Record Class TimeComponent

java.lang.Object
java.lang.Record
dev.latvian.mods.kubejs.recipe.component.TimeComponent
All Implemented Interfaces:
RecipeComponent<TickDuration>

public record TimeComponent(RecipeComponentType<?> type, long scale, com.mojang.serialization.Codec<TickDuration> codec) extends Record implements RecipeComponent<TickDuration>
  • Field Details

  • Constructor Details

    • TimeComponent

      public TimeComponent(RecipeComponentType<?> type, long scale, com.mojang.serialization.Codec<TickDuration> codec)
      Creates an instance of a TimeComponent record class.
      Parameters:
      type - the value for the type record component
      scale - the value for the scale record component
      codec - the value for the codec record component
  • Method Details

    • codec

      public com.mojang.serialization.Codec<TickDuration> codec()
      Returns the value of the codec record component.
      Specified by:
      codec in interface RecipeComponent<TickDuration>
      Returns:
      the value of the codec record component
    • typeInfo

      public dev.latvian.mods.rhino.type.TypeInfo typeInfo()
      Description copied from interface: RecipeComponent
      Defines a description for how this component may be constructed. Type descriptions may be comprised of a primitive type such as a string, number or Java class (which may be useful if that that class has an appropriate type wrapper for it already), an array of fixed or dynamic length, a map / object, or a union of multiple types.

      Type descriptions are used by addons like ProbeJS to provide typing hints.

      Specified by:
      typeInfo in interface RecipeComponent<TickDuration>
      Returns:
      A description of how this component may be constructed
    • hasPriority

      public boolean hasPriority(RecipeMatchContext cx, Object from)
      Description copied from interface: RecipeComponent
      Declares whether this component should take priority when being considered by e.g. an EitherRecipeComponent during deserialization.
      Specified by:
      hasPriority in interface RecipeComponent<TickDuration>
      Parameters:
      cx - Script context
      from - The object to be deserialized from
      Returns:
      Whether this component should take priority
    • wrap

      public TickDuration wrap(RecipeScriptContext cx, Object from)
      Description copied from interface: RecipeComponent
      Method to read the value contained within this component from an input object; this may be some arbitrary value passed into a schema's constructor(s) or automatically generated builder methods. By default, it will attempt to type wrap based on RecipeComponent.typeInfo()
      Specified by:
      wrap in interface RecipeComponent<TickDuration>
      Parameters:
      cx - Script context
      from - An object to be converted to a value for this component
      Returns:
      The value read from the input
    • buildUniqueId

      public void buildUniqueId(UniqueIdBuilder builder, TickDuration value)
      Specified by:
      buildUniqueId in interface RecipeComponent<TickDuration>
    • isEmpty

      public boolean isEmpty(TickDuration value)
      Description copied from interface: RecipeComponent
      Shallow empty check function
      Specified by:
      isEmpty in interface RecipeComponent<TickDuration>
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public RecipeComponentType<?> type()
      Returns the value of the type record component.
      Specified by:
      type in interface RecipeComponent<TickDuration>
      Returns:
      the value of the type record component
    • scale

      public long scale()
      Returns the value of the scale record component.
      Returns:
      the value of the scale record component