mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-12 01:41:05 +01:00
53 lines
2.6 KiB
Diff
53 lines
2.6 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||
|
Date: Fri, 12 Mar 2021 17:09:42 -0800
|
||
|
Subject: [PATCH] Item Rarity API
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/net/minecraft/server/Item.java b/src/main/java/net/minecraft/server/Item.java
|
||
|
index c3b57e8d572d13ec74d6df5544072cdc55756690..2304730bbd66f9a37975f2684794bb8402654fad 100644
|
||
|
--- a/src/main/java/net/minecraft/server/Item.java
|
||
|
+++ b/src/main/java/net/minecraft/server/Item.java
|
||
|
@@ -15,7 +15,7 @@ public class Item implements IMaterial {
|
||
|
protected static final UUID g = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3");
|
||
|
protected static final Random RANDOM = new Random();
|
||
|
protected final CreativeModeTab i;
|
||
|
- private final EnumItemRarity a;
|
||
|
+ private final EnumItemRarity a; public final EnumItemRarity getItemRarity() { return a; } // Paper - OBFHELPER
|
||
|
private final int maxStackSize;
|
||
|
private final int durability;
|
||
|
private final boolean d;
|
||
|
@@ -178,6 +178,7 @@ public class Item implements IMaterial {
|
||
|
return itemstack.hasEnchantments();
|
||
|
}
|
||
|
|
||
|
+ public EnumItemRarity getItemStackRarity(ItemStack itemStack) { return i(itemStack); } // Paper - OBFHELPER
|
||
|
public EnumItemRarity i(ItemStack itemstack) {
|
||
|
if (!itemstack.hasEnchantments()) {
|
||
|
return this.a;
|
||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||
|
index 00e53d577b1dcaccb409e62d35165ee015de9330..57d56ff1b41582f0d249b24165d5b08b02b0f9fe 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||
|
@@ -447,6 +447,20 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||
|
return net.minecraft.server.Entity.nextEntityId();
|
||
|
}
|
||
|
|
||
|
+ @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.getItemRarity().ordinal()];
|
||
|
+ }
|
||
|
+
|
||
|
+ @Override
|
||
|
+ public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) {
|
||
|
+ return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getItemStackRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()];
|
||
|
+ }
|
||
|
+
|
||
|
// Paper end
|
||
|
|
||
|
/**
|