mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Avoid item meta usage for itemstack enchantment getter (#8373)
This commit is contained in:
parent
28f9b1a3cb
commit
2e51143433
1 changed files with 7 additions and 17 deletions
|
@ -116,21 +116,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
static boolean makeTag(net.minecraft.world.item.ItemStack item) {
|
static boolean makeTag(net.minecraft.world.item.ItemStack item) {
|
||||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
||||||
|
if (this.handle == null) {
|
||||||
@Override
|
return 0;
|
||||||
public boolean containsEnchantment(Enchantment ench) {
|
|
||||||
- return this.getEnchantmentLevel(ench) > 0;
|
|
||||||
+ return this.hasItemMeta() && this.getItemMeta().hasEnchant(ench); // Paper - use meta
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEnchantmentLevel(Enchantment ench) {
|
|
||||||
- Validate.notNull(ench, "Cannot find null enchantment");
|
|
||||||
- if (this.handle == null) {
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
- return EnchantmentHelper.getItemEnchantmentLevel(CraftEnchantment.getRaw(ench), handle);
|
- return EnchantmentHelper.getItemEnchantmentLevel(CraftEnchantment.getRaw(ench), handle);
|
||||||
+ return this.hasItemMeta() ? this.getItemMeta().getEnchantLevel(ench) : 0; // Paper - replace entire method with meta
|
+ return net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(CraftEnchantment.getRaw(ench), handle); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -173,10 +163,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- listCopy.add(list.get(i));
|
- listCopy.add(list.get(i));
|
||||||
- }
|
- }
|
||||||
+ // Paper start - replace entire method
|
+ // Paper start - replace entire method
|
||||||
|
+ int level = getEnchantmentLevel(ench);
|
||||||
|
+ if (level > 0) {
|
||||||
+ final ItemMeta itemMeta = this.getItemMeta();
|
+ final ItemMeta itemMeta = this.getItemMeta();
|
||||||
+ if (itemMeta == null) return 0;
|
+ if (itemMeta == null) return 0;
|
||||||
+ int level = itemMeta.getEnchantLevel(ench);
|
|
||||||
+ if (level > 0) {
|
|
||||||
+ itemMeta.removeEnchant(ench);
|
+ itemMeta.removeEnchant(ench);
|
||||||
+ this.setItemMeta(itemMeta);
|
+ this.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue