aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0572-Item-Rarity-API.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0572-Item-Rarity-API.patch')
-rw-r--r--patches/server/0572-Item-Rarity-API.patch31
1 files changed, 19 insertions, 12 deletions
diff --git a/patches/server/0572-Item-Rarity-API.patch b/patches/server/0572-Item-Rarity-API.patch
index 3e21a97a84..b691abcce6 100644
--- a/patches/server/0572-Item-Rarity-API.patch
+++ b/patches/server/0572-Item-Rarity-API.patch
@@ -6,27 +6,34 @@ Subject: [PATCH] Item Rarity API
== AT ==
public net.minecraft.world.item.Item rarity
+diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
+index 49be8074280d9840bb3d8e6880b4e0a8aa4ef0cb..589e8816a49f7d5cb6c4231e5851319647e71d3e 100644
+--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemType.java
+@@ -142,4 +142,11 @@ public class CraftItemType implements ItemType {
+ return this.item.getDescriptionId();
+ }
+ // Paper end
++
++ // Paper start - Item Rarity API
++ @Override
++ public io.papermc.paper.inventory.ItemRarity getItemRarity() {
++ return io.papermc.paper.inventory.ItemRarity.values()[this.item.rarity.ordinal()];
++ }
++ // Paper end
+ }
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
-index 16ef907b9443b9feedd768d0116762799fee9ab3..2a08fca2c863717b72341772630cd4b690f34968 100644
+index 6c454ec27082f04d4e6b74d718dd1e333e4b2f14..9f395fd7a38d2589269eeea00efd6dcada290088 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
-@@ -528,6 +528,20 @@ public final class CraftMagicNumbers implements UnsafeValues {
+@@ -587,6 +587,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
public String getMainLevelName() {
return ((net.minecraft.server.dedicated.DedicatedServer) net.minecraft.server.MinecraftServer.getServer()).getProperties().levelName;
}
+
+ @Override
-+ public io.papermc.paper.inventory.ItemRarity getItemRarity(org.bukkit.Material material) {
-+ Item item = getItem(material);
-+ if (item == null) {
-+ throw new IllegalArgumentException(material + " is not an item, and rarity does not apply to blocks");
-+ }
-+ return io.papermc.paper.inventory.ItemRarity.values()[item.rarity.ordinal()];
-+ }
-+
-+ @Override
+ public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) {
-+ return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()];
++ return io.papermc.paper.inventory.ItemRarity.values()[((org.bukkit.craftbukkit.inventory.CraftItemType)itemStack.getType()).getHandle().getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()];
+ }
// Paper end