Record Class BlockStateComponent

java.lang.Object
java.lang.Record
dev.latvian.mods.kubejs.recipe.component.BlockStateComponent
All Implemented Interfaces:
RecipeComponent<net.minecraft.world.level.block.state.BlockState>

public record BlockStateComponent(RecipeComponentType<?> type, boolean preferObjectForm, boolean allowEmpty) extends Record implements RecipeComponent<net.minecraft.world.level.block.state.BlockState>
  • Field Details

    • TYPE_INFO

      public static final dev.latvian.mods.rhino.type.TypeInfo TYPE_INFO
    • BLOCK

      public static final RecipeComponentType<net.minecraft.world.level.block.state.BlockState> BLOCK
    • BLOCK_STRING

      public static final RecipeComponentType<net.minecraft.world.level.block.state.BlockState> BLOCK_STRING
    • OPTIONAL_BLOCK

      public static final RecipeComponentType<net.minecraft.world.level.block.state.BlockState> OPTIONAL_BLOCK
    • OPTIONAL_BLOCK_STRING

      public static final RecipeComponentType<net.minecraft.world.level.block.state.BlockState> OPTIONAL_BLOCK_STRING
  • Constructor Details

    • BlockStateComponent

      public BlockStateComponent(RecipeComponentType<?> type, boolean preferObjectForm, boolean allowEmpty)
      Creates an instance of a BlockStateComponent record class.
      Parameters:
      type - the value for the type record component
      preferObjectForm - the value for the preferObjectForm record component
      allowEmpty - the value for the allowEmpty record component
  • Method Details

    • codec

      public com.mojang.serialization.Codec<net.minecraft.world.level.block.state.BlockState> codec()
      Specified by:
      codec in interface RecipeComponent<net.minecraft.world.level.block.state.BlockState>
    • 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<net.minecraft.world.level.block.state.BlockState>
      Returns:
      A description of how this component may be constructed
    • wrap

      public net.minecraft.world.level.block.state.BlockState 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<net.minecraft.world.level.block.state.BlockState>
      Parameters:
      cx - Script context
      from - An object to be converted to a value for this component
      Returns:
      The value read from the input
    • matches

      public boolean matches(RecipeMatchContext cx, net.minecraft.world.level.block.state.BlockState value, ReplacementMatchInfo match)
      Specified by:
      matches in interface RecipeComponent<net.minecraft.world.level.block.state.BlockState>
      Parameters:
      cx - Script context
      value - The value to check
      match - The replacement match to check against
      Returns:
      true if the given value matches the given replacement match.
    • isEmpty

      public boolean isEmpty(net.minecraft.world.level.block.state.BlockState value)
      Description copied from interface: RecipeComponent
      Shallow empty check function
      Specified by:
      isEmpty in interface RecipeComponent<net.minecraft.world.level.block.state.BlockState>
    • buildUniqueId

      public void buildUniqueId(UniqueIdBuilder builder, net.minecraft.world.level.block.state.BlockState value)
      Specified by:
      buildUniqueId in interface RecipeComponent<net.minecraft.world.level.block.state.BlockState>
    • 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
    • toString

      public String toString(OpsContainer ops, net.minecraft.world.level.block.state.BlockState value)
      Specified by:
      toString in interface RecipeComponent<net.minecraft.world.level.block.state.BlockState>
    • 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<net.minecraft.world.level.block.state.BlockState>
      Returns:
      the value of the type record component
    • preferObjectForm

      public boolean preferObjectForm()
      Returns the value of the preferObjectForm record component.
      Returns:
      the value of the preferObjectForm record component
    • allowEmpty

      public boolean allowEmpty()
      Returns the value of the allowEmpty record component.
      Specified by:
      allowEmpty in interface RecipeComponent<net.minecraft.world.level.block.state.BlockState>
      Returns:
      the value of the allowEmpty record component