Class ValueTypeBase<V extends IValue>

java.lang.Object
org.cyclops.integrateddynamics.core.evaluate.variable.ValueTypeBase<V>
All Implemented Interfaces:
IValueType<V>
Direct Known Subclasses:
ValueObjectTypeBase, ValueTypeBoolean, ValueTypeCategoryBase, ValueTypeDouble, ValueTypeInteger, ValueTypeLong, ValueTypeNbt, ValueTypeOperator, ValueTypeString

public abstract class ValueTypeBase<V extends IValue> extends Object implements IValueType<V>
Base implementation of a value type.
  • Constructor Details

    • ValueTypeBase

      public ValueTypeBase(String typeName, int color, net.minecraft.ChatFormatting colorFormat, Class<V> valueClass)
  • Method Details

    • isCategory

      public boolean isCategory()
      Specified by:
      isCategory in interface IValueType<V extends IValue>
      Returns:
      If this type is a category and should be handled accordingly.
    • isObject

      public boolean isObject()
      Specified by:
      isObject in interface IValueType<V extends IValue>
      Returns:
      If this type is an object type, otherwise it is a raw type.
    • getUniqueName

      public net.minecraft.resources.ResourceLocation getUniqueName()
      Specified by:
      getUniqueName in interface IValueType<V extends IValue>
      Returns:
      The unique name for this value type, only used for internal storage.
    • getUnlocalizedPrefix

      protected String getUnlocalizedPrefix()
    • getTypeNamespace

      protected String getTypeNamespace()
    • getTranslationKey

      public String getTranslationKey()
      Specified by:
      getTranslationKey in interface IValueType<V extends IValue>
      Returns:
      The unique name of this type that will also be used for display.
    • getTypeName

      public String getTypeName()
      Specified by:
      getTypeName in interface IValueType<V extends IValue>
      Returns:
      The name of this type without any prefixes.
    • getDisplayColor

      public int getDisplayColor()
      Specified by:
      getDisplayColor in interface IValueType<V extends IValue>
      Returns:
      The color that is used to identify this value type.
    • getDisplayColorFormat

      public net.minecraft.ChatFormatting getDisplayColorFormat()
      Specified by:
      getDisplayColorFormat in interface IValueType<V extends IValue>
      Returns:
      The color that is used to identify this value type using MC formatting codes.
    • correspondsTo

      public boolean correspondsTo(IValueType<?> valueType)
      Description copied from interface: IValueType
      Check if the given type corresponds with this type. To check bidirectional, use ValueHelpers.correspondsTo(IValueType, IValueType).
      Specified by:
      correspondsTo in interface IValueType<V extends IValue>
      Parameters:
      valueType - The value type to check correspondence with.
      Returns:
      If the given value type can be used with this value type.
    • registerModelResourceLocation

      protected void registerModelResourceLocation()
    • loadTooltip

      public void loadTooltip(List<net.minecraft.network.chat.Component> lines, boolean appendOptionalInfo, @Nullable V value)
      Description copied from interface: IValueType
      Add tooltip lines for this aspect when hovered in a gui.
      Specified by:
      loadTooltip in interface IValueType<V extends IValue>
      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.
    • canDeserialize

      public net.minecraft.network.chat.Component canDeserialize(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.Tag value)
      Description copied from interface: IValueType
      Check if the given value can be deserialized.
      Specified by:
      canDeserialize in interface IValueType<V extends IValue>
      Parameters:
      valueDeseralizationContext - Getter for blocks.
      value - The value to deserialize.
      Returns:
      An error or null.
    • materialize

      public V materialize(V value) throws EvaluationException
      Description copied from interface: IValueType
      Materialize the given value so that it can exist without any external references.
      Specified by:
      materialize in interface IValueType<V extends IValue>
      Parameters:
      value - The value to materialize.
      Returns:
      The materialized value.
      Throws:
      EvaluationException - if materialization fails because of a variable evaluation.
    • parseString

      public V parseString(String value) throws EvaluationException
      Description copied from interface: IValueType
      Parse the given string representation of a value. This corresponds to IValueType.toString(IValue).
      Specified by:
      parseString in interface IValueType<V extends IValue>
      Parameters:
      value - A string representation of a value.
      Returns:
      A value.
      Throws:
      EvaluationException - If parsing failed.
    • toString

      public String toString(V value)
      Description copied from interface: IValueType
      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 IValueType.parseString(String).
      Specified by:
      toString in interface IValueType<V extends IValue>
      Parameters:
      value - A value.
      Returns:
      A string representation of the given value.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createLogicProgrammerElement

      public ValueTypeLPElementBase createLogicProgrammerElement()
      Specified by:
      createLogicProgrammerElement in interface IValueType<V extends IValue>
      Returns:
      A new logic programmer element for this value type.
    • getModId

      protected String getModId()
    • cast

      public V cast(IValue value) throws EvaluationException
      Description copied from interface: IValueType
      Attempt to cast the given value to a value of this value type.
      Specified by:
      cast in interface IValueType<V extends IValue>
      Parameters:
      value - A value of unknown type.
      Returns:
      The casted value.
      Throws:
      EvaluationException - If the incorrect value type was found.