Skip to content

Fix loot tables being reset before death event#13886

Merged
Warriorrrr merged 8 commits into
PaperMC:mainfrom
roro1506HD:fix/death_event_loot_table
May 26, 2026
Merged

Fix loot tables being reset before death event#13886
Warriorrrr merged 8 commits into
PaperMC:mainfrom
roro1506HD:fix/death_event_loot_table

Conversation

@roro1506HD

@roro1506HD roro1506HD commented May 15, 2026

Copy link
Copy Markdown
Contributor

Using the following listener, the logged loot table currently matches the default loot table of the entity, not the actual loot table used:

    @EventHandler
    public void onEntityDeath(EntityDeathEvent event) {
        if (event.getEntity() instanceof Mob mob) {
            this.getSLF4JLogger().warn("Entity {} died with loot table: {}", mob.getName(), mob.getLootTable());
        }
    }

During my test, the Pig I modified did drop rotten flesh despite the console printing entities/pig loot table

[02:11:45 INFO]: roro1506_HD issued server command: /data merge entity 62185aec-e858-4945-a41a-6e21107085b7 {DeathLootTable:"minecraft:entities/zombie"}
[02:11:45 INFO]: [roro1506_HD: Modified entity data of Pig]
[02:11:47 WARN]: [Paper-Test-Plugin] Entity Pig died with loot table: minecraft:entities/pig

This PR fixes this issue

[16:12:32 INFO]: roro1506_HD issued server command: /data merge entity c3c71d92-632f-49d3-a682-fd062b85f884 {DeathLootTable:"minecraft:entities/zombie"}
[16:12:32 INFO]: [roro1506_HD: Modified entity data of Pig]
[16:12:34 WARN]: [Paper-Test-Plugin] Entity Pig died with loot table: minecraft:entities/zombie

Also addresses the issue where loot tables were being reset even when the EntityDeathEvent was being cancelled

@roro1506HD roro1506HD requested a review from a team as a code owner May 15, 2026 14:16
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue May 15, 2026
Comment thread paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch Outdated
Co-authored-by: Pedro <3602279+Doc94@users.noreply.github.com>

@Doc94 Doc94 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with /summon pig ~ ~ ~ {DeathLootTable:"minecraft:entities/zombie"} and the entity in event show the loot table to being use.
Also for the cancel state the entity keep the loottable.

Comment thread paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch Outdated
Comment thread paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch Outdated
@Warriorrrr Warriorrrr added type: bug Something doesn't work as it was intended to. scope: api labels May 26, 2026
@Warriorrrr Warriorrrr merged commit 34cf3ab into PaperMC:main May 26, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Awaiting review to Merged in Paper PR Queue May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: api type: bug Something doesn't work as it was intended to.

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

5 participants