diff --git a/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch b/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch index 058997e7ee..da106bbd37 100644 --- a/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch +++ b/paper-server/nms-patches/net/minecraft/world/item/ItemStack.patch @@ -302,18 +302,18 @@ if (i <= 0) { return; } -@@ -480,6 +694,11 @@ - } +@@ -458,6 +672,11 @@ + this.setDamageValue(j); + if (j >= this.getMaxDamage()) { + Item item = this.getItem(); ++ // CraftBukkit start - Check for item breaking ++ if (this.count == 1) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent(entityplayer, this); ++ } ++ // CraftBukkit end - this.hurtAndBreak(i, worldserver, entityplayer, (item) -> { -+ // CraftBukkit start - Check for item breaking -+ if (this.count == 1 && entityliving instanceof EntityHuman) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((EntityHuman) entityliving, this); -+ } -+ // CraftBukkit end - entityliving.onEquippedItemBroken(item, enumitemslot); - }); - } + this.shrink(1); + consumer.accept(item); @@ -693,6 +912,12 @@ return this.getItem().useOnRelease(this); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index fb7d1e8f3e..85c949273d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1365,9 +1365,9 @@ public class CraftEventFactory { return event; } - public static void callPlayerItemBreakEvent(EntityHuman human, ItemStack brokenItem) { + public static void callPlayerItemBreakEvent(EntityPlayer human, ItemStack brokenItem) { CraftItemStack item = CraftItemStack.asCraftMirror(brokenItem); - PlayerItemBreakEvent event = new PlayerItemBreakEvent((Player) human.getBukkitEntity(), item); + PlayerItemBreakEvent event = new PlayerItemBreakEvent(human.getBukkitEntity(), item); Bukkit.getPluginManager().callEvent(event); }