Board Thread:General Mod Discussion/@comment-27392198-20190524095325/@comment-25612015-20190525065156


 * For example, reading lotr/common/world/structure2/LOTRWorldGenHobbitHole.java I see the code:

''        if (this.isWealthy && random.nextBoolean) { this.placeChest(world, random, 0, 0, 6, 2, LOTRChestContents.HOBBIT_HOLE_TREASURE); }''


 * Looking at the headers, I see:

import lotr.common.world.structure.LOTRChestContents;


 * So I check lotr/common/world/structure/LOTRChest.java and find:

    public static LOTRChestContents HOBBIT_HOLE_TREASURE = new LOTRChestContents(3, 6, new WeightedRandomChestContent[]{new WeightedRandomChestContent(new ItemStack(Items.field_151043_k), 1, 4, 100), new WeightedRandomChestContent(new ItemStack(Items.field_151074_bl), 1, 8, 100), new WeightedRandomChestContent(new ItemStack(LOTRMod.silver), 1, 4, 100), new WeightedRandomChestContent(new ItemStack(LOTRMod.silverNugget), 1, 8, 100), new WeightedRandomChestContent(new ItemStack(LOTRMod.silverCoin, 1, 0), 1, 25, 50), new WeightedRandomChestContent(new ItemStack(LOTRMod.silverCoin, 1, 1), 1, 10, 20), new WeightedRandomChestContent(new ItemStack(LOTRMod.silverCoin, 1, 2), 1, 2, 20), new WeightedRandomChestContent(new ItemStack(LOTRMod.mithrilNugget), 1, 3, 25)});


 * Going on with the code reading, I see that:

LOTRChestContents(3, 6, ...

means the chest will contain 3 to 6 items


 * WeightedRandomChestContent is a Minecraft method defined in:

import net.minecraft.util.WeightedRandomChestContent;

Searching in Google Books I learn that:

''The first parameter in the WeightedRandomChestContent is an ItemStack containing the item or block that should be generated. The second parameter is the minimum stack size in which it will generate. The third parameter is the maximum stack size. The final parameter is the chance of it being chosen''

So you could get:


 * on each of the 3 to 6 runs


 * 1 to 3 Mithril nuggets


 * with a weighted chance of 25 out of 515 (100+100+100+100+50+20+20+25)

(I'm not sure of my interpretation on this last one...)