aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0680-Expand-PlayerItemDamageEvent.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0680-Expand-PlayerItemDamageEvent.patch')
-rw-r--r--patches/server/0680-Expand-PlayerItemDamageEvent.patch23
1 files changed, 23 insertions, 0 deletions
diff --git a/patches/server/0680-Expand-PlayerItemDamageEvent.patch b/patches/server/0680-Expand-PlayerItemDamageEvent.patch
new file mode 100644
index 0000000000..85a05db466
--- /dev/null
+++ b/patches/server/0680-Expand-PlayerItemDamageEvent.patch
@@ -0,0 +1,23 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: HexedHero <[email protected]>
+Date: Sun, 10 Apr 2022 06:26:32 +0100
+Subject: [PATCH] Expand PlayerItemDamageEvent
+
+
+diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
+index 18f84d54ec72debec652adb22067e11aa058b238..679112d1622744680b7d3c7d296acafac019d00a 100644
+--- a/src/main/java/net/minecraft/world/item/ItemStack.java
++++ b/src/main/java/net/minecraft/world/item/ItemStack.java
+@@ -698,10 +698,11 @@ public final class ItemStack implements DataComponentHolder {
+ }
+
+ public void hurtAndBreak(int amount, ServerLevel world, @Nullable LivingEntity player, Consumer<Item> breakCallback) { // Paper - Add EntityDamageItemEvent
++ int originalDamage = amount; // Paper - Expand PlayerItemDamageEvent
+ int j = this.processDurabilityChange(amount, world, player);
+ // CraftBukkit start
+ if (player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent
+- PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j); // Paper - Add EntityDamageItemEvent
++ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j, originalDamage); // Paper - Add EntityDamageItemEvent
+ event.getPlayer().getServer().getPluginManager().callEvent(event);
+
+ if (j != event.getDamage() || event.isCancelled()) {