From fe5c08d312b8159d513feb5b5c6c8819dece0514 Mon Sep 17 00:00:00 2001 From: Janet Blackquill Date: Sat, 25 May 2024 19:47:14 -0400 Subject: [PATCH] Expose anvil cost in the API (#10682) --- patches/api/More-Enchantment-API.patch | 11 +++++++++++ patches/server/More-Enchantment-API.patch | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/patches/api/More-Enchantment-API.patch b/patches/api/More-Enchantment-API.patch index 7a7f41eb9..f6d7c7a9f 100644 --- a/patches/api/More-Enchantment-API.patch +++ b/patches/api/More-Enchantment-API.patch @@ -4,6 +4,7 @@ Date: Thu, 6 May 2021 19:58:03 -0700 Subject: [PATCH] More Enchantment API Co-authored-by: Luis +Co-authored-by: Janet Blackquill diff --git a/src/main/java/io/papermc/paper/enchantments/EnchantmentRarity.java b/src/main/java/io/papermc/paper/enchantments/EnchantmentRarity.java new file mode 100644 @@ -97,6 +98,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public abstract int getMaxModifiedCost(int level); + + /** ++ * Gets cost of applying this enchantment using an anvil. ++ *

++ * Note that this is halved when using an enchantment book, and is multiplied by the level of the enchantment. ++ * See https://minecraft.wiki/w/Anvil_mechanics for more information. ++ *

++ * @return The anvil cost of this enchantment ++ */ ++ public abstract int getAnvilCost(); ++ ++ /** + * Gets the rarity of this enchantment. + * + * @return the rarity diff --git a/patches/server/More-Enchantment-API.patch b/patches/server/More-Enchantment-API.patch index 5813bba79..25dfa27d0 100644 --- a/patches/server/More-Enchantment-API.patch +++ b/patches/server/More-Enchantment-API.patch @@ -7,6 +7,7 @@ Subject: [PATCH] More Enchantment API public net.minecraft.world.item.enchantment.Enchantment definition Co-authored-by: Luis +Co-authored-by: Janet Blackquill diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -55,6 +56,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override ++ public int getAnvilCost() { ++ return this.handle.getAnvilCost(); ++ } ++ ++ @Override + public io.papermc.paper.enchantments.EnchantmentRarity getRarity() { + throw new UnsupportedOperationException("Enchantments don't have a rarity anymore in 1.20.5+."); + }