Skip to content

Added function to empty an entity's loot table. #12666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Another-Joy
Copy link

Fix #11849

By replacing the entity's loot table with an empty one, we ensure that the entity will not drop any items when killed, fixing the issue related to "clearLootTable" not working as expected.

Signed-off-by: Tiago Ferreira tiago.a.p.ferreira@tecnico.ulisboa.pt

Another-Joy and others added 2 commits June 13, 2025 14:52
Fix PaperMC#11849

By replacing the entity's loot table with an empty one, we ensure that the entity will not drop any items when killed, fixing the issue related to "clearLootTable" not working as expected.

Signed-off-by: Tiago Ferreira <tiago.a.p.ferreira@tecnico.ulisboa.pt>
@Another-Joy Another-Joy requested a review from a team as a code owner June 13, 2025 23:07
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Jun 13, 2025
@Doc94
Copy link
Contributor

Doc94 commented Jun 14, 2025

If is using a vanilla loot table then can a datapack override that for make that loot return a thing?
I think its better just expose an LootTable.EMPTY custom

@Another-Joy
Copy link
Author

Yes, it is possible to make that loot return something, if a plugin changes what the Player loot table drops (this one is empty by default, that's why I used it). This initially sounds like a huge problem, however, it's rare to change the player's loot table.

Unfortunately, there is no LootTable.EMPTY (removed from vanilla a few updates ago), and making a custom one would involve a lot more work than it seems, since Paper does not have in-API support for creating custom loot tables. So that you know, this was information I gathered from a few other contributors on the Discord.

@Doc94
Copy link
Contributor

Doc94 commented Jun 14, 2025

not so rare.. a basic example are datapacks for get player heads that use the player loot table for allow that.

about the custom yeah exists things like.

        new LootTable() {
            @Override
            public @NotNull Collection<ItemStack> populateLoot(@Nullable Random random, @NotNull LootContext context) {
                return Collections.emptyList();
            }

            @Override
            public void fillInventory(@NotNull Inventory inventory, @Nullable Random random, @NotNull LootContext context) {

            }

            @Override
            public @NotNull NamespacedKey getKey() {
                return new NamespacedKey(PLUGIN_INSTANCE, "loot_empty");
            }
        };

but not sure if is a good way for this...

@Another-Joy
Copy link
Author

Uhm, I see. That interaction was already on my mind when I was writing the code. However, the biggest problem with this bug is that there seems to be no perfect solution.

Would the creation of a new empty LootTable be a better solution? Probably. But then again, from what I gathered with other contributors was to not mess with the LootTables themselves too much, since that is kind of outside Paper.

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.

Mob#clearLootTable has no effect
2 participants