3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-14 20:10:05 +01:00

Expose anvil cost in the API (#10682)

Dieser Commit ist enthalten in:
Janet Blackquill 2024-05-25 19:47:14 -04:00 committet von GitHub
Ursprung 26e90b9ffb
Commit f0bd0cca8f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
2 geänderte Dateien mit 21 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,7 @@ Date: Thu, 6 May 2021 19:58:03 -0700
Subject: [PATCH] More Enchantment API
Co-authored-by: Luis <luisc99@icloud.com>
Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
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
@ -37,7 +38,7 @@ index 0000000000000000000000000000000000000000..50c49739cc25679c9d241466e3069c9c
+ }
+}
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
index 4e41980dfbb256356231bc9565f6a90ea66aab76..de616cecaeb45018d96685c916532188e369bdd4 100644
index 4e41980dfbb256356231bc9565f6a90ea66aab76..73e367fdf405b926599f4a7d34d61c25bb6c6e81 100644
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
+++ b/src/main/java/org/bukkit/enchantments/Enchantment.java
@@ -292,11 +292,7 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
@ -52,7 +53,7 @@ index 4e41980dfbb256356231bc9565f6a90ea66aab76..de616cecaeb45018d96685c916532188
public abstract boolean isCursed();
/**
@@ -330,6 +326,87 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
@@ -330,6 +326,97 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
* @return the name of the enchantment with {@code level} applied
*/
public abstract net.kyori.adventure.text.@NotNull Component displayName(int level);
@ -97,6 +98,16 @@ index 4e41980dfbb256356231bc9565f6a90ea66aab76..de616cecaeb45018d96685c916532188
+ public abstract int getMaxModifiedCost(int level);
+
+ /**
+ * Gets cost of applying this enchantment using an anvil.
+ * <p>
+ * Note that this is halved when using an enchantment book, and is multiplied by the level of the enchantment.
+ * See <a href="https://minecraft.wiki/w/Anvil_mechanics">https://minecraft.wiki/w/Anvil_mechanics</a> for more information.
+ * </p>
+ * @return The anvil cost of this enchantment
+ */
+ public abstract int getAnvilCost();
+
+ /**
+ * Gets the rarity of this enchantment.
+ *
+ * @return the rarity

Datei anzeigen

@ -7,9 +7,10 @@ Subject: [PATCH] More Enchantment API
public net.minecraft.world.item.enchantment.Enchantment definition
Co-authored-by: Luis <luisc99@icloud.com>
Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
index faf0f726453aa957d17b75dfd8de5b40d984e69c..3157cac1905728ba0f51af412a5bba57578352b3 100644
index faf0f726453aa957d17b75dfd8de5b40d984e69c..067aa761abd023991c884278a5cf0a63684026aa 100644
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
@@ -94,7 +94,7 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
@ -21,7 +22,7 @@ index faf0f726453aa957d17b75dfd8de5b40d984e69c..3157cac1905728ba0f51af412a5bba57
}
@Override
@@ -166,13 +166,70 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
@@ -166,13 +166,75 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
// Paper start
@Override
public net.kyori.adventure.text.Component displayName(int level) {
@ -55,6 +56,11 @@ index faf0f726453aa957d17b75dfd8de5b40d984e69c..3157cac1905728ba0f51af412a5bba57
+ }
+
+ @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+.");
+ }