Don't you have to register it? I want to assign the loot table to a chest in my structure generation code, it's not for a block or entity.
I want to do something like this:
protected void handleDataMarker(String function, BlockPos pos, IWorld worldIn, Random rand, MutableBoundingBox sbb) {
if ("chest".equals(function)) {
worldIn.setBlockState(pos, Blocks.CHEST.getDefaultState().with(ChestBlock.WATERLOGGED, Boolean.valueOf(worldIn.getFluidState(pos).isTagged(FluidTags.WATER))), 2);
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof ChestTileEntity) {
((ChestTileEntity)tileentity).setLootTable(this.isLarge ? LootTables.CHESTS_UNDERWATER_RUIN_BIG : LootTables.CHESTS_UNDERWATER_RUIN_SMALL, rand.nextLong());
}
}
}
That code is taken from the Ocean Ruin Structure, as you can see they load a loot table, register it and then access it from the Ocean Ruin Structure.