From Command line this works just fine:
setblock ~ ~ ~ chest{Lock:"Player's Key",LootTable:"hard:chests/chest_1"}
but when running it in a datapack as a tick function like so:
execute as @e[type=armor_stand,name=chest,tag=spawnchest,limit=1] at @s run setblock ~ ~ ~ chest{Lock:"Player's Key",LootTable:"hard:chests/chest_1"}
the commands run everything right except the Loottable. it spawns chest and when I open it with the key there is no loot_table applied. don't understand : bug I don't know
Linked issues
Attachments
Comments 6
No, bc every time I try I always destroy any chest the spawn before trying it again. even in running in the command line you can do many chest with the nbt tags with LOCK and Loot_table. but I can't get even one to spawn with the loot table in tacked using datapacks. the Lock tag work in datapacks but the Loottable does not and the Path is the same in both so I know the path works...
Can you attach the data pack? Both commands work fine for me with vanilla loot tables. Chances are that you made a mistake in your function.
I found the cause of this bug! It's actually caused by MC-117574 (containers being cleared when the command fails, so also if there's a chest already at that location).
In the meantime you can drop an extra if block ~ ~ ~ air
into your execute
command, and it'll work.
Does MC-117574 describe your issue?