Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
fix
Dieser Commit ist enthalten in:
Ursprung
92131adaf2
Commit
0ec01a007a
@ -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..8c9ae9ac38def29ae4cd8944395e566e434d46d0 100644
|
||||
index f00b756fe5dad616323e3b11e35e27353f347042..88700393292c0a036c168428cd32e2f3ba07feb9 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -692,11 +692,11 @@ public final class ItemStack implements DataComponentHolder {
|
||||
@@ -692,11 +692,15 @@ public final class ItemStack implements DataComponentHolder {
|
||||
return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1;
|
||||
}
|
||||
|
||||
@ -18,12 +18,16 @@ index f00b756fe5dad616323e3b11e35e27353f347042..8c9ae9ac38def29ae4cd8944395e566e
|
||||
// CraftBukkit start
|
||||
- if (player != null) {
|
||||
- PlayerItemDamageEvent event = new PlayerItemDamageEvent(player.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j);
|
||||
+ if (player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent
|
||||
+ // Paper start - Add EntityDamageItemEvent
|
||||
+ if (j <= 0) {
|
||||
+ return;
|
||||
+ } else if (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,6 +707,14 @@ public final class ItemStack implements DataComponentHolder {
|
||||
@@ -707,30 +711,38 @@ public final class ItemStack implements DataComponentHolder {
|
||||
}
|
||||
|
||||
j = event.getDamage();
|
||||
@ -38,7 +42,10 @@ index f00b756fe5dad616323e3b11e35e27353f347042..8c9ae9ac38def29ae4cd8944395e566e
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -716,21 +724,21 @@ public final class ItemStack implements DataComponentHolder {
|
||||
- if (j != 0) {
|
||||
+ if (j > 0) { // Paper - Add EntityDamageItemEvent
|
||||
this.applyDamage(this.getDamageValue() + j, player, breakCallback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -67,7 +74,7 @@ index f00b756fe5dad616323e3b11e35e27353f347042..8c9ae9ac38def29ae4cd8944395e566e
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -768,7 +776,7 @@ public final class ItemStack implements DataComponentHolder {
|
||||
@@ -768,7 +780,7 @@ public final class ItemStack implements DataComponentHolder {
|
||||
entityplayer = null;
|
||||
}
|
||||
|
||||
|
@ -5,17 +5,21 @@ 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 a100c7a53b4b1dac0a01ee65418d44297bcdb93f..bcb3a45166e5dd75dd727adf92304b3a75399c8d 100644
|
||||
index 9cca3bbff57885380bda2dbe19b8fefe4ae2c1ac..2b0e8a159cf0765c6c93928384cd2ca2eb211e2a 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -693,10 +693,11 @@ public final class ItemStack implements DataComponentHolder {
|
||||
@@ -693,6 +693,7 @@ 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
|
||||
// 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
|
||||
- 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);
|
||||
|
@ -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 bcb3a45166e5dd75dd727adf92304b3a75399c8d..90a55f00c36903d52630c51bf69322973a2b5274 100644
|
||||
index 2b0e8a159cf0765c6c93928384cd2ca2eb211e2a..6f2f3148823615f234f93b3b08722743dcfc7506 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 {
|
||||
@ -27,9 +27,9 @@ index bcb3a45166e5dd75dd727adf92304b3a75399c8d..90a55f00c36903d52630c51bf6932297
|
||||
- int j = this.processDurabilityChange(amount, world, player);
|
||||
+ int j = this.processDurabilityChange(amount, world, player, force); // Paper
|
||||
// CraftBukkit start
|
||||
if (player instanceof final ServerPlayer serverPlayer) { // Paper - Add EntityDamageItemEvent
|
||||
PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), j, originalDamage); // Paper - Add EntityDamageItemEvent
|
||||
@@ -726,7 +731,12 @@ public final class ItemStack implements DataComponentHolder {
|
||||
// Paper start - Add EntityDamageItemEvent
|
||||
if (j <= 0) {
|
||||
@@ -730,7 +735,12 @@ public final class ItemStack implements DataComponentHolder {
|
||||
}
|
||||
|
||||
private int processDurabilityChange(int baseDamage, ServerLevel world, @Nullable LivingEntity player) { // Paper - Add EntityDamageItemEvent
|
||||
@ -43,7 +43,7 @@ index bcb3a45166e5dd75dd727adf92304b3a75399c8d..90a55f00c36903d52630c51bf6932297
|
||||
}
|
||||
|
||||
private void applyDamage(int damage, @Nullable LivingEntity player, Consumer<Item> breakCallback) { // Paper - Add EntityDamageItemEvent
|
||||
@@ -766,6 +776,11 @@ public final class ItemStack implements DataComponentHolder {
|
||||
@@ -770,6 +780,11 @@ public final class ItemStack implements DataComponentHolder {
|
||||
}
|
||||
|
||||
public void hurtAndBreak(int amount, LivingEntity entity, EquipmentSlot slot) {
|
||||
@ -55,7 +55,7 @@ index bcb3a45166e5dd75dd727adf92304b3a75399c8d..90a55f00c36903d52630c51bf6932297
|
||||
Level world = entity.level();
|
||||
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
@@ -778,8 +793,8 @@ public final class ItemStack implements DataComponentHolder {
|
||||
@@ -782,8 +797,8 @@ public final class ItemStack implements DataComponentHolder {
|
||||
}
|
||||
|
||||
this.hurtAndBreak(amount, worldserver, entity, (item) -> { // Paper - Add EntityDamageItemEvent
|
||||
|
@ -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 98b5208baeaa12a5ff2788e457c542000d6ea48b..babd89f39c43b0c64709d99bf8aca6cdc6ca1b24 100644
|
||||
index b5f9e0ef87d07515ca277e48ec523b1d4e9fa0a6..217280ec6e6f27dcb31978ee6a19f9ff7983bdd1 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -1361,6 +1361,11 @@ public final class ItemStack implements DataComponentHolder {
|
||||
@@ -1365,6 +1365,11 @@ public final class ItemStack implements DataComponentHolder {
|
||||
public void setItem(Item item) {
|
||||
this.bukkitStack = null; // Paper
|
||||
this.item = item;
|
||||
|
@ -62,10 +62,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 947e2a3620d73569552c5185664b7564e908007e..33e7d2884195677c4d6340d8b84c1dd85c636ec1 100644
|
||||
index b72519fc7744c4565d30face4a650fbe1f758110..445db1f17225d7606410623c1dbaba74295091a2 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -881,10 +881,16 @@ public final class ItemStack implements DataComponentHolder {
|
||||
@@ -885,10 +885,16 @@ public final class ItemStack implements DataComponentHolder {
|
||||
}
|
||||
|
||||
public ItemStack copy() {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren