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 Classes
    Modifier and Type
    Interface
    Description
    static class 
    Use this comparator for any comparisons with value types.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.network.chat.Component
    canDeserialize(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.Tag value)
    Check if the given value can be deserialized.
    cast(IValue value)
    Attempt to cast the given value to a value of this value type.
    boolean
    correspondsTo(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.
    int
     
    net.minecraft.ChatFormatting
     
     
     
    net.minecraft.resources.ResourceLocation
     
    default net.minecraft.client.resources.model.BakedModel
    getVariableItemOverrideModel(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.
    boolean
     
    boolean
     
    void
    loadTooltip(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.
    Parse the given string representation of a value.
    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.
    net.minecraft.nbt.Tag
    serialize(V value)
    Serialize the given value.
    net.minecraft.network.chat.MutableComponent
     
    toString(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

      net.minecraft.network.chat.MutableComponent toCompactString(V value)
      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

      boolean correspondsTo(IValueType<?> valueType)
      Check if the given type corresponds with this type. To check bidirectional, use ValueHelpers.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

      net.minecraft.nbt.Tag serialize(V value)
      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

      V deserialize(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.Tag value)
      Deserialize the given value.
      Parameters:
      valueDeseralizationContext - Deserialization context.
      value - The value to deserialize.
      Returns:
      The deserialized value.
    • materialize

      V materialize(V value) throws EvaluationException
      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

      String toString(V value)
      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 to parseString(String).
      Parameters:
      value - A value.
      Returns:
      A string representation of the given value.
    • parseString

      V parseString(String value) throws EvaluationException
      Parse the given string representation of a value. This corresponds to toString(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

      V cast(IValue value) throws EvaluationException
      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.