Skip to content

Commit

Permalink
Align
Browse files Browse the repository at this point in the history
  • Loading branch information
lynxplay committed Nov 26, 2024
1 parent 5478356 commit 5c07b1b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
16 changes: 7 additions & 9 deletions patches/server/0569-Add-EntityDamageItemEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Add EntityDamageItemEvent


diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index f00b756fe5dad616323e3b11e35e27353f347042..55fb8f14f85efd589cc43c772dcb926646609691 100644
index f00b756fe5dad616323e3b11e35e27353f347042..296dc89ce2717e28e312722de9bb89594ae35de7 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -692,11 +692,15 @@ public final class ItemStack implements DataComponentHolder {
@@ -692,11 +692,13 @@ public final class ItemStack implements DataComponentHolder {
return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1;
}

Expand All @@ -19,20 +19,18 @@ index f00b756fe5dad616323e3b11e35e27353f347042..55fb8f14f85efd589cc43c772dcb9266
- if (player != null) {
- PlayerItemDamageEvent event = new PlayerItemDamageEvent(player.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j);
+ // Paper start - Add EntityDamageItemEvent
+ if (j == 0) {
+ return;
+ } else if (player instanceof final ServerPlayer serverPlayer) {
+ if (j > 0 && player instanceof final ServerPlayer serverPlayer) {
+ // Paper end - Add EntityDamageItemEvent
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j); // Paper - Add EntityDamageItemEvent
event.getPlayer().getServer().getPluginManager().callEvent(event);

if (j != event.getDamage() || event.isCancelled()) {
@@ -707,30 +711,38 @@ public final class ItemStack implements DataComponentHolder {
@@ -707,30 +709,38 @@ public final class ItemStack implements DataComponentHolder {
}

j = event.getDamage();
+ // Paper start - Add EntityDamageItemEvent
+ } else if (player != null) {
+ } else if (j > 0 && player != null) {
+ io.papermc.paper.event.entity.EntityDamageItemEvent event = new io.papermc.paper.event.entity.EntityDamageItemEvent(player.getBukkitLivingEntity(), CraftItemStack.asCraftMirror(this), amount);
+ if (!event.callEvent()) {
+ return;
Expand All @@ -43,7 +41,7 @@ index f00b756fe5dad616323e3b11e35e27353f347042..55fb8f14f85efd589cc43c772dcb9266
// CraftBukkit end

- if (j != 0) {
+ if (j != 0) { // Paper - Add EntityDamageItemEvent
+ if (j != 0) { // Paper - Add EntityDamageItemEvent - diff on change for above event ifs.
this.applyDamage(this.getDamageValue() + j, player, breakCallback);
}

Expand Down Expand Up @@ -74,7 +72,7 @@ index f00b756fe5dad616323e3b11e35e27353f347042..55fb8f14f85efd589cc43c772dcb9266
}
// CraftBukkit end

@@ -768,7 +780,7 @@ public final class ItemStack implements DataComponentHolder {
@@ -768,7 +778,7 @@ public final class ItemStack implements DataComponentHolder {
entityplayer = null;
}

Expand Down
8 changes: 3 additions & 5 deletions patches/server/0685-Expand-PlayerItemDamageEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ 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 9cca3bbff57885380bda2dbe19b8fefe4ae2c1ac..2b0e8a159cf0765c6c93928384cd2ca2eb211e2a 100644
index b7beac621e9178c3f97cd72719e5fb3be4505adb..d31e18e9ae85ee122d44081c4e5024a1fc5e9a58 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -693,6 +693,7 @@ public final class ItemStack implements DataComponentHolder {
@@ -693,12 +693,13 @@ 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
// Paper start - Add EntityDamageItemEvent
@@ -700,7 +701,7 @@ public final class ItemStack implements DataComponentHolder {
return;
} else if (player instanceof final ServerPlayer serverPlayer) {
if (j > 0 && player instanceof final ServerPlayer serverPlayer) {
// Paper end - 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
Expand Down
10 changes: 5 additions & 5 deletions patches/server/0761-ItemStack-damage-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the logic associated with damaging them
public net.minecraft.world.entity.LivingEntity entityEventForEquipmentBreak(Lnet/minecraft/world/entity/EquipmentSlot;)B

diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 13a7c23a7bee6be0ac14ba69b80dc54e5c18de93..a1c8e3ec97394880d9abe789d0025d0c6d21ad95 100644
index d31e18e9ae85ee122d44081c4e5024a1fc5e9a58..8aba08876eb349fe3efb2cd742417b92ea090386 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -693,8 +693,13 @@ public final class ItemStack implements DataComponentHolder {
Expand All @@ -28,8 +28,8 @@ index 13a7c23a7bee6be0ac14ba69b80dc54e5c18de93..a1c8e3ec97394880d9abe789d0025d0c
+ int j = this.processDurabilityChange(amount, world, player, force); // Paper
// CraftBukkit start
// Paper start - Add EntityDamageItemEvent
if (j == 0) {
@@ -730,7 +735,12 @@ public final class ItemStack implements DataComponentHolder {
if (j > 0 && player instanceof final ServerPlayer serverPlayer) {
@@ -728,7 +733,12 @@ public final class ItemStack implements DataComponentHolder {
}

private int processDurabilityChange(int baseDamage, ServerLevel world, @Nullable LivingEntity player) { // Paper - Add EntityDamageItemEvent
Expand All @@ -43,7 +43,7 @@ index 13a7c23a7bee6be0ac14ba69b80dc54e5c18de93..a1c8e3ec97394880d9abe789d0025d0c
}

private void applyDamage(int damage, @Nullable LivingEntity player, Consumer<Item> breakCallback) { // Paper - Add EntityDamageItemEvent
@@ -770,6 +780,11 @@ public final class ItemStack implements DataComponentHolder {
@@ -768,6 +778,11 @@ public final class ItemStack implements DataComponentHolder {
}

public void hurtAndBreak(int amount, LivingEntity entity, EquipmentSlot slot) {
Expand All @@ -55,7 +55,7 @@ index 13a7c23a7bee6be0ac14ba69b80dc54e5c18de93..a1c8e3ec97394880d9abe789d0025d0c
Level world = entity.level();

if (world instanceof ServerLevel worldserver) {
@@ -782,8 +797,8 @@ public final class ItemStack implements DataComponentHolder {
@@ -780,8 +795,8 @@ public final class ItemStack implements DataComponentHolder {
}

this.hurtAndBreak(amount, worldserver, entity, (item) -> { // Paper - Add EntityDamageItemEvent
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0952-General-ItemMeta-fixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public net/minecraft/world/level/block/entity/BlockEntity saveId(Lnet/minecraft/
Co-authored-by: GhastCraftHD <[email protected]>

diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index b5f9e0ef87d07515ca277e48ec523b1d4e9fa0a6..217280ec6e6f27dcb31978ee6a19f9ff7983bdd1 100644
index c6e35eac9cf7ff2744e5f796acd08c9b91fd283e..2fbad9beee64661d4cd4dc50d8f47e89b8b53696 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -1365,6 +1365,11 @@ public final class ItemStack implements DataComponentHolder {
@@ -1363,6 +1363,11 @@ public final class ItemStack implements DataComponentHolder {
public void setItem(Item item) {
this.bukkitStack = null; // Paper
this.item = item;
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0982-Optimize-Hoppers.patch
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ index b13b3991292ab96542ba390f3e8e3ff0d7529c44..ff6f2dc31bbbaa420323a68282cb1ee3
gameprofilerfiller.push(() -> {
String s = String.valueOf(worldserver);
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index b72519fc7744c4565d30face4a650fbe1f758110..445db1f17225d7606410623c1dbaba74295091a2 100644
index 34ce4d154b690be88750da0252c0cc531ac03357..d80d4936c01539542e0f05c7a45dc45d8a7bc421 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -885,10 +885,16 @@ public final class ItemStack implements DataComponentHolder {
@@ -883,10 +883,16 @@ public final class ItemStack implements DataComponentHolder {
}

public ItemStack copy() {
Expand Down

0 comments on commit 5c07b1b

Please sign in to comment.