Record Class ResourceKeyComponent<T>

java.lang.Object
java.lang.Record
dev.latvian.mods.kubejs.recipe.component.ResourceKeyComponent<T>
All Implemented Interfaces:
RecipeComponent<net.minecraft.resources.ResourceKey<T>>

public record ResourceKeyComponent<T>(@Nullable RecipeComponentType<?> typeOverride, net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> registryKey, com.mojang.serialization.Codec<net.minecraft.resources.ResourceKey<T>> codec, dev.latvian.mods.rhino.type.TypeInfo typeInfo) extends Record implements RecipeComponent<net.minecraft.resources.ResourceKey<T>>
  • Field Details

    • DIMENSION

      public static final RecipeComponentType<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>> DIMENSION
    • LOOT_TABLE

      public static final RecipeComponentType<net.minecraft.resources.ResourceKey<net.minecraft.world.level.storage.loot.LootTable>> LOOT_TABLE
    • TYPE

      public static final RecipeComponentType<?> TYPE
  • Constructor Details

    • ResourceKeyComponent

      public ResourceKeyComponent(@Nullable @Nullable RecipeComponentType<?> typeOverride, net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> registryKey, com.mojang.serialization.Codec<net.minecraft.resources.ResourceKey<T>> codec, dev.latvian.mods.rhino.type.TypeInfo typeInfo)
      Creates an instance of a ResourceKeyComponent record class.
      Parameters:
      typeOverride - the value for the typeOverride record component
      registryKey - the value for the registryKey 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.resources.ResourceKey<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
    • 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.resources.ResourceKey<T> value)
      Specified by:
      toString in interface RecipeComponent<T>
    • 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.
    • typeOverride

      @Nullable public @Nullable RecipeComponentType<?> typeOverride()
      Returns the value of the typeOverride record component.
      Returns:
      the value of the typeOverride record component
    • registryKey

      public net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> registryKey()
      Returns the value of the registryKey record component.
      Returns:
      the value of the registryKey record component
    • codec

      public com.mojang.serialization.Codec<net.minecraft.resources.ResourceKey<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