Posted June 26, 20178 yr TileEntityChest chest = (TileEntityChest) world.getTileEntity(new BlockPos(i + 6, j + 11, k + 6)); chest.setLootTable(new ResourceLocation("nm:loot/loot_chest"), new Random().nextLong()); Hello, I have made a custom structure and have been trying to add loot tables to the chests inside my structure. I have this code. The resource path is correct I have checked that many times. The only error I get is: Couldn't find resource table nm:loot/loot_chest when I open the chest. I don't know why this is happening because the path is assets.nm.loot and in that package I have loot_chest.json with the loot table in it. Any help is appreciated, Thanks! Edited June 27, 20178 yr by funsize888
June 27, 20178 yr Author 2 hours ago, diesieben07 said: Post a Git repo of your mod. How do I do that
June 27, 20178 yr Try adding .json to your resource location. Not entirely sure if necessary but I know you need for instance .png in resource locations for entity textures IGN: matte006 Played Minecraft since summer 2011. Modding is my life now. Please check out my mod https://minecraft.curseforge.com/projects/gadgets-n-goodies-mod?gameCategorySlug=mc-mods&projectID=230028
June 27, 20178 yr Author 2 minutes ago, TheMattyBoy said: Try adding .json to your resource location. Not entirely sure if necessary but I know you need for instance .png in resource locations for entity textures I have tried that and the same thing happened
June 27, 20178 yr OK then. Why don't you register it like Minecraft has done it in LootTableList::register(ResourceLocation) (which is a public static method)? That does mean that you have to rename your "loot" folder to "loot_tables", and you probably want to create a sub folder called "chests" where you put your "loot_chest.json" file, but that shouldn't be too big of an issue. I would try doing something like public static ResourceLocation LOOT_CHEST; in your main mod class, then say LOOT_CHEST = LootTableList.register(new ResourceLocation("nm", "chests/loot_chest")); in your pre-initialization event (maybe another event) and then call this field in your chest.setLootTable method. IGN: matte006 Played Minecraft since summer 2011. Modding is my life now. Please check out my mod https://minecraft.curseforge.com/projects/gadgets-n-goodies-mod?gameCategorySlug=mc-mods&projectID=230028
June 27, 20178 yr Author 1 hour ago, TheMattyBoy said: OK then. Why don't you register it like Minecraft has done it in LootTableList::register(ResourceLocation) (which is a public static method)? That does mean that you have to rename your "loot" folder to "loot_tables", and you probably want to create a sub folder called "chests" where you put your "loot_chest.json" file, but that shouldn't be too big of an issue. I would try doing something like public static ResourceLocation LOOT_CHEST; in your main mod class, then say LOOT_CHEST = LootTableList.register(new ResourceLocation("nm", "chests/loot_chest")); in your pre-initialization event (maybe another event) and then call this field in your chest.setLootTable method. Ok, I have this in my main class: public static ResourceLocation LOOT_CHEST; and this also in my main class but under the preInit method: LOOT_CHEST = LootTableList.register(new ResourceLocation("nm", "chests/loot_chest")); And I have this in my structure class: TileEntityChest chest = (TileEntityChest) world.getTileEntity(new BlockPos(i + 6, j + 11, k + 6)); chest.setLootTable((MyMod.LOOT_CHEST), new Random().nextLong()); I have also changed the resource locations. I don't get any errors but nothing is inside the chests. Which happens everytime I register it.
June 27, 20178 yr Author Nevermind, I changed: ("nm", "chests/loot_chest")); to "nm:loot_tables/chests/loot_chest" and it worked!, Thank you so much for your help, would have never got it otherwise!
June 28, 20178 yr Author 16 hours ago, funsize888 said: Nevermind, I changed: ("nm", "chests/loot_chest")); to "nm:loot_tables/chests/loot_chest" and it worked!, Thank you so much for your help, would have never got it otherwise! Ok nevermind, items spawned in the chest once and now I'm getting the same error couldn't find resource table. I didn't change anything. I am still stuck
June 28, 20178 yr Author Now I'm getting the error: Loot Table "nm:chests/loot_chest" Missing `name` entry for pool #0. I did set a name though, here is my json file: { "pools": [ { "name": "loot", "rolls": { "min": 2, "max": 4 }, "entries": [ { "type": "item", "name": "minecraft:diamond", "functions": [ { "function": "set_count", "count": { "min": 1, "max": 3 } } ], "weight": 5 }, { "type": "item", "name": "minecraft:iron_ingot", "functions": [ { "function": "set_count", "count": { "min": 1, "max": 5 } } ], "weight": 15 }, { "type": "item", "name": "minecraft:gold_ingot", "functions": [ { "function": "set_count", "count": { "min": 2, "max": 7 } } ], "weight": 15 }, { "type": "item", "name": "minecraft:emerald", "functions": [ { "function": "set_count", "count": { "min": 1, "max": 3 } } ], "weight": 15 }, { "type": "item", "name": "minecraft:bone", "functions": [ { "function": "set_count", "count": { "min": 4, "max": 6 } } ], "weight": 25 }, { "type": "item", "name": "minecraft:spider_eye", "functions": [ { "function": "set_count", "count": { "min": 1, "max": 3 } } ], "weight": 25 }, { "type": "item", "name": "minecraft:rotten_flesh", "functions": [ { "function": "set_count", "count": { "min": 3, "max": 7 } } ], "weight": 25 }, { "type": "item", "name": "minecraft:saddle", "weight": 20 }, { "type": "item", "name": "minecraft:iron_horse_armor", "weight": 15 }, { "type": "item", "name": "minecraft:golden_horse_armor", "weight": 10 }, { "type": "item", "name": "minecraft:diamond_horse_armor", "weight": 5 }, { "type": "item", "name": "minecraft:book", "weight": 20, "functions": [ { "function": "enchant_randomly" } ] }, { "type": "item", "name": "minecraft:gunpowder", "weight": 20 }, { "type": "item", "name": "minecraft:golden_apple", "weight": 2, "functions": [ { "function": "set_data", "data": 1 } ] }, { "type": "empty", "weight": 15 } ] }, { "rolls": 4, "entries": [ { "type": "item", "name": "minecraft:bone", "weight": 10, "functions": [ { "function": "set_count", "count": { "min": 1, "max": 8 } } ] }, { "type": "item", "name": "minecraft:gunpowder", "weight": 10, "functions": [ { "function": "set_count", "count": { "min": 1, "max": 8 } } ] }, { "type": "item", "name": "minecraft:rotten_flesh", "weight": 10, "functions": [ { "function": "set_count", "count": { "min": 1, "max": 8 } } ] }, { "type": "item", "name": "minecraft:string", "weight": 10, "functions": [ { "function": "set_count", "count": { "min": 1, "max": 8 } } ] }, { "type": "item", "name": "minecraft:sand", "weight": 10, "functions": [ { "function": "set_count", "count": { "min": 1, "max": 8 } } ] } ] } ] }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.