Skip to content

Commit

Permalink
no negative damage
Browse files Browse the repository at this point in the history
  • Loading branch information
notTamion authored and lynxplay committed Dec 8, 2024
1 parent 947cf37 commit d621254
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
14 changes: 8 additions & 6 deletions patches/server/0680-Expand-PlayerItemDamageEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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..1623c127c83c6704989f8f06f4de8123cc0c24cf 100644
index 18f84d54ec72debec652adb22067e11aa058b238..9209f5509affbd3cbcf777b75b0868c898ee913f 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 {
Expand All @@ -21,16 +21,18 @@ index 18f84d54ec72debec652adb22067e11aa058b238..1623c127c83c6704989f8f06f4de8123
event.getPlayer().getServer().getPluginManager().callEvent(event);

if (j != event.getDamage() || event.isCancelled()) {
@@ -761,6 +762,14 @@ public final class ItemStack implements DataComponentHolder {
@@ -761,6 +762,16 @@ public final class ItemStack implements DataComponentHolder {
return;
}

+ // Paper start - Expand PlayerItemDamageEvent
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j, amount);
+ if (!event.callEvent() || event.getDamage() == 0) {
+ return;
+ if (j > 0) {
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(entityplayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j, amount);
+ if (!event.callEvent() || event.getDamage() == 0) {
+ return;
+ }
+ j = event.getDamage();
+ }
+ j = event.getDamage();
+ // Paper end - Expand PlayerItemDamageEvent
+
int k = Math.min(this.getDamageValue() + j, this.getMaxDamage() - 1);
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0756-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 1623c127c83c6704989f8f06f4de8123cc0c24cf..f0c0f2fe612874ceffcef442a537e32d5d8c395d 100644
index 9209f5509affbd3cbcf777b75b0868c898ee913f..5dc286093f0befdb0988427f6134f752e62d0dc5 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -698,8 +698,13 @@ public final class ItemStack implements DataComponentHolder {
Expand Down Expand Up @@ -43,7 +43,7 @@ index 1623c127c83c6704989f8f06f4de8123cc0c24cf..f0c0f2fe612874ceffcef442a537e32d
}

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

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

if (world instanceof ServerLevel worldserver) {
@@ -791,8 +806,8 @@ public final class ItemStack implements DataComponentHolder {
@@ -793,8 +808,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/0947-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 1377659d99694c928206b9665bc41d68ab5daf5a..5d39ddfbce3f8845f6798d241fd958f866fa8411 100644
index 6c1b81967fe32802c895e3f9f8e199588c36be7f..4c684b665180f8485131542b161483c77c40b4ec 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -1387,6 +1387,11 @@ public final class ItemStack implements DataComponentHolder {
@@ -1389,6 +1389,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/1044-Optimize-Hoppers.patch
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ index 682417e20459ffd576e494e1a279c477589103ba..ccbd76a7d1a3c29759aec86c5780cab6
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 222d4b71718a6f731981b411850668b986cdcd36..b1017ef7bdb922ed0f29218cc2986a1a439c1fad 100644
index 57a5c7c26c77cb961f7b7a11ff866f65d042934c..1f05ab1aabae0ce4fae49e790833b8b6038263bb 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -894,10 +894,16 @@ public final class ItemStack implements DataComponentHolder {
@@ -896,10 +896,16 @@ public final class ItemStack implements DataComponentHolder {
}

public ItemStack copy() {
Expand Down

0 comments on commit d621254

Please sign in to comment.