diff options
Diffstat (limited to 'patches')
-rw-r--r-- | patches/api/0285-More-Enchantment-API.patch | 43 | ||||
-rw-r--r-- | patches/server/0598-More-Enchantment-API.patch | 14 |
2 files changed, 52 insertions, 5 deletions
diff --git a/patches/api/0285-More-Enchantment-API.patch b/patches/api/0285-More-Enchantment-API.patch index 0ccfe049b4..88be180baf 100644 --- a/patches/api/0285-More-Enchantment-API.patch +++ b/patches/api/0285-More-Enchantment-API.patch @@ -3,6 +3,7 @@ From: Jake Potrebic <[email protected]> Date: Thu, 6 May 2021 19:58:03 -0700 Subject: [PATCH] More Enchantment API +Co-authored-by: Luis <[email protected]> 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 @@ -35,7 +36,7 @@ index 0000000000000000000000000000000000000000..e6a40c1fcea761bd66743b50e3da3d14 + } +} diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java -index 1b6f42ff632b1f3f5034c825e99b72f389a890b4..4cfe8501368f601fdd4203570f4e6a8f6f9685e6 100644 +index 1b6f42ff632b1f3f5034c825e99b72f389a890b4..8183f26545998e076ad93b4e28f3a3ff693d1032 100644 --- a/src/main/java/org/bukkit/enchantments/Enchantment.java +++ b/src/main/java/org/bukkit/enchantments/Enchantment.java @@ -273,11 +273,7 @@ public abstract class Enchantment implements Keyed, net.kyori.adventure.translat @@ -50,7 +51,7 @@ index 1b6f42ff632b1f3f5034c825e99b72f389a890b4..4cfe8501368f601fdd4203570f4e6a8f public abstract boolean isCursed(); /** -@@ -311,6 +307,46 @@ public abstract class Enchantment implements Keyed, net.kyori.adventure.translat +@@ -311,6 +307,70 @@ public abstract class Enchantment implements Keyed, net.kyori.adventure.translat * @return the name of the enchantment with {@code level} applied */ public abstract net.kyori.adventure.text.@NotNull Component displayName(int level); @@ -71,6 +72,30 @@ index 1b6f42ff632b1f3f5034c825e99b72f389a890b4..4cfe8501368f601fdd4203570f4e6a8f + public abstract boolean isDiscoverable(); + + /** ++ * Gets the minimum modified cost of this enchantment at a specific level. ++ * <p> ++ * 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 <a href="https://minecraft.wiki/w/Enchanting/Levels">https://minecraft.wiki/w/Enchanting/Levels</a> for more information. ++ * </p> ++ * @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. ++ * <p> ++ * 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 <a href="https://minecraft.wiki/w/Enchanting/Levels">https://minecraft.wiki/w/Enchanting/Levels</a> for more information. ++ * </p> ++ * @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 @@ -98,10 +123,10 @@ index 1b6f42ff632b1f3f5034c825e99b72f389a890b4..4cfe8501368f601fdd4203570f4e6a8f @Override diff --git a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java -index a39f9c078f42451bd122f3e3729d10ca299bee5f..5f42a9c0c43ced10b754170d7c83793a99fce81b 100644 +index a39f9c078f42451bd122f3e3729d10ca299bee5f..4a838d6eab5a17d7204dba96a882b6c5a22636fc 100644 --- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java +++ b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java -@@ -74,5 +74,32 @@ public class EnchantmentWrapper extends Enchantment { +@@ -74,5 +74,42 @@ public class EnchantmentWrapper extends Enchantment { public @NotNull String translationKey() { return getEnchantment().translationKey(); } @@ -116,6 +141,16 @@ index a39f9c078f42451bd122f3e3729d10ca299bee5f..5f42a9c0c43ced10b754170d7c83793a + 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/0598-More-Enchantment-API.patch b/patches/server/0598-More-Enchantment-API.patch index fc96204583..8c55414347 100644 --- a/patches/server/0598-More-Enchantment-API.patch +++ b/patches/server/0598-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 <[email protected]> + diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 5b09e7e08c61b10044ac5f481bf10bb79feda8a3..06a857ae432fc81737b53a6d2b8742c1e80e5f8a 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -19,7 +21,7 @@ index 5b09e7e08c61b10044ac5f481bf10bb79feda8a3..06a857ae432fc81737b53a6d2b8742c1 } @Override -@@ -199,6 +199,45 @@ public class CraftEnchantment extends Enchantment { +@@ -199,6 +199,55 @@ public class CraftEnchantment extends Enchantment { public String translationKey() { return this.target.getDescriptionId(); } @@ -35,6 +37,16 @@ index 5b09e7e08c61b10044ac5f481bf10bb79feda8a3..06a857ae432fc81737b53a6d2b8742c1 + } + + @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()); + } |