diff --git a/patches/api/More-Enchantment-API.patch b/patches/api/More-Enchantment-API.patch index 1c654591a7..44a9849f61 100644 --- a/patches/api/More-Enchantment-API.patch +++ b/patches/api/More-Enchantment-API.patch @@ -3,6 +3,7 @@ From: Jake Potrebic Date: Thu, 6 May 2021 19:58:03 -0700 Subject: [PATCH] More Enchantment API +Co-authored-by: Luis 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 @@ -71,6 +72,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public abstract boolean isDiscoverable(); + + /** ++ * Gets the minimum modified cost of this enchantment at a specific level. ++ *

++ * Note this is not the number of experience levels needed, and does not directly translate to the levels shown in an enchanting table. ++ * This value is used in combination with factors such as tool enchantability to determine a final cost. ++ * See https://minecraft.wiki/w/Enchanting/Levels for more information. ++ *

++ * @param level The level of the enchantment ++ * @return The modified cost of this enchantment ++ */ ++ public abstract int getMinModifiedCost(int level); ++ ++ /** ++ * Gets the maximum modified cost of this enchantment at a specific level. ++ *

++ * Note this is not the number of experience levels needed, and does not directly translate to the levels shown in an enchanting table. ++ * This value is used in combination with factors such as tool enchantability to determine a final cost. ++ * See https://minecraft.wiki/w/Enchanting/Levels for more information. ++ *

++ * @param level The level of the enchantment ++ * @return The modified cost of this enchantment ++ */ ++ public abstract int getMaxModifiedCost(int level); ++ ++ /** + * Gets the rarity of this enchantment. + * + * @return the rarity @@ -116,6 +141,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return getEnchantment().isDiscoverable(); + } + ++ @Override ++ public int getMinModifiedCost(int level) { ++ return getEnchantment().getMinModifiedCost(level); ++ } ++ ++ @Override ++ public int getMaxModifiedCost(int level) { ++ return getEnchantment().getMaxModifiedCost(level); ++ } ++ + @NotNull + @Override + public io.papermc.paper.enchantments.EnchantmentRarity getRarity() { diff --git a/patches/server/More-Enchantment-API.patch b/patches/server/More-Enchantment-API.patch index d44d49def3..b1e5e3fce3 100644 --- a/patches/server/More-Enchantment-API.patch +++ b/patches/server/More-Enchantment-API.patch @@ -6,6 +6,8 @@ Subject: [PATCH] More Enchantment API == AT == public net.minecraft.world.item.enchantment.Enchantment slots +Co-authored-by: Luis + 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 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -35,6 +37,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override ++ public int getMinModifiedCost(int level) { ++ return target.getMinCost(level); ++ } ++ ++ @Override ++ public int getMaxModifiedCost(int level) { ++ return target.getMaxCost(level); ++ } ++ ++ @Override + public io.papermc.paper.enchantments.EnchantmentRarity getRarity() { + return fromNMSRarity(target.getRarity()); + }