Record Class EnchantRecipe
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.api.enchantment.recipe.EnchantRecipe
- Record Components:
input- AHolderSetof eligible inputItems that match this recipe.output- The resulting outputItemholder produced when enchanted.attachment- TheEnchantmentAttachmentmode dictating where the enchantment is stored on the output.enchantability- The base enchantability value assigned to the input item during altar generation (minimum1).
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
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<EnchantRecipe> The codec responsible for serializing and deserializingEnchantRecipedefinitions from JSON. -
Constructor Summary
ConstructorsConstructorDescriptionEnchantRecipe(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 aEnchantReciperecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theattachmentrecord component.intReturns the effective enchantability for this recipe, clamped to at least1.final booleanIndicates whether some other object is "equal to" this one.static Optional<EnchantRecipe> get(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.ItemStack target) Searches the dynamicEnchantRecipes.RECIPE_REGISTRY_KEYregistry to find a recipe whoseinput()matches the given targetItemStack(e.g.,Book -> Enchanted Book).final inthashCode()Returns a hash code value for this object.net.minecraft.core.HolderSet<net.minecraft.world.item.Item> input()Returns the value of theinputrecord component.net.minecraft.core.Holder<net.minecraft.world.item.Item> output()Returns the value of theoutputrecord component.static Optional<EnchantRecipe> reverse(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.ItemStack output) Searches the dynamicEnchantRecipes.RECIPE_REGISTRY_KEYregistry in reverse to find a recipe whoseoutput()matches the givenItemStack(e.g., reverting anEnchanted Page -> Paper).final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
The codec responsible for serializing and deserializingEnchantRecipedefinitions 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 aEnchantReciperecord class.- Parameters:
input- the value for theinputrecord componentoutput- the value for theoutputrecord componentattachment- the value for theattachmentrecord componentenchantability- the value for theenchantabilityrecord component
-
-
Method Details
-
enchantability
public int enchantability()Returns the effective enchantability for this recipe, clamped to at least1.- 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 dynamicEnchantRecipes.RECIPE_REGISTRY_KEYregistry to find a recipe whoseinput()matches the given targetItemStack(e.g.,Book -> Enchanted Book).- Parameters:
registryAccess- The activeRegistryAccessproviding the recipe registry.target- The inputItemStackto match.- Returns:
- An
Optionalcontaining the matchingEnchantRecipe, or empty if none matches.
-
reverse
public static Optional<EnchantRecipe> reverse(net.minecraft.core.RegistryAccess registryAccess, net.minecraft.world.item.ItemStack output) Searches the dynamicEnchantRecipes.RECIPE_REGISTRY_KEYregistry in reverse to find a recipe whoseoutput()matches the givenItemStack(e.g., reverting anEnchanted Page -> Paper).- Parameters:
registryAccess- The activeRegistryAccessproviding the recipe registry.output- The outputItemStackto reverse-match.- Returns:
- An
Optionalcontaining the matchingEnchantRecipe, or empty if none matches.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
input
public net.minecraft.core.HolderSet<net.minecraft.world.item.Item> input()Returns the value of theinputrecord component.- Returns:
- the value of the
inputrecord component
-
output
public net.minecraft.core.Holder<net.minecraft.world.item.Item> output()Returns the value of theoutputrecord component.- Returns:
- the value of the
outputrecord component
-
attachment
Returns the value of theattachmentrecord component.- Returns:
- the value of the
attachmentrecord component
-