Record Class RegistryComponent<T>

java.lang.Object
java.lang.Record
dev.latvian.mods.kubejs.recipe.component.RegistryComponent<T>
All Implemented Interfaces:
RecipeComponent<net.minecraft.core.Holder<T>>

public record RegistryComponent<T>(net.minecraft.core.Registry<T> registry, @Nullable RegistryType<T> regType, com.mojang.serialization.Codec<net.minecraft.core.Holder<T>> codec, dev.latvian.mods.rhino.type.TypeInfo typeInfo) extends Record implements RecipeComponent<net.minecraft.core.Holder<T>>
  • Field Details

  • Constructor Details

    • RegistryComponent

      public RegistryComponent(RegistryAccessContainer registries, @Nullable @Nullable RegistryType<T> regType, net.minecraft.resources.ResourceKey key)
    • RegistryComponent

      public RegistryComponent(RegistryAccessContainer registries, net.minecraft.resources.ResourceKey key)
    • RegistryComponent

      public RegistryComponent(net.minecraft.core.Registry<T> registry, @Nullable @Nullable RegistryType<T> regType, com.mojang.serialization.Codec<net.minecraft.core.Holder<T>> codec, dev.latvian.mods.rhino.type.TypeInfo typeInfo)
      Creates an instance of a RegistryComponent record class.
      Parameters:
      registry - the value for the registry record component
      regType - the value for the regType record component
      codec - the value for the codec record component
      typeInfo - the value for the typeInfo record component
  • Method Details

    • type

      public RecipeComponentType<?> type()
      Specified by:
      type in interface RecipeComponent<T>
    • wrap

      public net.minecraft.core.Holder<T> 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<T>
      Parameters:
      cx - Script context
      from - An object to be converted to a value for this component
      Returns:
      The value read from the input
    • 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<T>
      Parameters:
      cx - Script context
      from - The object to be deserialized from
      Returns:
      Whether this component should take priority
    • buildUniqueId

      public void buildUniqueId(UniqueIdBuilder builder, net.minecraft.core.Holder<T> value)
      Specified by:
      buildUniqueId in interface RecipeComponent<T>
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • registry

      public net.minecraft.core.Registry<T> registry()
      Returns the value of the registry record component.
      Returns:
      the value of the registry record component
    • regType

      @Nullable public @Nullable RegistryType<T> regType()
      Returns the value of the regType record component.
      Returns:
      the value of the regType record component
    • codec

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

      public dev.latvian.mods.rhino.type.TypeInfo typeInfo()
      Returns the value of the typeInfo record component.
      Specified by:
      typeInfo in interface RecipeComponent<T>
      Returns:
      the value of the typeInfo record component