From 39d3961920f1c0b21f42a7ee21f210a81efb7374 Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Fri, 15 May 2026 16:13:49 +0200 Subject: [PATCH 1/7] fix: loot tables being reset before death event --- .../sources/net/minecraft/world/entity/Mob.java.patch | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index fa3e3bce9f23..ad3476a88112 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -108,7 +108,7 @@ this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -401,6 +_,13 @@ +@@ -401,11 +_,22 @@ this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -122,6 +122,15 @@ } @Override + protected void dropFromLootTable(final ServerLevel level, final DamageSource source, final boolean playerKilled) { + super.dropFromLootTable(level, source, playerKilled); ++ // Paper start - delay loot table removal to after death event ++ } ++ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { ++ // Paper end - delay loot table removal to after death event + this.lootTable = Optional.empty(); + } + @@ -465,6 +_,11 @@ for (ItemEntity entity : this.level() .getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(pickupReach.getX(), pickupReach.getY(), pickupReach.getZ()))) { From a59417ab47f27b5454aa0166cad3cdb7999e6e70 Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Fri, 15 May 2026 16:59:42 +0200 Subject: [PATCH 2/7] fix: loot tables still being reset when death event is cancelled --- .../patches/sources/net/minecraft/world/entity/Mob.java.patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index ad3476a88112..92d5a88c8a54 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -108,7 +108,7 @@ this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -401,11 +_,22 @@ +@@ -401,11 +_,23 @@ this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -127,6 +127,7 @@ + // Paper start - delay loot table removal to after death event + } + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { ++ if (!event.isCancelled()) + // Paper end - delay loot table removal to after death event this.lootTable = Optional.empty(); } From 708f6833a47e1280c3a6904ea6ec2b45e8dd4bda Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Fri, 15 May 2026 17:33:14 +0200 Subject: [PATCH 3/7] chore: make patch a little more readable Co-authored-by: Pedro <3602279+Doc94@users.noreply.github.com> --- .../patches/sources/net/minecraft/world/entity/Mob.java.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index 92d5a88c8a54..aeb8ed434373 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -127,7 +127,7 @@ + // Paper start - delay loot table removal to after death event + } + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { -+ if (!event.isCancelled()) ++ if (event.isCancelled()) return; + // Paper end - delay loot table removal to after death event this.lootTable = Optional.empty(); } From 0cdcfc5623a86fabb89f3500beaecbda67ff5a87 Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Fri, 15 May 2026 20:34:26 +0200 Subject: [PATCH 4/7] chore: add missing override annotation --- .../patches/sources/net/minecraft/world/entity/Mob.java.patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index aeb8ed434373..7f6ce056b4e2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -108,7 +108,7 @@ this.dropChances = input.read("drop_chances", DropChances.CODEC).orElse(DropChances.DEFAULT); this.readLeashData(input); this.homeRadius = input.getIntOr("home_radius", -1); -@@ -401,11 +_,23 @@ +@@ -401,11 +_,24 @@ this.lootTable = input.read("DeathLootTable", LootTable.KEY_CODEC); this.lootTableSeed = input.getLongOr("DeathLootTableSeed", 0L); this.setNoAi(input.getBooleanOr("NoAI", false)); @@ -126,6 +126,7 @@ super.dropFromLootTable(level, source, playerKilled); + // Paper start - delay loot table removal to after death event + } ++ @Override + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { + if (event.isCancelled()) return; + // Paper end - delay loot table removal to after death event From d3f941b3a5ed27f45d2f018d90966eae95e1dd7f Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Fri, 15 May 2026 20:42:58 +0200 Subject: [PATCH 5/7] chore: add missing override annotation for chested horse --- .../world/entity/animal/equine/AbstractChestedHorse.java.patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch index 5e1eb25224f2..26233fff84b9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java +++ b/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java -@@ -75,6 +_,12 @@ +@@ -75,6 +_,13 @@ super.dropEquipment(level); if (this.hasChest()) { this.spawnAtLocation(level, Blocks.CHEST); + // Paper start - moved to post death logic + } + } ++ @Override + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { + if (this.hasChest() && !event.isCancelled()) { + // Paper end - moved to post death logic From 6172b68906f8073fd7ade0abd7e265d791dd1e00 Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Sat, 16 May 2026 02:52:44 +0200 Subject: [PATCH 6/7] fix: check event cancellation before the callback --- .../net/minecraft/world/entity/LivingEntity.java.patch | 4 ++-- .../patches/sources/net/minecraft/world/entity/Mob.java.patch | 4 ++-- .../entity/animal/equine/AbstractChestedHorse.java.patch | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index e6413834b5a7..a0b02fb2905d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -931,7 +931,7 @@ + killer.awardKillScore(this, source); + } + }); // Paper end -+ this.postDeathDropItems(deathEvent); // Paper ++ if (!deathEvent.isCancelled()) this.postDeathEventCallback(); // Paper - post death event logic + this.drops = new java.util.ArrayList<>(); + // this.dropEquipment(level); // CraftBukkit - moved up + // CraftBukkit end @@ -941,7 +941,7 @@ protected void dropEquipment(final ServerLevel level) { } -+ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {} // Paper - method for post death logic that cannot be ran before the event is potentially cancelled ++ protected void postDeathEventCallback() {} // Paper - method for post death logic that must be ran if the event isn't cancelled - protected void dropExperience(final ServerLevel level, final @Nullable Entity killer) { + public int getExpReward(final ServerLevel level, final @Nullable Entity killer) { // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index 7f6ce056b4e2..8f51f7150644 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -127,8 +127,8 @@ + // Paper start - delay loot table removal to after death event + } + @Override -+ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { -+ if (event.isCancelled()) return; ++ protected void postDeathEventCallback() { ++ if (!this.shouldDropLoot((ServerLevel) this.level())) return; // This callback can only be ran if the level is a ServerLevel + // Paper end - delay loot table removal to after death event this.lootTable = Optional.empty(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch index 26233fff84b9..601b0504297d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch @@ -8,8 +8,8 @@ + } + } + @Override -+ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { -+ if (this.hasChest() && !event.isCancelled()) { ++ protected void postDeathEventCallback() { ++ if (this.hasChest()) { + // Paper end - moved to post death logic this.setChest(false); } From 211f557fdb41e6694fd5cb712640b36c98a6b010 Mon Sep 17 00:00:00 2001 From: roro1506HD Date: Sat, 16 May 2026 20:22:00 +0200 Subject: [PATCH 7/7] fix: call super method for chested horse callback --- .../world/entity/animal/equine/AbstractChestedHorse.java.patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch index 601b0504297d..e72165075e84 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java +++ b/net/minecraft/world/entity/animal/equine/AbstractChestedHorse.java -@@ -75,6 +_,13 @@ +@@ -75,6 +_,14 @@ super.dropEquipment(level); if (this.hasChest()) { this.spawnAtLocation(level, Blocks.CHEST); @@ -9,6 +9,7 @@ + } + @Override + protected void postDeathEventCallback() { ++ super.postDeathEventCallback(); + if (this.hasChest()) { + // Paper end - moved to post death logic this.setChest(false);