Hi all, I am following the structures tutorial here, to assist with my first structure. I've replaced stuffs that are outdated/deprecated. But there is one last thing that I have not replaced and that is the WeightedRandomChestContent. From what I've read in the replies of the thread, the replacement is LootTable#fillInventory, but what do I fill in the parameters? The specific lines of code is here and here.
Use TileEntityLockableLoot#setLootTable to set the loot table and random seed of a chest (or any other TileEntityLockableLoot implementation). When the inventory is first interacted with (via automation or a player opening it), it will be filled with random loot from the loot table.
Vanilla stores its loot tables in LootTableList. You can also use LootTableList.register to register your own loot tables.
The wiki has an explanation of the loot table format here. Forge adds the requirement for mod loot tables that each pool in a table has a unique "name" property and each entry in a pool has a unique name (either the name of the item/loot table it uses or the "entryName" property).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Hm, well, I would like my own items inside the chest that will be generated along with the structure, which option should I go for?
Create your own loot table. I've edited my previous post with an explanation of this.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
How do I add exact value of durability to a tool in the loot table json?
Use the set_damage function with the same value for the minimum and maximum.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Create a class to store your loot table ResourceLocations and register them in the static initialiser of that class or its fields (like I do here).
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
No, registering them when they're first needed (i.e. in a static initialiser) works.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ah, now I need help with this lines of code. What do I need to do?
You need to convert that array to a loot table, register it and store the ResourceLocation. When you generate a chest in your structure, call TileEntityLockableLoot#setLootTable with the ResourceLocation of your loot table.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
You need to convert that array to a loot table, register it and store the ResourceLocation. When you generate a chest in your structure, call TileEntityLockableLoot#setLootTable with the ResourceLocation of your loot table.
Oh, what do I fill in the Long parameter? Could I call World#rand?
Oh, what do I fill in the Long parameter? Could I call World#rand?
Call Random#nextLong on the Random argument of your WorldGenerator#generate override.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Is there any difference between calling Random#nextLong and World#rand#nextLong?
It's the same method, but they'll produce different pseudorandom numbers because the two Random objects have been initialised with different seeds.
World#rand is initialised with a unique seed based on the number of Random objects created and the system time, whereas the Random argument passed to IWorldGenerator#generate is initialised with a random seed based on the world's seed and the chunk x/z coordinates. The latter is the same algorithm vanilla uses for its structure generation.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ah gotacha, is it possible for my structure to spawn near the player like the bonus chest?
It should be. Look at how WorldServer#createBonusChest and WorldGeneratorBonusChest#generate decide where to generate the bonus chest.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Hi all, I am following the structures tutorial here, to assist with my first structure. I've replaced stuffs that are outdated/deprecated. But there is one last thing that I have not replaced and that is the WeightedRandomChestContent. From what I've read in the replies of the thread, the replacement is LootTable#fillInventory, but what do I fill in the parameters? The specific lines of code is here and here.
Use TileEntityLockableLoot#setLootTable to set the loot table and random seed of a chest (or any other TileEntityLockableLoot implementation). When the inventory is first interacted with (via automation or a player opening it), it will be filled with random loot from the loot table.
Vanilla stores its loot tables in LootTableList. You can also use LootTableList.register to register your own loot tables.
The wiki has an explanation of the loot table format here. Forge adds the requirement for mod loot tables that each pool in a table has a unique "name" property and each entry in a pool has a unique name (either the name of the item/loot table it uses or the "entryName" property).
You can see an example mod loot table here.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Hm, well, I would like my own items inside the chest that will be generated along with the structure, which option should I go for?
Create your own loot table. I've edited my previous post with an explanation of this.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
How do I add exact value of durability to a tool in the loot table json?
Use the set_damage function with the same value for the minimum and maximum.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Yea, but for example I want a wooden tool with durability of 17/59 to be added to the loot table, how do I it?
Like this.
The values used by the set_damage function are the remaining durability as a percentage of the maximum damage. 0.28 is 17/59.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Where do I register my loot table?
Create a class to store your loot table ResourceLocations and register them in the static initialiser of that class or its fields (like I do here).
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
That's it? No need to put in init or preInit?
No, registering them when they're first needed (i.e. in a static initialiser) works.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ah, now I need help with this lines of code. What do I need to do?
You need to convert that array to a loot table, register it and store the ResourceLocation. When you generate a chest in your structure, call TileEntityLockableLoot#setLootTable with the ResourceLocation of your loot table.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Oh, what do I fill in the Long parameter? Could I call World#rand?
Call Random#nextLong on the Random argument of your WorldGenerator#generate override.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Is there any difference between calling Random#nextLong and World#rand#nextLong?
It's the same method, but they'll produce different pseudorandom numbers because the two Random objects have been initialised with different seeds.
World#rand is initialised with a unique seed based on the number of Random objects created and the system time, whereas the Random argument passed to IWorldGenerator#generate is initialised with a random seed based on the world's seed and the chunk x/z coordinates. The latter is the same algorithm vanilla uses for its structure generation.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ah gotacha, is it possible for my structure to spawn near the player like the bonus chest?
It should be. Look at how WorldServer#createBonusChest and WorldGeneratorBonusChest#generate decide where to generate the bonus chest.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.