mojira.dev
MC-249889

Foxes drop equipment before loot (prevents loot tables checking for equipment in predicate)

This line of a fox's loot table:

"conditions": [
                {
                  "condition": "entity_properties",
                  "predicate": {
                    "nbt": "{HandItems:[{id:\"minecraft:wheat\"},{}],Type:\"red\",Sleeping:0b}"
                  },
                  "entity": "this"
                }

 

should check for a fox, holding wheat that is red and isn't sleeping. With the /loot command it works as if the mob is alive and holding the wheat. But when it is killed, it produces a different loot as the hand items are dropped before the loot table is processed. With other mobs, the hand items are consistent and can be read through the loot table to process the correct loot as the hand items are processed after the loot table instead of before.

 

Comments 1

Confirmed. And here's a shaky code analysis:

dropAllDeathLoot calls, in order, dropFromLootTable and dropCustomDeathLoot. The latter drops and removes equipment. Therefore, when dropFromLootTable runs, the equipment is present and can be detected.

For some reason, foxes override dropAllDeathLoot to manually drop the hand item first, and then call the super method. Therefore, when dropFromLootTable runs, the equipment is already gone and cannot be detected. It's unclear to me why this override is present, since presumably dropCustomDeathLoot would handle the fox's held item just fine like it does for other mobs. I'm not able to test what the effects of removing the override would be, though.

n1njag0

(Unassigned)

Confirmed

Platform

Low

Loot tables

1.18.2, 22w13a, 22w16b, 1.19.2, 1.19.3, 1.19.4 Pre-release 4

Retrieved