StructPro Mod (Fast Schematic Spawning System)

StructPro Mod (Fast Schematic Spawning System)

92.9k Downloads

[MOD = 4.2][MC = 1.12.2][Request] Use built-in loot tables for chest contents

jalfje opened this issue ยท 1 comments

commented

Right now, generated chests can contain absolutely any valid item, except those explicitly blacklisted in the configurator. This means that if ONLY_VANILLA_LOOT=false then absolutely any item from any mod can be put in chests, which, while fun, is a little ridiculous. It would make more sense (and be more consistent with vanilla, and with other mods) if the generated chests would only generate items that could otherwise be generated in other structures (mineshafts, dungeons, strongholds, villages, etc). This could also be a config option.

I've looked at the code, and it seems that the problem could be fixed in either UItems.java or Tiles.java. I think it would be best to change Tiles.load(TileEntityChest, ...) to generate items using the normal loot method.

In either case, it would require a check of minecraft's loot tables - these are found in net.minecraft.world.storage.loot.LootTableList, and you can access the entire list of their resource locations with LootTableList.getAll(). These include chest, entity, and fishing loot tables, so you'd probably want to remove all that don't contain .*chests.* in their resource location. Then you can pick a loot table from that list, and get its actual loot table with LootTableManager.getLootTableFromLocation(ResourceLocation). You can then generate loot with LootTable.generateLootForPool(Random, LootContext) or with LootTable.fillInventory(IInventory, Random, LootContext), which should be enough to suit your needs.

I think that doing this (with a config option, perhaps) would make the generated structures feel a little less imbalanced, because after testing your mod for a pretty brief period, I had already encountered a number of extremely late-game items, sometimes in large quantities.

See also

commented

This would be extremely useful not only to prevent finding bedrock, dragon eggs and nether stars (things I've actually found in generated chests), but this would also allow people to use craft tweaker and define their own loot. I want to use this mod in a zombie survival server, and having chests generate things like bullets and food would be very useful.