Interface IValueType<V extends IValue>
- All Known Subinterfaces:
IValueTypeCategory<V>,IValueTypeNamed<V>,IValueTypeNullable<V>,IValueTypeNumber<V>,IValueTypeUniquelyNamed<V>
- All Known Implementing Classes:
ValueObjectTypeBase,ValueObjectTypeBlock,ValueObjectTypeEntity,ValueObjectTypeFluidStack,ValueObjectTypeIngredients,ValueObjectTypeItemStack,ValueObjectTypeRecipe,ValueTypeBase,ValueTypeBoolean,ValueTypeCategoryAny,ValueTypeCategoryBase,ValueTypeCategoryNamed,ValueTypeCategoryNullable,ValueTypeCategoryNumber,ValueTypeCategoryUniquelyNamed,ValueTypeDouble,ValueTypeInteger,ValueTypeList,ValueTypeLong,ValueTypeNbt,ValueTypeOperator,ValueTypeString
public interface IValueType<V extends IValue>
Type of value
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classUse this comparator for any comparisons with value types. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.network.chat.ComponentcanDeserialize(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.Tag value) Check if the given value can be deserialized.Attempt to cast the given value to a value of this value type.booleancorrespondsTo(IValueType<?> valueType) Check if the given type corresponds with this type.deserialize(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.Tag value) Deserialize the given value.default ValuePredicate<V>deserializeValuePredicate(com.google.gson.JsonObject element, IValue value) Deserialize the given JSON element to a value predicate.Create an immutable default value.intnet.minecraft.ChatFormattingnet.minecraft.resources.ResourceLocationdefault net.minecraft.client.resources.model.BakedModelgetVariableItemOverrideModel(V value, net.minecraft.client.resources.model.BakedModel model, net.minecraft.world.item.ItemStack stack, net.minecraft.client.multiplayer.ClientLevel world, net.minecraft.world.entity.LivingEntity livingEntity) An optional baked model to override when rendering the variable as item.booleanbooleanisObject()voidloadTooltip(List<net.minecraft.network.chat.Component> lines, boolean appendOptionalInfo, V value) Add tooltip lines for this aspect when hovered in a gui.materialize(V value) Materialize the given value so that it can exist without any external references.parseString(String value) Parse the given string representation of a value.default voidrenderISTER(V value, net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource buffer, int combinedLight, int combinedOverlay) Called during ISTER rendering of an variable item.net.minecraft.nbt.TagSerialize the given value.net.minecraft.network.chat.MutableComponenttoCompactString(V value) Get the string representation of the given value.
-
Method Details
-
isCategory
boolean isCategory()- Returns:
- If this type is a category and should be handled accordingly.
-
isObject
boolean isObject()- Returns:
- If this type is an object type, otherwise it is a raw type.
-
getDefault
V getDefault()Create an immutable default value.- Returns:
- The default value of this type.
-
getTypeName
String getTypeName()- Returns:
- The name of this type without any prefixes.
-
getUniqueName
net.minecraft.resources.ResourceLocation getUniqueName()- Returns:
- The unique name for this value type, only used for internal storage.
-
getTranslationKey
String getTranslationKey()- Returns:
- The unique name of this type that will also be used for display.
-
loadTooltip
void loadTooltip(List<net.minecraft.network.chat.Component> lines, boolean appendOptionalInfo, @Nullable V value) Add tooltip lines for this aspect when hovered in a gui.- Parameters:
lines- The list to add lines to.appendOptionalInfo- If shift-to-show info should be added.value- The value to show the tooltip for.
-
toCompactString
- Parameters:
value- The value- Returns:
- A short string representation used in guis to show the value.
-
getDisplayColor
int getDisplayColor()- Returns:
- The color that is used to identify this value type.
-
getDisplayColorFormat
net.minecraft.ChatFormatting getDisplayColorFormat()- Returns:
- The color that is used to identify this value type using MC formatting codes.
-
correspondsTo
Check if the given type corresponds with this type. To check bidirectional, useValueHelpers.correspondsTo(IValueType, IValueType).- Parameters:
valueType- The value type to check correspondence with.- Returns:
- If the given value type can be used with this value type.
-
serialize
Serialize the given value.- Parameters:
value- The value to serialize.- Returns:
- The serialized value.
-
canDeserialize
@Nullable net.minecraft.network.chat.Component canDeserialize(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.Tag value) Check if the given value can be deserialized.- Parameters:
valueDeseralizationContext- Getter for blocks.value- The value to deserialize.- Returns:
- An error or null.
-
deserialize
Deserialize the given value.- Parameters:
valueDeseralizationContext- Deserialization context.value- The value to deserialize.- Returns:
- The deserialized value.
-
materialize
Materialize the given value so that it can exist without any external references.- Parameters:
value- The value to materialize.- Returns:
- The materialized value.
- Throws:
EvaluationException- if materialization fails because of a variable evaluation.
-
toString
Get the string representation of the given value. This is useful for cases when the value needs to be edited in a GUI. This corresponds toparseString(String).- Parameters:
value- A value.- Returns:
- A string representation of the given value.
-
parseString
Parse the given string representation of a value. This corresponds totoString(IValue).- Parameters:
value- A string representation of a value.- Returns:
- A value.
- Throws:
EvaluationException- If parsing failed.
-
createLogicProgrammerElement
IValueTypeLogicProgrammerElement createLogicProgrammerElement()- Returns:
- A new logic programmer element for this value type.
-
deserializeValuePredicate
default ValuePredicate<V> deserializeValuePredicate(com.google.gson.JsonObject element, @Nullable IValue value) Deserialize the given JSON element to a value predicate.- Parameters:
element- The JSON element.value- The value.- Returns:
- The value predicate.
-
cast
Attempt to cast the given value to a value of this value type.- Parameters:
value- A value of unknown type.- Returns:
- The casted value.
- Throws:
EvaluationException- If the incorrect value type was found.
-
getVariableItemOverrideModel
@Nullable default net.minecraft.client.resources.model.BakedModel getVariableItemOverrideModel(V value, net.minecraft.client.resources.model.BakedModel model, net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.client.multiplayer.ClientLevel world, @Nullable net.minecraft.world.entity.LivingEntity livingEntity) An optional baked model to override when rendering the variable as item.- Parameters:
value- The value to value to get the model for.model- The original baked model.stack- The variable stack.world- The client world.livingEntity- The entity holding the stack.- Returns:
- The overridden model. Will fallback to default if null.
-
renderISTER
default void renderISTER(V value, net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource buffer, int combinedLight, int combinedOverlay) Called during ISTER rendering of an variable item.- Parameters:
value- The value to value to render.stack- The variable stack.transformType- Transform type.matrixStack- Matrix stack.buffer- Render buffer.combinedLight- Lighting.combinedOverlay- Overlay.
-