2021-03-13 02:27:48 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java
|
|
|
|
index 5d7c44a53fb98532057b09176677ce0d719b055b..e6a838430084d64326d1042c7b2089f49a24a789 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/item/Item.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/Item.java
|
|
|
|
@@ -45,7 +45,7 @@ public class Item implements IMaterial {
|
2021-03-13 02:27:48 +01:00
|
|
|
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;
|
2021-03-16 08:19:45 +01:00
|
|
|
@@ -208,6 +208,7 @@ public class Item implements IMaterial {
|
2021-03-13 02:27:48 +01:00
|
|
|
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
|
2021-03-16 08:19:45 +01:00
|
|
|
index ca911ed346daf8c43b7b6e0acabf9ac0c64223aa..712a32c0b64dace1f3e3d6f8acb8cbef1736b1f9 100644
|
2021-03-13 02:27:48 +01:00
|
|
|
--- 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 {
|
2021-03-16 08:19:45 +01:00
|
|
|
return net.minecraft.world.entity.Entity.nextEntityId();
|
2021-03-13 02:27:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ @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
|
|
|
|
|
|
|
|
/**
|