Record Class EnchantRecipe

java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.enchantment.recipe.EnchantRecipe
Record Components:
input - A HolderSet of eligible input Items that match this recipe.
output - The resulting output Item holder produced when enchanted.
attachment - The EnchantmentAttachment mode dictating where the enchantment is stored on the output.
enchantability - The base enchantability value assigned to the input item during altar generation (minimum 1).

public record EnchantRecipe(net.minecraft.core.HolderSet<net.minecraft.world.item.Item> input, net.minecraft.core.Holder<net.minecraft.world.item.Item> output, EnchantmentAttachment attachment, int enchantability) extends Record
A data-driven record defining an enchanting transmutation recipe.

Determines how an input item (or tag of items) transforms into an output item when an enchantment is applied to it in the Enchanting Altar, Anvil, Tome Bartering, or loot generation (for example, transforming Paper into an Enchanted Page or a Book into an Enchanted Book), as well as how Grindstones and catalyst consumption revert the output item back to its input item.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<EnchantRecipe>
    The codec responsible for serializing and deserializing EnchantRecipe definitions from JSON.
  • Constructor Summary

    Constructors
    Constructor
    Description
    EnchantRecipe(net.minecraft.core.HolderSet<net.minecraft.world.item.Item> input, net.minecraft.core.Holder<net.minecraft.world.item.Item> output, EnchantmentAttachment attachment, int enchantability)
    Creates an instance of a EnchantRecipe record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the attachment record component.
    int
    Returns the effective enchantability for this recipe, clamped to at least 1.
    final boolean
    Indicates whether some other object is "equal to" this one.
    get(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.ItemStack target)
    Searches the dynamic EnchantRecipes.RECIPE_REGISTRY_KEY registry to find a recipe whose input() matches the given target ItemStack (e.g., Book -> Enchanted Book).
    final int
    Returns a hash code value for this object.
    net.minecraft.core.HolderSet<net.minecraft.world.item.Item>
    Returns the value of the input record component.
    net.minecraft.core.Holder<net.minecraft.world.item.Item>
    Returns the value of the output record component.
    reverse(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.ItemStack output)
    Searches the dynamic EnchantRecipes.RECIPE_REGISTRY_KEY registry in reverse to find a recipe whose output() matches the given ItemStack (e.g., reverting an Enchanted Page -> Paper).
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<EnchantRecipe> CODEC
      The codec responsible for serializing and deserializing EnchantRecipe definitions from JSON.
  • Constructor Details

    • EnchantRecipe

      public EnchantRecipe(net.minecraft.core.HolderSet<net.minecraft.world.item.Item> input, net.minecraft.core.Holder<net.minecraft.world.item.Item> output, EnchantmentAttachment attachment, int enchantability)
      Creates an instance of a EnchantRecipe record class.
      Parameters:
      input - the value for the input record component
      output - the value for the output record component
      attachment - the value for the attachment record component
      enchantability - the value for the enchantability record component
  • Method Details

    • enchantability

      public int enchantability()
      Returns the effective enchantability for this recipe, clamped to at least 1.
      Returns:
      The clamped integer enchantability value.
    • get

      public static Optional<EnchantRecipe> get(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.ItemStack target)
      Searches the dynamic EnchantRecipes.RECIPE_REGISTRY_KEY registry to find a recipe whose input() matches the given target ItemStack (e.g., Book -> Enchanted Book).
      Parameters:
      registryAccess - The active RegistryAccess providing the recipe registry.
      target - The input ItemStack to match.
      Returns:
      An Optional containing the matching EnchantRecipe, or empty if none matches.
    • reverse

      public static Optional<EnchantRecipe> reverse(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.ItemStack output)
      Searches the dynamic EnchantRecipes.RECIPE_REGISTRY_KEY registry in reverse to find a recipe whose output() matches the given ItemStack (e.g., reverting an Enchanted Page -> Paper).
      Parameters:
      registryAccess - The active RegistryAccess providing the recipe registry.
      output - The output ItemStack to reverse-match.
      Returns:
      An Optional containing the matching EnchantRecipe, or empty if none matches.
    • toString

      public final 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.
    • input

      public net.minecraft.core.HolderSet<net.minecraft.world.item.Item> input()
      Returns the value of the input record component.
      Returns:
      the value of the input record component
    • output

      public net.minecraft.core.Holder<net.minecraft.world.item.Item> output()
      Returns the value of the output record component.
      Returns:
      the value of the output record component
    • attachment

      public EnchantmentAttachment attachment()
      Returns the value of the attachment record component.
      Returns:
      the value of the attachment record component