-
Bug
-
Resolution: Unresolved
-
None
-
Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 18w20c, Minecraft 18w21a, Minecraft 18w21b, Minecraft 1.13-pre1, Minecraft 1.13-pre2, Minecraft 1.13-pre3, Minecraft 1.13-pre4, Minecraft 1.13-pre5, Minecraft 1.13-pre8, Minecraft 1.13, Minecraft 1.14.2, 1.15.2, 1.17.1, 1.20.2
-
None
-
Confirmed
-
Data Packs
Reproduction
Given the following advancement (world/data/advancements/skylinerw/context.json):
{ "criteria": { "custom_test_name": { "trigger": "minecraft:impossible" } }, "rewards": { "loot": ["skylinerw:context_loot"] } }
And the following loot table (world/data/loot_tables/skylinerw/context_loot.json), where you receive 1 stone for having a Luck value of 1+, 2 dirt if you have Looting 1 (or 1 dirt if you do not), and 1 sand at all times:
{ "pools": [ { "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:stone", "weight": 0, "quality": 1 } ] }, { "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:dirt", "functions": [ { "function": "looting_enchant", "count": 1 } ] } ] }, { "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:sand" } ] } ] }
Holding a Looting sword that also increases luck, and then rewarding yourself with the advancement, will not grant you the expected items:
/give @s minecraft:diamond_sword 1 0 {ench:[{id:21s,lvl:1s}],AttributeModifiers:[{AttributeName:"generic.luck",Name:"+luck",Amount:1.0,Operation:0,Slot:"mainhand",UUIDLeast:1l,UUIDMost:1l}]} /advancement grant @s only skylinerw:context
*Expected items:* 1 stone, 2 dirt, 1 sand.
*Actual result:* 1 dirt, 1 sand.
Versus killing a mob using that loot table with the sword, which will provide you with the expected items:
/summon minecraft:creeper ~ ~1 ~ {DeathLootTable:"skylinerw:context_loot",Health:0.01f}
Analysis
Using MCP for 1.12: in method net.minecraft.advancements.AdvancementRewards.func_192113_a(), the LootContext builder receives only the player themselves through the withLootedEntity() method (normally this would be the entity that was killed). The methods withDamageSource() (for the "looting_enchant" function) and withLuck() methods would need to be appended for the above table to work as expected. It could also append withPlayer(), though this would be irrelevant since all the loot table features covered by this is already accessible thanks to withLootedEntity(), and everything else (such as the "killer_by_player" condition) is redundant.