Minecraft – How would one put a loot table (of any kind) into a chest

minecraft-commandsminecraft-java-edition

The Wiki states that a block's data, in terms of loot tables, there should be a LootTable tag associated with it. After figuring out and running data get block on a chest, I've found… nothing of the sort. I even tried to do it on a sunken shipwreck and found nothing. I also found the same section of the Wiki says;

The loot tables of mobs and containers can be altered with /entitydata, /blockdata, /execute store and /data merge.

Seeing as the two former (entitydata and blockdata) were removed come 17w45b (a 1.13 snapshot), I'm going to assume that this would prove to be outdated. This is also helped by running data get on a Zombie and trying to find its loot table (which the Wiki says could be found in DeathLootTable tag of a mob), and getting nothing of the sort.

Without going into the files of the game to find each loot table or some other tedious workaround, is there any way that I can simply get the loot table in-game then set it using data modify or data merge?

Best Answer

For entities, you can use:

/data modify entity @e[type=sheep,limit=1,sort=nearest] DeathLootTable set value "minecraft:entities/spider"

and the same goes for blocks:

/data modify block <x> <y> <z> LootTable set value "minecraft:chests/village/village_toolsmith"

there is a list of all loot tables on the Minecraft wiki: https://minecraft.gamepedia.com/Loot_table#List_of_loot_tables. Just expand the "File structure" section.