Skip to content

Fix loot tables being reset before death event#13886

Open
roro1506HD wants to merge 7 commits into
PaperMC:mainfrom
roro1506HD:fix/death_event_loot_table
Open

Fix loot tables being reset before death event#13886
roro1506HD wants to merge 7 commits into
PaperMC:mainfrom
roro1506HD:fix/death_event_loot_table

Conversation

@roro1506HD
Copy link
Copy Markdown
Contributor

@roro1506HD roro1506HD commented May 15, 2026

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>
Copy link
Copy Markdown
Member

@Doc94 Doc94 left a comment

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

3 participants