2024-06-14 03:30:23 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: HexedHero <6012891+HexedHero@users.noreply.github.com>
|
|
|
|
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
|
2024-09-15 21:39:53 +02:00
|
|
|
index 1cfd41f36724f0c54489ad7c1c41486e45467a23..889263767ce3a2a4c43a2c61aa9d2d715392607c 100644
|
2024-06-14 03:30:23 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
|
|
@@ -650,10 +650,11 @@ public final class ItemStack implements DataComponentHolder {
|
|
|
|
if (this.isDamageableItem()) {
|
|
|
|
if (player == null || !player.hasInfiniteMaterials()) {
|
|
|
|
if (amount > 0) {
|
|
|
|
+ int originalDamage = amount; // Paper - Expand PlayerItemDamageEvent
|
|
|
|
amount = EnchantmentHelper.processDurabilityChange(world, this, amount);
|
|
|
|
// CraftBukkit start
|
|
|
|
if (player instanceof ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent
|
|
|
|
- PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount); // Paper - Add EntityDamageItemEvent
|
|
|
|
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount, originalDamage); // Paper - Add EntityDamageItemEvent & Expand PlayerItemDamageEvent
|
|
|
|
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (amount != event.getDamage() || event.isCancelled()) {
|