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 3d62a1a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 28 deletions.
18 changes: 7 additions & 11 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..4df27601c4502b90a9a9e4ccc340dfcb37a6a79c 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,11 @@ public final class ItemStack implements DataComponentHolder {
return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1;
}

Expand All @@ -18,21 +18,17 @@ index f00b756fe5dad616323e3b11e35e27353f347042..55fb8f14f85efd589cc43c772dcb9266
// CraftBukkit start
- 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) {
+ // Paper end - Add EntityDamageItemEvent
+ if (j > 0 && player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent - limit to positive damage and run for player
+ 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 +707,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 +39,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 +70,7 @@ index f00b756fe5dad616323e3b11e35e27353f347042..55fb8f14f85efd589cc43c772dcb9266
}
// CraftBukkit end

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

Expand Down
10 changes: 3 additions & 7 deletions patches/server/0685-Expand-PlayerItemDamageEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ 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 7ebe03c592789c6a74eb3c12045e40c3d6d5f50c..b591ded5f7c7726c6bd3923f3b8243b08b3569c4 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,10 +693,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
// Paper start - Add EntityDamageItemEvent
@@ -700,7 +701,7 @@ public final class ItemStack implements DataComponentHolder {
return;
} else if (player instanceof final ServerPlayer serverPlayer) {
// Paper end - Add EntityDamageItemEvent
if (j > 0 && player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent - limit to positive damage and run for player
- 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);
Expand Down
12 changes: 6 additions & 6 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 b591ded5f7c7726c6bd3923f3b8243b08b3569c4..06ce27ddf7bfabd8f803fe9c1a82f7dba9818178 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 @@ -27,9 +27,9 @@ index 13a7c23a7bee6be0ac14ba69b80dc54e5c18de93..a1c8e3ec97394880d9abe789d0025d0c
- int j = this.processDurabilityChange(amount, world, player);
+ 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) { // Paper - Add EntityDamageItemEvent - limit to positive damage and run for player
PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j, originalDamage); // Paper - Add EntityDamageItemEvent
@@ -726,7 +731,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 {
@@ -766,6 +776,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 {
@@ -778,8 +793,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 <julius.gruenberg@leghast.de>

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 49ab79b6a22362d5fa226ea502ef2a6d3bb40e21..5a3a88091dd8775e4ef0417ab2e2d376931c870a 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 {
@@ -1361,6 +1361,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 d7c88b4edbf9158a2e7a520e80526fe967e93aff..3ae07439de25ee30ae32d214bb630180e3451e57 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 {
@@ -881,10 +881,16 @@ public final class ItemStack implements DataComponentHolder {
}

public ItemStack copy() {
Expand Down

0 comments on commit 3d62a1a

Please sign in to comment.