Module:LootChest

local p = {

calc_average_amount_this_item_per_pool = function( 			min_stacksize, max_stacksize,			min_pool_rolls, max_pool_rolls, 			item_weight, pool_total_item_weight )

local avg_stacksize = ( min_stacksize + max_stacksize ) / 2 local avg_rolls = ( min_pool_rolls + max_pool_rolls ) / 2 return avg_stacksize * avg_rolls * item_weight / pool_total_item_weight end, calc_chance_any_of_this_item_per_pool = function( 			min_pool_rolls, max_pool_rolls,			item_weight, pool_total_item_weight )

local inverse_result = 0 -- 1 - inverse_result = return value local inverse_item_weight = pool_total_item_weight - item_weight -- will be used for the division in the for loop to avoid the slightly -- less performant math.pow. The divisor already includes the probability -- of picking any specific number of rolls. local cur_dividend = inverse_item_weight local cur_divisor = pool_total_item_weight * (max_pool_rolls - min_pool_rolls + 1) for i = 1, max_pool_rolls do			if i >= min_pool_rolls then inverse_result = inverse_result + cur_dividend / cur_divisor end cur_dividend = cur_dividend * inverse_item_weight -- simulate pow cur_divisor = cur_divisor * pool_total_item_weight -- simulate pow end return 1 - inverse_result end, java = 'In Java Edition, ', ['java-upcoming'] = 'In Java Edition 1.15, ', bedrock = 'In Bedrock Edition ', ['bedrock-upcoming'] = 'In Bedrock Edition 1.9 ', -- These 'items' define which sprite, label and link to use in the table. -- Properties 'cannot_stack', 'preserve_case', and 'plural' describe how to display the single-item summary in p.base2. -- Order within this 'items' list doesn't matter.

items = { ["acacia-log"]         = { "block", link="Log" }, ["acacia-sapling"]     = { "block", link="Sapling" }, ["activator-rail"]     = { "block" }, ["apple"]              = { "item" }, ["arrow"]              = { "item" }, ["bamboo"]             = { "item", plural=false }, ["barrel"]             = { "block" }, ["beef"]			   = { "item" }, ["beetroot"]           = { "item" }, ["beetroot-seeds"]     = { "item", plural=false }, ["beetroot-soup"]		= { "item", plural=false, cannot_stack=true }, ["birch-log"]          = { "block", link="Log" }, ["birch-sapling"]      = { "block", link="Sapling" }, ["black-wool"]         = { "block", link="Wool", plural=false }, ["blue-ice"]			= { "block" }, ["bone"]               = { "item" }, ["book"]               = { "item" }, ["book-and-quill"]     = { "item", plural=false, title="Book and Quill" }, ["bottle-o'-enchanting"] = { "item", title="Bottle o' Enchanting", plural="bottles o' enchanting" }, ["bread"]              = { "item", plural=false }, ["brown-mushroom"]     = { "block", link="Mushroom" }, ["brown-wool"]         = { "block", link="Wool", plural=false }, ["bucket"]             = { "item" }, ["buried-treasure-map"] = { "item", link="Explorer Map" }, ["cactus"]             = { "block", plural=false }, ["cake"]               = { "block", plural=false }, ["carrot"]             = { "item" }, ["chainmail-boots"]    = { "item", link="Armor", cannot_stack=true, plural=false }, ["chainmail-chestplate"] = { "item", link="Armor", cannot_stack=true }, ["chainmail-helmet"]   = { "item", link="Armor", cannot_stack=true }, ["chainmail-leggings"] = { "item", link="Armor", cannot_stack=true, plural=false }, ["clay"]				= { "item" }, ["clock"]				= { "item" }, ["coal"]               = { "item", plural=false }, ["cocoa-beans"]        = { "item", plural=false }, ["cooked-cod"]         = { "item", plural=false, link="Cooked Cod" }, ["cooked-salmon"]      = { "item", plural=false, link="Cooked Salmon" }, ["compass"]            = { "item" }, ["crossbow"]           = { "item", cannot_stack=true }, ["dandelion"]			= { "block", link="Flower" }, ["dark-oak-log"]       = { "block", link="Log" }, ["dark-oak-sapling"]   = { "block", link="Sapling" }, ["dead-bush"]			= { "block", link="Dead Bush" }, ["detector-rail"]      = { "block" }, ["diamond"]            = { "item" }, ["diamond-chestplate"] = { "item", link="Armor", cannot_stack=true }, ["diamond-hoe"]        = { "item", link="Hoe", cannot_stack=true }, ["diamond-horse-armor"] = { "item", link="Horse Armor", cannot_stack=true, plural=false }, ["disc-13"]            = { "item", id='music-disc-13', title="Music Disc (13)", link="Music Disc", cannot_stack=true, plural=false }, ["disc-cat"]           = { "item", id='music-disc-cat',title="Music Disc (Cat)", link="Music Disc", cannot_stack=true, plural=false }, ["disc-mellohi"]       = { "item", id='music-disc-mellohi',title="Music Disc (Mellohi)", link="Music Disc", cannot_stack=true, plural=false }, ["disc-wait"]          = { "item", id='music-disc-wait',title="Music Disc (Wait)", link="Music Disc", cannot_stack=true, plural=false }, ["egg"]            = { "item" }, ["emerald"]            = { "item" }, ["empty-map"]          = { "item", link="Map", title="Empty Map" }, ["enchanted-book"]  = { "item", id='enchanted-book', title="Enchanted Book", link="Enchanted Book", cannot_stack=true, note="enchant-with-levels-30" }, ["enchanted-book-rnd"] = { "item", id='enchanted-book', title="Enchanted Book", link="Enchanted Book", cannot_stack=true, note="enchant-randomly" }, ["enchanted-book-rnd-treasure"] = { "item", id='enchanted-book', title="Enchanted Book", link="Enchanted Book", cannot_stack=true, note="enchant-randomly-treasure" }, ["enchanted-fishing-rod"] = { "item", id="fishing-rod", link="Fishing Rod", cannot_stack=true, note="enchant-randomly" }, ["enchanted-golden-apple"] = { "item", id='golden-apple', link="Golden Apple" }, ["ender-pearl"]        = { "item" }, ["feather"]            = { "item" }, ["fern"]				= { "block", link="Grass" }, ["flint"]              = { "item", plural=false }, ["flint-and-steel"]    = { "item", cannot_stack=true, plural=false }, ["flower-pot"]			= { "item" }, ["furnace"]            = { "block" }, ["golden-apple"]       = { "item" }, ["golden-chestplate"]  = { "item", link="Armor", cannot_stack=true }, ["golden-helmet"]      = { "item", link="Armor", cannot_stack=true }, ["golden-horse-armor"] = { "item", link="Horse Armor", cannot_stack=true, plural=false }, ["golden-sword"]       = { "item", link="Sword", cannot_stack=true }, ["gold-ingot"]         = { "item" }, ["gold-nugget"]        = { "item" }, ["grass"]				= { "block", link="Grass" }, ["gray-wool"]          = { "block", link="Wool", plural=false }, ["green-dye"]			= { "item", link="Dye" }, ["gunpowder"]          = { "item", plural=false }, ["heart-of-the-sea"]   = { "item", plural=false, link="Heart of the Sea" }, ["ink-sac"]            = { "item" }, ["iron-boots"]         = { "item", link="Armor", cannot_stack=true, plural=false }, ["iron-chestplate"]    = { "item", link="Armor", cannot_stack=true }, ["iron-helmet"]        = { "item", link="Armor", cannot_stack=true }, ["iron-horse-armor"]   = { "item", link="Horse Armor", cannot_stack=true, plural=false }, ["iron-ingot"]         = { "item" }, ["iron-leggings"]      = { "item", link="Armor", cannot_stack=true, plural=false }, ["iron-nugget"]        = { "item" }, ["iron-pickaxe"]       = { "item", link="Pickaxe", cannot_stack=true }, ["iron-shovel"]        = { "item", link="Shovel", cannot_stack=true }, ["iron-sword"]         = { "item", link="Sword", cannot_stack=true }, ["jungle-log"]         = { "block", link="Log" }, ["jungle-sapling"]     = { "block", link="Sapling" }, ["lapis-lazuli"]       = { "item", plural=false }, ["large-fern"]			= { "block", link="Grass" }, ["lead"]               = { "item" }, ["leather"]     		= { "item" }, ["leather-boots"]      = { "item", link="Armor", cannot_stack=true }, ["leather-cap"]        = { "item", link="Armor", cannot_stack=true }, ["leather-pants"]      = { "item", link="Armor", cannot_stack=true }, ["leather-tunic"]      = { "item", link="Armor", cannot_stack=true }, ["light-gray-wool"]    = { "block", link="Wool", plural=false }, ["melon-seeds"]        = { "item", plural=false }, ["name-tag"]           = { "item" }, ["nether-wart"]        = { "item", plural=false }, ["oak-log"]            = { "block", link="Log" }, ["oak-planks"]         = { "block", link="Planks", id="oak-wood-planks", plural=false }, ["oak-sapling"]        = { "block", link="Sapling" }, ["oak-sign"]           = { "item", link="Sign" }, ["obsidian"]           = { "block", plural=false }, ["paper"]              = { "item", plural=false }, ["poisonous-potato"]   = { "item", plural="poisonous potatoes" }, ["poppy"]				= { "block", link="Flower" }, ["potato"]             = { "item", plural="potatoes" }, ["potion-of-regeneration"] = { "item", link="Potion", title="Potion of Regeneration", plural=false, preserve_case=true }, ["potion-of-water-breathing"] = { "item", link="Potion", title="Potion of Water Breathing", plural=false, preserve_case=true }, ["powered-rail"]       = { "block", title="Powered Rails", plural=false }, ["prismarine-crystals"] = { "item", plural=false }, ["pumpkin"]            = { "block" }, ["pumpkin-pie"]        = { "item" }, ["pumpkin-seeds"]      = { "item", plural=false }, ["rail"]               = { "block", title="Rails", plural=false }, ["raw-cod"]            = { "item", link="Raw Cod", plural=false }, ["raw-mutton"]			= { "item", link="Raw Mutton" }, ["raw-porkchop"]		= { "item", link="Raw Porkchop" }, ["raw-salmon"]         = { "item", link="Raw Salmon", plural=false }, ["redstone"]           = { "item", id="redstone-dust", title="Redstone Dust", plural=false }, ["rotten-flesh"]       = { "item", plural=false }, ["saddle"]             = { "item", cannot_stack=true }, ["sand"]               = { "block", plural=false }, ["shears"]             = { "item", plural=false, cannot_stack=true }, ["smooth-stone"]		= { "block", plural=false }, ["snowball"]			= { "item", link="Snowball" }, ["snow-block"]			= { "block", link="Snow Block" }, ["spider-eye"]         = { "item" }, ["spruce-log"]         = { "block", link="Log" }, ["spruce-sapling"]     = { "block", link="Sapling" }, ["spruce-sign"]    	= { "item", link="Sign" }, ["stick"]              = { "item" }, ["stone"]              = { "block", plural=false }, ["stone-axe"]          = { "item", link="Axe", cannot_stack=true }, ["stone-bricks"]       = { "block", plural=false }, ["stone-pickaxe"]      = { "item", link="Pickaxe", cannot_stack=true }, ["string"]             = { "item", plural=false }, ["suspicious-stew"]    = { "item", plural=false, note="suspicious-stew" }, ["sweet-berries"]      = { "item", plural=false }, ["tall-grass"]			= { "block", link="Grass" }, ["tnt"]                = { "block", title="TNT", plural=false, preserve_case=true }, ["torch"]              = { "block" }, ["water-bucket"]       = { "item", cannot_stack=true }, ["wheat"]              = { "item", plural=false }, ["wheat-seeds"]        = { "item", plural=false }, ["white-wool"]         = { "block", link="Wool", plural=false }, ["wooden-axe"]         = { "item", link="Axe", cannot_stack=true }, ["wooden-hoe"]         = { "item", link="Hoe", cannot_stack=true }, ["wooden-pickaxe"]     = { "item", link="Pickaxe", cannot_stack=true }, ["yellow-dye"]			= { "item", link="Dye" },

["enchanted-diamond-boots"]     = { "item", id="diamond-boots", link="Armor", note="enchant-with-levels-20-39", cannot_stack=true, plural=false }, ["enchanted-diamond-chestplate"] = { "item", id="diamond-chestplate", link="Armor", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-diamond-helmet"]    = { "item", id="diamond-helmet", link="Armor", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-diamond-leggings"]  = { "item", id="diamond-leggings", link="Armor", note="enchant-with-levels-20-39", cannot_stack=true, plural=false }, ["enchanted-diamond-pickaxe"]   = { "item", id="diamond-pickaxe", link="Pickaxe", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-diamond-shovel"]    = { "item", id="diamond-shovel", link="Shovel", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-diamond-sword"]     = { "item", id="diamond-sword", link="Sword", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-iron-boots"]        = { "item", id="iron-boots", link="Armor", note="enchant-with-levels-20-39", cannot_stack=true, plural=false }, ["enchanted-iron-chestplate"]   = { "item", id="iron-chestplate", link="Armor", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-iron-helmet"]       = { "item", id="iron-helmet", link="Armor", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-iron-leggings"]     = { "item", id="iron-leggings", link="Armor", note="enchant-with-levels-20-39", cannot_stack=true, plural=false }, ["enchanted-iron-pickaxe"]      = { "item", id="iron-pickaxe", link="Pickaxe", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-iron-shovel"]       = { "item", id="iron-shovel", link="Shovel", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-iron-sword"]        = { "item", id="iron-sword", link="Sword", note="enchant-with-levels-20-39", cannot_stack=true }, ["enchanted-leather-boots"]     = { "item", id="leather-boots", link="Armor", note="enchant-randomly", cannot_stack=true, plural=false }, ["enchanted-leather-cap"]       = { "item", id="leather-cap", link="Armor", note="enchant-randomly", cannot_stack=true }, ["enchanted-leather-pants"]     = { "item", id="leather-pants", link="Armor", note="enchant-randomly", cannot_stack=true, plural=false }, ["enchanted-leather-tunic"]     = { "item", id="leather-tunic", link="Armor", note="enchant-randomly", cannot_stack=true },

["empty"]                       = { "block", id="air", link='', title='Nothing', plural=false, note="nothing" }, },

notes = { ["enchant-randomly"] = "All enchantments are equally probable, except treasure enchantments, and any level of the enchantment is equally probable.", ["enchant-randomly-treasure"] = "All enchantments are equally probable, including treasure enchantments, and any level of the enchantment is equally probable.", ["enchant-with-levels-20-39"] = "Enchantment probabilities are the same as a level-20 to level-39 enchantment would be on an enchantment table that had no cap at level 30, and that was able to apply treasure enchantments, and where the chance of multiple enchantments is not reduced.", ["enchant-with-levels-30"] = "Enchantment probabilities are the same as a level-30 enchantment on an enchantment table that was able to apply treasure enchantments, and where the chance of multiple enchantments is not reduced.", ["nothing"] = "'Nothing' does not refer to the chance of an empty chest. Instead, it refers to the chance that the random loot generator will not add any loot on a single roll.", ["suspicious-stew"] = "The stew will grant one of the following effects: 5–7 seconds of Blindness, 7–10 seconds of Jump Boost, 10–20 seconds of Poison, 7–10 seconds of Saturation, 7–10 seconds of Speed, or 6–8 seconds of Weakness.", },

--  -- NOTE: order here doesn't matter. --		 * in the table, chests will sort in alphabetical order --      * in the table, items will sort by chance, then by avg#, then alphabetically. --      * If poolsJavaUpcoming is omitted, poolsJava will be used. To omit a pool entirely, set it to {}. --      * If poolsBedrock is omitted, it implies that Bedrock has the same pools as Java. This is a shortcoming; it ought to be made explicit somehow. chests = { ["shipwreck-map"] = { -- shipwreck_map.json header = "Map", superheader = "Shipwreck", link  = "shipwreck map", structure = "Shipwreck", container = "Map chest", structID = "shipwreck", poolsJava = { {					rolls = {1,1}, items = { ["buried-treasure-map"] = {1,1,1}, }				},				{					rolls = {3,3}, items = { ["compass"]            = {1,1,1}, ["empty-map"]          = {1,1,1}, ["clock"]              = {1,1,1}, ["paper"]              = {1,10,20}, ["feather"]            = {1,5,10}, ["book"]               = {1,5,5}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["shipwreck-supply"] = { -- shipwreck_supply.json header = "Supply", superheader = "Shipwreck", link  = "shipwreck supply", structure = "Shipwreck", container = "Supply chest", structID = "shipwreck", poolsJava = { {					rolls = {3,10}, items = { ["paper"]              = {1,12,8}, ["potato"]             = {2,6,7}, ["poisonous-potato"]   = {2,6,7}, ["carrot"]             = {4,8,7}, ["wheat"]              = {8,21,7}, ["coal"]               = {2,8,6}, ["rotten-flesh"]       = {5,24,5}, ["bamboo"]             = {1,3,2}, ["suspicious-stew"]    = {1,1,10}, ["pumpkin"]            = {1,3,2}, ["gunpowder"]          = {1,5,3}, ["tnt"]                = {1,2,1}, ["enchanted-leather-cap"]        = {1,1,3}, ["enchanted-leather-tunic"]      = {1,1,3}, ["enchanted-leather-pants"]      = {1,1,3}, ["enchanted-leather-boots"]      = {1,1,3}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {3,10}, items = { ["paper"]              = {1,12,8}, ["potato"]             = {2,6,7}, ["poisonous-potato"]   = {2,6,7}, ["carrot"]             = {4,8,7}, ["wheat"]              = {8,21,7}, ["coal"]               = {2,8,6}, ["rotten-flesh"]       = {5,24,5}, ["bamboo"]             = {1,3,2}, ["pumpkin"]            = {1,3,2}, ["gunpowder"]          = {1,5,3}, ["tnt"]                = {1,2,1}, ["enchanted-leather-cap"]        = {1,1,3}, ["enchanted-leather-tunic"]      = {1,1,3}, ["enchanted-leather-pants"]      = {1,1,3}, ["enchanted-leather-boots"]      = {1,1,3}, }				},			},			poolsBedrockUpcoming = {} },		["shipwreck-treasure"] = { -- shipwreck_treasure.json header = "Treasure", superheader = "Shipwreck", link  = "shipwreck treasure", structure = "Shipwreck", container = "Treasure chest", structID = "shipwreck", poolsJava = { {					rolls = {3,6}, items = { ["iron-ingot"]         = {1,5,90}, ["gold-ingot"]         = {1,5,10}, ["emerald"]            = {1,5,40}, ["diamond"]            = {1,1,5}, ["bottle-o'-enchanting"] = {1,1,5}, }				},				{					rolls = {2,5}, items = { ["iron-nugget"]        = {1,10,50}, ["gold-nugget"]        = {1,10,10}, ["lapis-lazuli"]       = {1,10,20}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["buried-treasure"] = { -- buried_treasure.json header = "Buried treasure", link  = "buried treasure", structure = "Buried treasure", container = "", structID = "buried-treasure", poolsJava = { {					rolls = {1,1}, items = { ["heart-of-the-sea"]   = {1,1,1}, }				},				{					rolls = {5,8}, items = { ["iron-ingot"]         = {1,4,20}, ["gold-ingot"]         = {1,4,10}, ["tnt"]                = {1,2,5}, }				},				{					rolls = {1,3}, items = { ["emerald"]            = {4,8,5}, ["diamond"]            = {1,2,5}, ["prismarine-crystals"] = {1,5,5}, }				},				{					rolls = {0,1}, items = { ["leather-tunic"]      = {1,1,1}, ["iron-sword"]         = {1,1,1}, }				},				{					rolls = {2,2}, items = { ["cooked-cod"]         = {2,4,1}, ["cooked-salmon"]      = {2,4,1}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {1,1}, items = { ["heart-of-the-sea"]   = {1,1,1}, }				},				{					rolls = {5,12}, items = { ["prismarine-crystals"] = {1,5,5}, ["iron-ingot"]         = {3,5,20}, ["gold-ingot"]         = {1,5,10}, ["tnt"]                = {1,2,10}, ["diamond"]            = {1,1,15}, ["disc-wait"]          = {1,1,5}, ["disc-mellohi"]       = {1,1,5}, ["name-tag"]           = {1,1,10}, ["chainmail-chestplate"] = {1,1,20}, ["chainmail-helmet"]   = {1,1,20}, ["chainmail-leggings"] = {1,1,20}, ["chainmail-boots"]    = {1,1,20}, ["book-and-quill"]     = {1,2,5}, ["lead"]               = {1,3,10}, ["bottle-o'-enchanting"] = {1,1,3}, ["potion-of-water-breathing"] = {1,1,15}, ["potion-of-regeneration"] = {1,1,10}, ["cake"]               = {1,1,1}, }				},			},			poolsBedrockUpcoming = {} },		["underwater-ruin-big"] = { -- underwater_ruin_big.json header = "Big", superheader = "Underwater ruins", link  = "big underwater ruins", structure = "Underwater ruins", container = "Big ruins chest", structID = "underwater-ruins", poolsJava = { {					rolls = {2,8}, items = { ["coal"]               = {1,4,10}, ["gold-nugget"]        = {1,3,10}, ["emerald"]            = {1,1,1}, ["wheat"]              = {2,3,10}, }				},				{					rolls = {1,1}, items = { ["golden-apple"]       = {1,1,1}, ["enchanted-book-rnd"] = {1,1,5}, ["leather-tunic"]      = {1,1,1}, ["golden-helmet"]      = {1,1,1}, ["enchanted-fishing-rod"] = {1,1,5}, ["buried-treasure-map"] = {1,1,10}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["underwater-ruin-small"] = { -- underwater_ruin_small.json header = "Small", superheader = "Underwater ruins", link  = "small underwater ruins", structure = "Underwater ruins", container = "Small ruins chest", structID = "underwater-ruins", poolsJava = { {					rolls = {2,8}, items = { ["coal"]               = {1,4,10}, ["stone-axe"]          = {1,1,2}, ["rotten-flesh"]       = {1,1,5}, ["emerald"]            = {1,1,1}, ["wheat"]              = {2,3,10}, }				},				{					rolls = {1,1}, items = { ["leather-tunic"]      = {1,1,1}, ["golden-helmet"]      = {1,1,1}, ["enchanted-fishing-rod"] = {1,1,5}, ["buried-treasure-map"] = {1,1,5}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-armorer"] = { -- village\village_armorer.json header = "Armorer", superheader = "Village", link  = "village armorer", structure = "Village", container = "Armorer's chest", structID = "village", poolsJava = { {					rolls = {1,5}, items = { ["iron-ingot"]    = {1,3,2}, ["bread"]         = {1,4,4}, ["iron-helmet"]   = {1,1,1}, ["emerald"]       = {1,1,1} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-butcher"] = { -- village\village_butcher.json header = "Butcher", superheader = "Village", link  = "village butcher", structure = "Village", container = "Butcher's chest", structID = "village", poolsJava = { {					rolls = {1,5}, items = { ["emerald"]       = {1,1,1}, ["raw-porkchop"]  = {1,3,6}, ["wheat"]         = {1,3,6}, ["beef"]          = {1,3,6}, ["raw-mutton"]    = {1,3,6}, ["coal"]          = {1,3,3} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-cartographer"] = { -- village\village_cartographer.json header = "Cartographer", superheader = "Village", link  = "village cartographer", structure = "Village", container = "Cartographer's chest", structID = "village", poolsJava = { {					rolls = {1,5}, items = { ["empty-map"]     = {1,3,10}, ["paper"]         = {1,5,15}, ["compass"]       = {1,1,5}, ["bread"]         = {1,4,15}, ["oak-sapling"]   = {1,2,5} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {1,5}, items = { ["empty-map"]     = {1,3,10}, ["paper"]         = {1,5,15}, ["compass"]       = {1,1,5}, ["bread"]         = {1,4,15}, ["stick"]   = {1,2,5} }				},			},			poolsBedrockUpcoming = {} },		["village-fisherman"] = { -- village\village_fisher.json, Java-exclusive as of Java 1.14 / Bedrock 1.12 header = "Fisherman", superheader = "Village", link  = "village fisherman", structure = "Village", container = "Fisherman's chest", structID = "village", poolsJava = { {					rolls = {1,5}, items = { ["emerald"]        = {1,1,1}, ["raw-cod"]        = {1,3,2}, ["raw-salmon"]     = {1,3,1}, ["water-bucket"]   = {1,3,1}, ["barrel"]         = {1,3,1}, ["wheat-seeds"]    = {1,3,3}, ["coal"]           = {1,3,2} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-fletcher"] = { -- village\village_fletcher.json header = "Fletcher", superheader = "Village", link  = "village fletcher", structure = "Village", container = "Fletcher's chest", structID = "village", poolsJava = { {					rolls = {1,5}, items = { ["emerald"]        = {1,1,1}, ["arrow"]          = {1,3,2}, ["feather"]        = {1,3,6}, ["egg"]            = {1,3,2}, ["flint"]          = {1,3,6}, ["stick"]          = {1,3,6} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-mason"] = { -- village\village_mason.json header = "Mason", superheader = "Village", link  = "village mason", structure = "Village", container = "Mason's chest", structID = "village", poolsJava = { {					rolls = {1,5}, items = { ["clay"]          = {1,3,1}, ["flower-pot"]    = {1,1,1}, ["stone"]         = {1,1,2}, ["stone-bricks"]  = {1,1,2}, ["bread"]         = {1,4,4}, ["yellow-dye"]    = {1,1,1}, ["smooth-stone"]  = {1,1,1}, ["emerald"]       = {1,1,1} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-shepherd"] = { -- village\village_shepherd.json header = "Shepherd", superheader = "Village", link  = "village shepherd", structure = "Village", container = "Shepherd's chest", structID = "village", poolsJava = { {					rolls = {1,5}, items = { ["white-wool"]     = {1,8,6}, ["black-wool"]     = {1,3,3}, ["gray-wool"]      = {1,3,2}, ["brown-wool"]     = {1,3,2}, ["light-gray-wool"] = {1,3,2}, ["emerald"]        = {1,1,1}, ["shears"]         = {1,1,1}, ["wheat"]          = {1,6,6} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-tannery"] = { -- village\village_tannery.json header = "Tannery", superheader = "Village", link  = "village tannery", structure = "Village", container = "Tanner's chest", structID = "village", poolsJava = { {					rolls = {1,5}, items = { ["leather"]        = {1,3,1}, ["leather-tunic"]  = {1,1,2}, ["leather-boots"]  = {1,1,2}, ["leather-cap"]    = {1,1,2}, ["bread"]          = {1,4,5}, ["leather-pants"]  = {1,1,2}, ["saddle"]         = {1,1,1}, ["emerald"]        = {1,4,1} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-temple"] = { -- village\village_temple.json header = "Temple", superheader = "Village", link  = "village temple", structure = "Village", container = "Temple chest", structID = "village", poolsJava = { {					rolls = {3,8}, items = { ["redstone"]       = {1,4,2}, ["bread"]          = {1,4,7}, ["rotten-flesh"]   = {1,4,7}, ["lapis-lazuli"]   = {1,4,1}, ["gold-ingot"]     = {1,4,1}, ["emerald"]        = {1,4,1} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-toolsmith"] = { -- village\village_toolsmith.json header = "Toolsmith", superheader = "Village", link  = "village toolsmith", structure = "Village", container = "Toolsmith's chest", structID = "village", poolsJava = { {					rolls = {3,8}, items = { ["diamond"]        = {1,3,1}, ["iron-ingot"]     = {1,5,5}, ["gold-ingot"]     = {1,3,1}, ["bread"]          = {1,3,15}, ["iron-pickaxe"]   = {1,1,5}, ["coal"]           = {1,3,1}, ["stick"]          = {1,3,20}, ["iron-shovel"]    = {1,1,5} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-weaponsmith"] = { -- village\village_weaponsmith.json header = "Weaponsmith", superheader = "Village", link  = "village weaponsmith", structure = "Village", container = "Weaponsmith's chest", structID = "village", poolsJava = { {					rolls = {3,8}, items = { ["diamond"]            = {1,3,3}, ["iron-ingot"]         = {1,5,10}, ["gold-ingot"]         = {1,3,5}, ["bread"]              = {1,3,15}, ["apple"]              = {1,3,15}, ["iron-pickaxe"]       = {1,1,5}, ["iron-sword"]         = {1,1,5}, ["iron-chestplate"]    = {1,1,5}, ["iron-helmet"]        = {1,1,5}, ["iron-leggings"]      = {1,1,5}, ["iron-boots"]         = {1,1,5}, ["obsidian"]           = {3,7,5}, ["oak-sapling"]        = {3,7,5}, ["saddle"]             = {1,1,3}, ["iron-horse-armor"]   = {1,1,1}, ["golden-horse-armor"] = {1,1,1}, ["diamond-horse-armor"] = {1,1,1} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-desert-house"] = { -- village\village_desert_house.json header = "Desert House", superheader = "Village", link  = "desert village house", structure = "Village", container = "Desert house chest", structID = "village", poolsJava = { {					rolls = {3,8}, items = { ["clay"]           = {1,1,1}, ["green-dye"]      = {1,1,1}, ["cactus"]         = {1,4,10}, ["wheat"]          = {1,7,10}, ["bread"]          = {1,4,10}, ["book"]           = {1,1,1}, ["dead-bush"]      = {1,3,2}, ["emerald"]        = {1,3,1} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-plains-house"] = { -- village\village_plains_house.json header = "Plains house", superheader = "Village", link  = "plains village house", structure = "Village", container = "Plains house chest", structID = "village", poolsJava = { {					rolls = {3,8}, items = { ["gold-nugget"]    = {1,3,1}, ["dandelion"]      = {1,1,2}, ["poppy"]          = {1,1,2}, ["potato"]         = {1,7,10}, ["bread"]          = {1,4,10}, ["apple"]          = {1,5,10}, ["book"]           = {1,1,1}, ["feather"]        = {1,1,1}, ["emerald"]        = {1,4,2}, ["oak-sapling"]    = {1,2,5} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-savanna-house"] = { -- village\village_savanna_house.json header = "Savanna house", superheader = "Village", link  = "savanna village house", structure = "Village", container = "Savanna house chest", structID = "village", poolsJava = { {					rolls = {3,8}, items = { ["gold-nugget"]    = {1,3,1}, ["grass"]          = {1,1,5}, ["tall-grass"]     = {1,1,5}, ["bread"]          = {1,4,10}, ["wheat-seeds"]    = {1,5,10}, ["emerald"]        = {1,4,2}, ["acacia-sapling"] = {1,2,10}, ["saddle"]         = {1,1,1}, ["torch"]          = {1,2,1}, ["bucket"]         = {1,1,1} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-snowy-house"] = { -- village\village_snowy_house.json header = "Snowy house", superheader = "Village", link  = "snowy village house", structure = "Village", container = "Snowy house chest", structID = "village", poolsJava = { {					rolls = {3,8}, items = { ["blue-ice"]       = {1,1,1}, ["snow-block"]     = {1,1,4}, ["potato"]         = {1,7,10}, ["bread"]          = {1,4,10}, ["beetroot-seeds"] = {1,5,10}, ["beetroot-soup"]  = {1,1,1}, ["furnace"]        = {1,1,1}, ["emerald"]        = {1,4,1}, ["snowball"]       = {1,7,10}, ["coal"]           = {1,4,5} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["village-taiga-house"] = { -- village\village_taiga_house.json header = "Taiga house", superheader = "Village", link  = "taiga village house", structure = "Village", container = "Taiga house chest", structID = "village", poolsJava = { {					rolls = {3,8}, items = { ["iron-nugget"]    = {1,5,1}, ["fern"]           = {1,1,2}, ["large-fern"]     = {1,1,2}, ["potato"]         = {1,7,10}, ["sweet-berries"]  = {1,7,5}, ["bread"]          = {1,4,10}, ["pumpkin-seeds"]  = {1,5,5}, ["pumpkin-pie"]    = {1,1,1}, ["emerald"]        = {1,4,2}, ["spruce-sapling"] = {1,5,5}, ["spruce-sign"]    = {1,1,1}, ["spruce-log"]     = {1,5,10} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {3,8}, items = { ["iron-nugget"]    = {1,5,1}, ["fern"]           = {1,1,2}, ["large-fern"]     = {1,1,2}, ["potato"]         = {1,7,10}, ["bread"]          = {1,4,10}, ["pumpkin-seeds"]  = {1,5,5}, ["pumpkin-pie"]    = {1,1,1}, ["emerald"]        = {1,4,2}, ["spruce-sapling"] = {1,5,5}, ["oak-sign"]       = {1,1,1}, ["spruce-log"]     = {1,5,10} }				},			},			poolsBedrockUpcoming = {} },		["stronghold-altar"] = { -- stronghold_corridor.json header     = "Altar", superheader = "Stronghold", link       = "stronghold altar", structure = "Stronghold", container = "Altar chest", structID = "stronghold", poolsJava = { {					rolls = {2,3}, items = { ["ender-pearl"]        = {1,1,10}, ["diamond"]            = {1,3,3}, ["iron-ingot"]         = {1,5,10}, ["gold-ingot"]         = {1,3,5}, ["redstone"]           = {4,9,5}, ["bread"]              = {1,3,15}, ["apple"]              = {1,3,15}, ["iron-pickaxe"]       = {1,1,5}, ["iron-sword"]         = {1,1,5}, ["iron-chestplate"]    = {1,1,5}, ["iron-helmet"]        = {1,1,5}, ["iron-leggings"]      = {1,1,5}, ["iron-boots"]         = {1,1,5}, ["golden-apple"]       = {1,1,1}, ["saddle"]             = {1,1,1}, ["iron-horse-armor"]   = {1,1,1}, ["golden-horse-armor"] = {1,1,1}, ["diamond-horse-armor"] = {1,1,1}, ["enchanted-book"]     = {1,1,1}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {2,3}, items = { ["ender-pearl"]        = {1,1,50}, ["emerald"]            = {1,3,15}, ["diamond"]            = {1,3,15}, ["iron-ingot"]         = {1,5,50}, ["gold-ingot"]         = {1,3,25}, ["redstone"]           = {4,9,25}, ["bread"]              = {1,3,75}, ["apple"]              = {1,3,75}, ["iron-pickaxe"]       = {1,1,25}, ["iron-sword"]         = {1,1,25}, ["iron-chestplate"]    = {1,1,25}, ["iron-helmet"]        = {1,1,25}, ["iron-leggings"]      = {1,1,25}, ["iron-boots"]         = {1,1,25}, ["golden-apple"]       = {1,1,5}, ["saddle"]             = {1,1,5}, ["iron-horse-armor"]   = {1,1,5}, ["golden-horse-armor"] = {1,1,5}, ["diamond-horse-armor"] = {1,1,5}, ["enchanted-book"]     = {1,1,6}, }				},			},			poolsBedrockUpcoming = {} },		["stronghold-library"] = { -- stronghold_library.json header     = "Library", superheader = "Stronghold", link       = "stronghold library", structure = "Stronghold", container = "Library chest", structID = "stronghold", poolsJava = { {					rolls = {2,10}, items = { ["book"]               = {1,3,20}, ["paper"]              = {2,7,20}, ["empty-map"]          = {1,1,1}, ["compass"]            = {1,1,1}, ["enchanted-book"]     = {1,1,10}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {2,10}, items = { ["book"]               = {1,3,100}, ["paper"]              = {2,7,100}, ["empty-map"]          = {1,1,5}, ["compass"]            = {1,1,5}, ["enchanted-book"]     = {1,1,60}, }				},			},			poolsBedrockUpcoming = {} },		["stronghold-storeroom"] = { -- stronghold_crossing.json header     = "Storeroom", superheader = "Stronghold", link       = "stronghold storeroom", structure = "Stronghold", container = "Storeroom chest", structID = "stronghold", poolsJava = { {					rolls = {1,4}, items = { ["iron-ingot"]         = {1,5,10}, ["gold-ingot"]         = {1,3,5}, ["redstone"]           = {4,9,5}, ["coal"]               = {3,8,10}, ["bread"]              = {1,3,15}, ["apple"]              = {1,3,15}, ["iron-pickaxe"]       = {1,1,1}, ["enchanted-book"]     = {1,1,1}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {1,4}, items = { ["iron-ingot"]         = {1,5,50}, ["gold-ingot"]         = {1,3,25}, ["redstone"]           = {4,9,25}, ["coal"]               = {3,8,50}, ["bread"]              = {1,3,75}, ["apple"]              = {1,3,75}, ["iron-pickaxe"]       = {1,1,5}, ["enchanted-book"]     = {1,1,6}, ["ink-sac"]            = {1,3,75}, }				},			},			poolsBedrockUpcoming = {} },		["bonus"] = { -- spawn_bonus_chest.json header = "Bonus", link  = "bonus", structure = "Bonus chest", container = "", structID = "day", poolsJava = { {					rolls = {1,1}, items = { ["stone-axe"]          = {1,1,1}, ["wooden-axe"]         = {1,1,3}, }				},				{					rolls = {1,1}, items = { ["stone-pickaxe"]      = {1,1,1}, ["wooden-pickaxe"]     = {1,1,3} }				},				{					rolls = {3,3}, items = { ["apple"]              = {1,2,5}, ["bread"]              = {1,2,3}, ["raw-salmon"]         = {1,2,3}, }				},				{					rolls = {4,4}, items = { ["stick"]              = {1,12,10}, ["oak-planks"]         = {1,12,10}, ["oak-log"]            = {1,3,3}, ["spruce-log"]         = {1,3,3}, ["birch-log"]          = {1,3,3}, ["jungle-log"]         = {1,3,3}, ["acacia-log"]         = {1,3,3}, ["dark-oak-log"]       = {1,3,3}, }				},			},		   poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {1,1}, items = { ["stone-axe"]          = {1,1,1}, ["wooden-axe"]         = {1,1,3}, }				},				{					rolls = {1,1}, items = { ["stone-pickaxe"]      = {1,1,1}, ["wooden-pickaxe"]     = {1,1,3} }				},				{					rolls = {1,1}, items = { ["apple"]              = {1,2,1} }				},				{					rolls = {1,1}, items = { ["bread"]              = {1,2,1} }				},				{					rolls = {1,1}, items = { ["raw-salmon"]         = {1,2,1} }				},				{					rolls = {1,1}, items = { ["stick"]              = {1,12,1} } 				},				{					rolls = {1,1}, items = { ["oak-planks"]         = {1,12,1} } 				},				{					rolls = {1,1}, items = { ["dark-oak-log"]       = {1,3,1}, ["acacia-log"]         = {1,3,1}, }				},				{					rolls = {1,1}, items = { ["oak-log"]            = {1,3,1}, ["spruce-log"]         = {1,3,1}, ["birch-log"]          = {1,3,1}, ["jungle-log"]         = {1,3,1}, }				},				{					rolls = {1,1}, items = { ["potato"]             = {1,2,3}, ["carrot"]             = {1,2,3}, }				},				{					rolls = {1,1}, items = { ["oak-sapling"]        = {4,4,2}, ["spruce-sapling"]     = {4,4,2}, ["birch-sapling"]      = {4,4,2}, ["jungle-sapling"]     = {4,4,2}, ["dark-oak-sapling"]   = {4,4,2}, ["acacia-sapling"]     = {4,4,2}, }				},				{					rolls = {1,1}, items = { ["melon-seeds"]        = {1,2,3}, ["pumpkin-seeds"]      = {1,2,3}, ["beetroot-seeds"]     = {1,2,3}, }				},				{					rolls = {1,1}, items = { ["cactus"]             = {1,2,3}, ["cocoa-beans"]        = {1,2,3}, }				},				{					rolls = {1,1}, items = { ["brown-mushroom"]             = {1,2,2}, }				},			},			poolsBedrockUpcoming = {} },		["dungeon"] = { -- simple_dungeon.json header = "Dungeon", link  = "dungeon", structure = "Dungeon", container = "", structID = "Dungeon", poolsJava = { {					rolls = {1,3}, items = { ["saddle"]             = {1,1,20}, ["golden-apple"]       = {1,1,15}, ["enchanted-golden-apple"] = {1,1,2}, ["disc-13"]            = {1,1,15}, ["disc-cat"]           = {1,1,15}, ["name-tag"]           = {1,1,20}, ["golden-horse-armor"] = {1,1,10}, ["iron-horse-armor"]   = {1,1,15}, ["diamond-horse-armor"] = {1,1,5}, ["enchanted-book-rnd"] = {1,1,10}, }				},				{					rolls = {1,4}, items = { ["iron-ingot"]         = {1,4,10}, ["gold-ingot"]         = {1,4,5}, ["bread"]              = {1,1,20}, ["wheat"]              = {1,4,20}, ["bucket"]             = {1,1,10}, ["redstone"]           = {1,4,15}, ["coal"]               = {1,4,15}, ["melon-seeds"]        = {2,4,10}, ["pumpkin-seeds"]      = {2,4,10}, ["beetroot-seeds"]     = {2,4,10}, }				},				{					rolls = {3,3}, items = { ["bone"]               = {1,8,10}, ["gunpowder"]          = {1,8,10}, ["rotten-flesh"]       = {1,8,10}, ["string"]             = {1,8,10}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["mineshaft"] = { -- abandoned_mineshaft.json chest_type = "minecart with chest", header = "Mineshaft", link  = "abandoned mineshafts", structure = "Mineshaft", container = "", structID = "abandoned-mineshaft", poolsJava = { {					rolls = {1,1}, items = { ["golden-apple"]       = {1,1,20}, ["enchanted-golden-apple"] = {1,1,1}, ["name-tag"]           = {1,1,30}, ["enchanted-book-rnd"] = {1,1,10}, ["iron-pickaxe"]       = {1,1,5}, ["empty"]				= {1,1,5}, }				},				{					rolls = {2,4}, items = { ["iron-ingot"]         = {1,5,10}, ["gold-ingot"]         = {1,3,5}, ["redstone"]           = {4,9,5}, ["lapis-lazuli"]       = {4,9,5}, ["diamond"]            = {1,2,3}, ["coal"]               = {3,8,10}, ["bread"]              = {1,3,15}, ["melon-seeds"]        = {2,4,10}, ["pumpkin-seeds"]      = {2,4,10}, ["beetroot-seeds"]     = {2,4,10}, }				},				{					rolls = {3,3}, items = { ["rail"]               = {4,8,20}, ["powered-rail"]       = {1,4,5}, ["detector-rail"]      = {1,4,5}, ["activator-rail"]     = {1,4,5}, ["torch"]              = {1,16,15}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["nether-fortress"] = { -- nether_bridge.json header = "Nether fortress", link  = "nether fortress", structure = "Nether fortress", container = "", structID = "nether-fortress", poolsJava = { {					rolls = {2,4}, items = { ["diamond"]            = {1,3,5}, ["iron-ingot"]         = {1,5,5}, ["gold-ingot"]         = {1,3,15}, ["golden-sword"]       = {1,1,5}, ["golden-chestplate"]  = {1,1,5}, ["flint-and-steel"]    = {1,1,5}, ["nether-wart"]        = {3,7,5}, ["saddle"]             = {1,1,10}, ["golden-horse-armor"]   = {1,1,8}, ["iron-horse-armor"]   = {1,1,5}, ["diamond-horse-armor"] = {1,1,3}, ["obsidian"]           = {2,4,2}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["desert-temple"] = { -- desert_pyramid.json header = "Desert temple", link  = "desert temple", structure = "Desert temple", container = "", structID = "desert-temple", poolsJava = { {					rolls = {2,4}, items = { ["diamond"]            = {1,3,5}, ["iron-ingot"]         = {1,5,15}, ["gold-ingot"]         = {2,7,15}, ["emerald"]            = {1,3,15}, ["bone"]               = {4,6,25}, ["spider-eye"]         = {1,3,25}, ["rotten-flesh"]       = {3,7,25}, ["saddle"]             = {1,1,20}, ["iron-horse-armor"]   = {1,1,15}, ["golden-horse-armor"] = {1,1,10}, ["diamond-horse-armor"] = {1,1,5}, ["enchanted-book-rnd"] = {1,1,20}, ["golden-apple"]       = {1,1,20}, ["enchanted-golden-apple"] = {1,1,2}, ["empty"]              = {1,1,15}, }				},				{					rolls = {4,4}, items = { ["bone"]               = {1,8,10}, ["gunpowder"]          = {1,8,10}, ["rotten-flesh"]       = {1,8,10}, ["string"]             = {1,8,10}, ["sand"]               = {1,8,10}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["jungle-temple"] = { -- jungle_temple.json header = "Jungle temple", link  = "jungle temple", structure = "Jungle temple", container = "Chest", structID = "jungle-temple", poolsJava = { {					rolls = {2,6}, items = { ["diamond"]            = {1,3,3}, ["iron-ingot"]         = {1,5,10}, ["gold-ingot"]         = {2,7,15}, ["emerald"]            = {1,3,2}, ["bone"]               = {4,6,20}, ["bamboo"]             = {1,3,15}, ["rotten-flesh"]       = {3,7,16}, ["saddle"]             = {1,1,3}, ["iron-horse-armor"]   = {1,1,1}, ["golden-horse-armor"] = {1,1,1}, ["diamond-horse-armor"] = {1,1,1}, ["enchanted-book"]     = {1,1,1} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {2,6}, items = { ["diamond"]            = {1,3,15}, ["iron-ingot"]         = {1,5,50}, ["gold-ingot"]         = {2,7,75}, ["emerald"]            = {1,3,10}, ["bone"]               = {4,6,100}, ["rotten-flesh"]       = {3,7,80}, ["bamboo"]             = {1,3,75}, ["saddle"]             = {1,1,15}, ["iron-horse-armor"]   = {1,1,5}, ["golden-horse-armor"] = {1,1,5}, ["diamond-horse-armor"] = {1,1,5}, ["enchanted-book"]     = {1,1,6} }				},			},			poolsBedrockUpcoming = {}, },		["jungle-temple-dispenser"] = { -- jungle_temple_dispenser.json chest_type = "dispenser", link  = "jungle temples", structure = "Jungle temple", container = "Dispenser", structID = "jungle-temple", poolsJava = { {					rolls = {1,2}, items = { ["arrow"] = {2,7,30} }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {2,2}, items = { ["arrow"] = {2,7,30} }				},			},			poolsBedrockUpcoming = {} },		["end-city"] = { -- end_city_treasure.json header = "End city", link  = "End city", structure = "End city", container = "", structID = "end-city", poolsJava = { {					rolls = {2,6}, items = { ["diamond"]            = {2,7,5}, ["iron-ingot"]         = {4,8,10}, ["gold-ingot"]         = {2,7,15}, ["emerald"]            = {2,6,2}, ["beetroot-seeds"]     = {1,10,5}, ["saddle"]             = {1,1,3}, ["iron-horse-armor"]   = {1,1,1}, ["golden-horse-armor"] = {1,1,1}, ["diamond-horse-armor"] = {1,1,1}, ["enchanted-diamond-sword"]     = {1,1,3}, ["enchanted-diamond-boots"]     = {1,1,3}, ["enchanted-diamond-chestplate"] = {1,1,3}, ["enchanted-diamond-leggings"]  = {1,1,3}, ["enchanted-diamond-helmet"]    = {1,1,3}, ["enchanted-diamond-pickaxe"]   = {1,1,3}, ["enchanted-diamond-shovel"]    = {1,1,3}, ["enchanted-iron-sword"]        = {1,1,3}, ["enchanted-iron-boots"]        = {1,1,3}, ["enchanted-iron-chestplate"]   = {1,1,3}, ["enchanted-iron-leggings"]     = {1,1,3}, ["enchanted-iron-helmet"]       = {1,1,3}, ["enchanted-iron-pickaxe"]      = {1,1,3}, ["enchanted-iron-shovel"]       = {1,1,3}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["igloo"] = { header = "Igloo", link  = "igloo", structure = "Igloo", container = "", structID = "igloo", poolsJava = { {					rolls = {2,8}, items = { ["apple"]              = {1,3,15}, ["coal"]               = {1,4,15}, ["gold-nugget"]        = {1,3,10}, ["stone-axe"]          = {1,1,2}, ["rotten-flesh"]       = {1,1,10}, ["emerald"]            = {1,1,1}, ["wheat"]              = {2,3,10} }				},				{					rolls = {1,1}, items = { ["golden-apple"]       = {1,1,1}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["pillager-outpost"] = { header = "Pillager outpost", link  = "pillager outpost", structure = "Pillager Outpost", container = "", structID = "pillager-outpost", poolsJava = { {					rolls = {0,1}, items = { ["crossbow"]            = {1,1,1}, }				},				{					rolls = {2,3}, items = { ["wheat"]               = {3,5,7}, ["potato"]              = {2,5,5}, ["carrot"]              = {3,5,5} }				},				{					rolls = {1,3}, items = { ["dark-oak-log"]        = {2,3,1} }				},				{					rolls = {2,3}, items = { ["bottle-o'-enchanting"] = {1,1,7}, ["string"]              = {1,6,4}, ["arrow"]               = {2,7,4}, ["tripwire-hook"]       = {1,3,3}, ["iron-ingot"]          = {1,3,3}, ["enchanted-book-rnd"]  = {1,1,1} }				}			},			poolsJavaUpcoming = {}, poolsBedrock = {}, poolsBedrockUpcoming = {} },		["woodland-mansion"] = { -- woodland_mansion.json header = "Woodland Mansion", link  = "woodland mansion", structure = "Woodland mansion", container = "", structID = "woodland-mansion", poolsJava = { {					rolls = {1,3}, items = { ["lead"]                 = {1,1,20}, ["golden-apple"]         = {1,1,15}, ["enchanted-golden-apple"] = {1,1,2}, ["disc-13"]              = {1,1,15}, ["disc-cat"]             = {1,1,15}, ["name-tag"]             = {1,1,20}, ["chainmail-chestplate"] = {1,1,10}, ["diamond-hoe"]          = {1,1,15}, ["diamond-chestplate"]   = {1,1,5}, ["enchanted-book-rnd"]   = {1,1,10}, }				},				{					rolls = {1,4}, items = { ["iron-ingot"]           = {1,4,10}, ["gold-ingot"]           = {1,4,5}, ["bread"]                = {1,1,20}, ["wheat"]                = {1,4,20}, ["bucket"]               = {1,1,10}, ["redstone"]             = {1,4,15}, ["coal"]                 = {1,4,15}, ["melon-seeds"]          = {2,4,10}, ["pumpkin-seeds"]        = {2,4,10}, ["beetroot-seeds"]       = {2,4,10}, }				},				{					rolls = {3,3}, items = { ["bone"]                 = {1,8,10}, ["gunpowder"]            = {1,8,10}, ["rotten-flesh"]         = {1,8,10}, ["string"]               = {1,8,10}, }				},			},			poolsJavaUpcoming = {}, poolsBedrock = { {					rolls = {1,3}, items = { ["lead"]                 = {1,1,100}, ["golden-apple"]         = {1,1,75}, ["enchanted-golden-apple"] = {1,1,10}, ["disc-13"]              = {1,1,75}, ["disc-cat"]             = {1,1,75}, ["name-tag"]             = {1,1,100}, ["chainmail-chestplate"] = {1,1,50}, ["diamond-hoe"]          = {1,1,75}, ["diamond-chestplate"]   = {1,1,25}, ["enchanted-book-rnd-treasure"] = {1,1,60}, }				},				{					rolls = {1,4}, items = { ["iron-ingot"]           = {1,4,50}, ["gold-ingot"]           = {1,4,25}, ["bread"]                = {1,1,100}, ["wheat"]                = {1,4,100}, ["bucket"]               = {1,1,50}, ["redstone"]             = {1,4,75}, ["coal"]                 = {1,4,75}, ["melon-seeds"]          = {2,4,50}, ["pumpkin-seeds"]        = {2,4,50}, ["beetroot-seeds"]       = {2,4,50}, }				},				{					rolls = {3,3}, items = { ["bone"]                 = {1,8,50}, ["gunpowder"]            = {1,8,50}, ["rotten-flesh"]         = {1,8,50}, ["string"]               = {1,8,50}, }				},			},			poolsBedrockUpcoming = {} },	},

-- these values are used: -- * in place of the keys, when the key is used as a parameter -- chest-param -> internally-valid-chest-param synonyms = { ["desert"] = "desert-temple", ["jungle"] = "jungle-temple", ["nether"] = "nether-fortress", ["fortress"] = "nether-fortress", ["armorer"]      = "village-armorer", ["butcher"]      = "village-butcher", ["cartographer"] = "village-cartographer", ["fisherman"]    = "village-fisherman", ["fletcher"]     = "village-fletcher", ["mason"]        = "village-mason", ["shepherd"]     = "village-shepherd", ["tannery"]      = "village-tannery", ["temple"]       = "village-temple", ["toolsmith"]    = "village-toolsmith", ["weaponsmith"]  = "village-weaponsmith",

["desert-house"] = "village-desert-house", ["plains-house"] = "village-plains-house", ["savanna-house"] = "village-savanna-house", ["snowy-house"]  = "village-snowy-house", ["taiga-house"]  = "village-taiga-house", ["altar"] = "stronghold-altar", ["storeroom"] = "stronghold-storeroom", ["library"] = "stronghold-library", ["outpost"] = "pillager-outpost", ["mansion"] = "woodland-mansion" },

-- these values are used: -- * in the header-description of a table showing only a single chest -- * if the key is not here, but it is a valid chest parameter, --  that header-description will default to use the key string from p.chests, --  e.g. "nether-fortress" -- chest-param -> description-string display_names = { ["nether-fortress"] = "Nether fortress", ["nether"] = "Nether fortress", ["fortress"] = "Nether fortress", ["desert"] = "desert temple", ["jungle"] = "jungle temple", ["desert-temple"] = "desert temple", ["jungle-temple"] = "jungle temple" },	-- these descriptions are used: -- * in column titles, -- * and above the table when only a single column-type is chosen columns = { ["stacksize"] = 'The size of stacks (or for unstackable items, number) of this item on any given roll.', ["weight"] = 'The weight of this item relative to other items in the pool.', ["items"] = 'The number of items expected per chest, averaged over a large number of chests.', ["chance"] = 'The odds of finding any of this item in a single chest.', ["chests"] = 'The number of chests the player should expect to search, to find any of this item.' },	current_frame = nil }

p.base = function( ... )

p.current_frame = mw.getCurrentFrame

local args = { ... }	if args[1] == p.current_frame then args = require( 'Module:ProcessArgs' ).merge( true ) else args = args[1] end -- transform args into usable list local chests, columns = q.massage_args( args ) if #chests == 0 then return " Module:LootChest: no valid arguments " end

q.fill_in_chest_derivative_data( chests ) -- construct an ordered list dictating the order of the rows local ordered_item_rows_java = {} local ordered_item_rows_java_upcoming = {} local ordered_item_rows_bedrock = {} local ordered_item_rows_bedrock_upcoming = {}

local ret = {} local java_specified            = args.java                and args.java ~= '0'; local java_upcoming_specified   = args['java-upcoming']    and args['java-upcoming'] ~= '0'; local bedrock_specified         = args.bedrock             and args.bedrock ~= '0'; local bedrock_upcoming_specified = args['bedrock-upcoming'] and args['bedrock-upcoming'] ~= '0'; local any_specified = java_specified or java_upcoming_specified or bedrock_specified or bedrock_upcoming_specified if any_specified then if java_specified then ordered_item_rows_java = q.construct_ordered_item_rows( chests, 'Java' ) end if java_upcoming_specified then ordered_item_rows_java_upcoming = q.construct_ordered_item_rows( chests, 'JavaUpcoming' ) end if bedrock_specified then ordered_item_rows_bedrock = q.construct_ordered_item_rows( chests, 'Bedrock' ) end if bedrock_upcoming_specified then ordered_item_rows_bedrock_upcoming = q.construct_ordered_item_rows( chests, 'BedrockUpcoming' ) end else local java_excluded            = args.java                and args.java == '0'; local java_upcoming_excluded   = args['java-upcoming']    and args['java-upcoming'] == '0'; local bedrock_excluded         = args.bedrock             and args.bedrock == '0'; local bedrock_upcoming_excluded = args['bedrock-upcoming'] and args['bedrock-upcoming'] == '0'; if not java_excluded then ordered_item_rows_java = q.construct_ordered_item_rows( chests, 'Java' ) end if not java_upcoming_excluded then ordered_item_rows_java_upcoming = q.construct_ordered_item_rows( chests, 'JavaUpcoming' ) end if not bedrock_excluded then ordered_item_rows_bedrock = q.construct_ordered_item_rows( chests, 'Bedrock' ) end if not bedrock_upcoming_excluded then ordered_item_rows_bedrock_upcoming = q.construct_ordered_item_rows( chests, 'BedrockUpcoming' ) end end if q.tablelength( ordered_item_rows_java ) > 0 then table.insert( ret, q.print_table( chests, columns, ordered_item_rows_java, 'Java' ) ) end if q.tablelength( ordered_item_rows_java_upcoming ) > 0 and q.compare_tables( ordered_item_rows_java, ordered_item_rows_java_upcoming ) then table.insert( ret, p.current_frame:preprocess( p['java-upcoming'] ) .. q.lcfirst( q.print_table( chests, columns, ordered_item_rows_java_upcoming, 'JavaUpcoming' ) ) ) end if q.tablelength( ordered_item_rows_bedrock ) > 0 and q.compare_tables( ordered_item_rows_java, ordered_item_rows_bedrock ) then table.insert( ret, p.current_frame:preprocess( p.bedrock ) .. q.lcfirst( q.print_table( chests, columns, ordered_item_rows_bedrock, 'Bedrock' ) ) .. '' ) end if q.tablelength( ordered_item_rows_bedrock_upcoming ) > 0 and q.compare_tables( ordered_item_rows, ordered_item_rows_bedrock_upcoming ) then table.insert( ret, p.current_frame:preprocess( p['bedrock-upcoming'] ) .. q.lcfirst( q.print_table( chests, columns, ordered_item_rows_bedrock_upcoming, 'BedrockUpcoming' ) ) .. '' ) end return table.concat( ret, '\n\n' ) end

p.doc = function

local valid_args = {} for chest_name, val in pairs(p.chests) do		local synonyms = {} for syn, orig in pairs(p.synonyms) do			if orig == chest_name then table.insert( synonyms, syn ) end end if #synonyms > 0 then chest_name = chest_name .. " ( " .. table.concat( synonyms, ", " ) .. " )" end table.insert( valid_args, chest_name ) end table.sort( valid_args ) return table.concat( valid_args, ",\n " )

end

p.doc2 = function

local valid_args = {} for column_name, val in pairs(p.columns) do table.insert( valid_args, column_name .. ": " .. val ) end table.sort( valid_args ) return table.concat( valid_args, ",\n " )

end

p.doc3 = function

local valid_args = {} for item_name, val in pairs(p.items) do		table.insert( valid_args, item_name ) end table.sort( valid_args ) return table.concat( valid_args, ", " )

end

p.base2 = function( ... )

p.current_frame = mw.getCurrentFrame

local args = { ... }	if args[1] == p.current_frame then args = require( 'Module:ProcessArgs' ).merge( true ) else args = args[1] end local itemname = args[1] if p.items[itemname] == nil then return ' unknown item "' .. itemname .. '" ' end if args.java and args.java ~= '0' then javaChances = q.single_item_find_values( itemname, 'poolsJava' ) javaUpcomingChances = {} bedrockChances = {} bedrockUpcomingChances = {} else if args['java-upcoming'] and args['java-upcoming'] ~= '0' then javaChances = q.single_item_find_values( itemname, 'poolsJavaUpcoming' ) javaUpcomingChances = {} bedrockChances = {} bedrockUpcomingChances = {} else if args.bedrock and args.bedrock ~= '0' then javaChances = q.single_item_find_values( itemname, 'poolsBedrock' ) javaUpcomingChances = {} bedrockChances = {} bedrockUpcomingChances = {} else if args['bedrock-upcoming'] and args['bedrock-upcoming'] ~= '0' then javaChances = q.single_item_find_values( itemname, 'poolsBedrockUpcoming' ) javaUpcomingChances = {} bedrockChances = {} bedrockUpcomingChances = {} else javaChances = q.single_item_find_values( itemname, 'poolsJava' ) javaUpcomingChances = q.single_item_find_values( itemname, 'poolsJavaUpcoming', javaChances ) bedrockChances = q.single_item_find_values( itemname, 'poolsBedrock', javaChances ) bedrockUpcomingChances = q.single_item_find_values( itemname, 'poolsBedrockUpcoming', javaChances, bedrockChances ) end end end end local html = {} local any_current = q.tablelength( javaChances ) > 0 local any_changes_upcoming = q.tablelength( javaUpcomingChances ) > 0 and q.compare_tables( javaChances, javaUpcomingChances ) local any_standard = any_current or any_changes_upcoming local any_bedrock_current = q.tablelength( bedrockChances ) > 0 local any_bedrock_upcoming = q.tablelength( bedrockUpcomingChances ) > 0 and q.compare_tables( bedrockChances, bedrockUpcomingChances ) local any_bedrock = any_bedrock_current or any_bedrock_upcoming local change_case = p.items[itemname].preserve_case == nil or p.items[itemname].preserve_case ~= true

if any_current then table.insert( html, p.base2_sub( itemname, javaChances ) ) end if any_changes_upcoming then table.insert( html, p.current_frame:preprocess( p['java-upcoming'] ) .. ( change_case and q.lcfirst( p.base2_sub( itemname, javaUpcomingChances, any_current ) ) or p.base2_sub( itemname, javaUpcomingChances, any_current ) ) ) end if any_bedrock_current then table.insert( html, ( any_standard and '\n\n' or '' ) .. p.current_frame:preprocess( p.bedrock ) .. ( change_case and q.lcfirst( p.base2_sub( itemname, bedrockChances, any_standard ) ) or p.base2_sub( itemname, bedrockChances, any_standard ) ) ) end if any_bedrock_upcoming then table.insert( html, ( any_standard and not any_bedrock_current and '\n\n' or '' ) .. p.current_frame:preprocess( p['bedrock-upcoming'] ) .. ( change_case and q.lcfirst( p.base2_sub( itemname, bedrockUpcomingChances, any_bedrock_current or any_standard ) ) or p.base2_sub( itemname, bedrockUpcomingChances, any_bedrock_current or any_standard ) ) ) end

if args.nocat then else table.insert( html, '' ) if p.items[itemname].category ~= nil and p.items[itemname].category ~= false then table.insert( html, '' ) end if any_bedrock then table.insert( html, '' ) end end return table.concat( html, ' ' ) end

p.base2_sub = function( itemname, chances, use_they )

local html = {} local item_display_name = '' if use_they then item_display_name = 'they' else if p.items[itemname].plural ~= nil and p.items[itemname].plural ~= false then item_display_name = p.items[itemname].plural else if p.items[itemname].title ~= nil then item_display_name = p.items[itemname].title else item_display_name = string.gsub( itemname, '-', ' ' ) end if p.items[itemname].plural == nil or p.items[itemname].plural ~= false then item_display_name = q.single_item_plural( item_display_name ) end end if p.items[itemname].preserve_case == nil or p.items[itemname].preserve_case ~= true then item_display_name = q.capitalize( item_display_name ) end if p.items[itemname].note and p.notes[p.items[itemname].note] then item_display_name = item_display_name .. p.current_frame:extensionTag( 'ref', p.notes[p.items[itemname].note], { group='note', name=p.items[itemname].note } ) end end table.insert( html, item_display_name ) table.insert( html, ' can be found ' )

local html_stacks = {} local stack_sep = ', ' local ns = q.tablelength( chances ) local s = 0

for stacksize, chest_details in pairs( chances ) do		s = s + 1 local html_per_stack = { 'in ' } local c = 0 local nc = q.tablelength( chest_details ) local sep = ( nc > 2 and ', ' or ' ' ) if nc > 2 and s ~= ns then stack_sep = '; ' end for k, chest in pairs( chest_details ) do			c = c + 1 if c == nc and nc > 1 then table.insert( html_per_stack, 'and ' ) end if chest.chance == 1 then table.insert( html_per_stack, " all " ) else table.insert( html_per_stack, string.format("%.1f", chest.chance*100) ) table.insert( html_per_stack, "% of " ) end if chest.chest_type == 'minecart with chest' then table.insert( html_per_stack, ' chest minecarts in ' ) table.insert( html_per_stack, p.chests[chest.chest_name].link ) elseif chest.chest_type == 'dispenser' then table.insert( html_per_stack, ' dispensers in ' ) table.insert( html_per_stack, p.chests[chest.chest_name].link ) else table.insert( html_per_stack, p.chests[chest.chest_name].link ) table.insert( html_per_stack, ' chests' ) end table.insert( html_per_stack, sep ) end if nc > 2 then table.insert( html_per_stack, 'all ' ) end table.insert( html_per_stack, 'in ' ) if p.items[itemname].cannot_stack ~= nil then table.insert( html_per_stack, 'groups of ' ) else table.insert( html_per_stack, 'stacks of ' ) end table.insert( html_per_stack, stacksize ) table.insert( html_stacks, table.concat( html_per_stack ) ) end local stackwise_summaries = '' if #html_stacks == 1 then table.insert( html, html_stacks[1] ) else for i = 1, #html_stacks - 1 do			table.insert( html, html_stacks[ i ] ) table.insert( html, stack_sep ) end table.insert( html, 'and ' ) table.insert( html, html_stacks[#html_stacks] ) end table.insert( html, '.' ) return table.concat( html ) end

p.base2_test = function

items = {} for item_name, v in pairs( p.items ) do table.insert( items, p.base2{ item_name, ["nocat"]=true } .. '\n\n' ) end

table.sort( items ) return table.concat(items) end

p.base3 = function( ... )

p.current_frame = mw.getCurrentFrame

local args = { ... }	if args[1] == p.current_frame then args = require( 'Module:ProcessArgs' ).merge( true ) else args = args[1] end local z = args[1] local html_java = {} local html_java_u = {} local html_bedrock = {} local html_bedrock_u = {} local rErr = "" local zT = {} if args[1] == "!!!ALL!!!" then for item_name, v in pairs( p.items ) do			table.insert( zT, item_name ) table.sort( zT ) end else zT = mw.text.split( args[1], ',' ) end for x, itemname in pairs( zT ) do		if p.items[itemname] == nil then rErr = rErr .. " Unknown item " .. itemname .. ". \n" else local javaChances, javaUpcomingChances, bedrockChances, bedrockUpcomingChances if args.java and args.java ~= '0' then javaChances = q.single_item_find_values( itemname, 'poolsJava' ) javaUpcomingChances = {} bedrockChances = {} bedrockUpcomingChances = {} else if args['java-upcoming'] and args['java-upcoming'] ~= '0' then javaChances = q.single_item_find_values( itemname, 'poolsJavaUpcoming' ) javaUpcomingChances = {} bedrockChances = {} bedrockUpcomingChances = {} else if args.bedrock and args.bedrock ~= '0' then javaChances = q.single_item_find_values( itemname, 'poolsBedrock' ) javaUpcomingChances = {} bedrockChances = {} bedrockUpcomingChances = {} else if args['bedrock-upcoming'] and args['bedrock-upcoming'] ~= '0' then javaChances = q.single_item_find_values( itemname, 'poolsBedrockUpcoming' ) javaUpcomingChances = {} bedrockChances = {} bedrockUpcomingChances = {} else javaChances = q.single_item_find_values( itemname, 'poolsJava' ) javaUpcomingChances = q.single_item_find_values( itemname, 'poolsJavaUpcoming', javaChances ) bedrockChances = q.single_item_find_values( itemname, 'poolsBedrock', javaChances ) bedrockUpcomingChances = q.single_item_find_values( itemname, 'poolsBedrockUpcoming', javaChances, bedrockChances ) end end end end local any_current = q.tablelength( javaChances ) > 0 local any_changes_upcoming = q.tablelength( javaUpcomingChances ) > 0 and q.compare_tables( javaChances, javaUpcomingChances ) local any_standard = any_current or any_changes_upcoming local any_bedrock_current = q.tablelength( bedrockChances ) > 0 local any_bedrock_upcoming = q.tablelength( bedrockUpcomingChances ) > 0 and q.compare_tables( bedrockChances, bedrockUpcomingChances ) local any_bedrock = any_bedrock_current or any_bedrock_upcoming if any_current then table.insert( html_java, p.base3_sub( itemname, javaChances ) ) end if any_changes_upcoming then table.insert( html_java_u, p.base3_sub( itemname, javaUpcomingChances ) ) end if any_bedrock_current then table.insert( html_bedrock, p.base3_sub( itemname, bedrockChances ) ) end if any_bedrock_upcoming then table.insert( html_bedrock_u, p.base3_sub( itemname, bedrockUpcomingChances ) ) end end end local output = rErr .. '{| class="wikitable sortable" \n! Item \n! Structure \n! Container \n! Quantity \n! Chance \n' .. table.concat( html_java ) if q.tablelength( html_java_u ) > 0 then output = output .. '|-\n!colspan=5|' .. p['java-upcoming'] .. ' \n' .. table.concat( html_java_u ) end if q.tablelength( html_bedrock ) > 0 then output = output .. '|-\n!colspan=5|' .. p.bedrock .. ' \n' .. table.concat( html_bedrock ) end if q.tablelength( html_bedrock_u ) > 0 then output = output .. '|-\n!colspan=5|' .. p['bedrock-upcoming'] .. ' \n' .. table.concat( html_bedrock_u ) end output = output .. '|}' .. p.current_frame:extensionTag( 'references', "", { group="note" } ) return output end

p.base3_sub = function( itemname, chances ) local html = {} local item_display_name = '' local output = "" lang = mw.getContentLanguage if p.items[itemname].title ~= nil then item_display_name = p.items[itemname].title else item_display_name = q.titlecase( string.gsub( itemname, '-', ' ' ) ) end local objectList = {} local ns = q.tablelength( chances ) local s = 0 local m = 0 local rn = 0

for stacksize, chest_details in pairs( chances ) do		s = s + 1 local nc = q.tablelength( chest_details ) local c = 0 for k, chest in pairs( chest_details ) do			c = c + 1 rn = rn + 1 local r = "" r = r .. '|' .. p.chests[chest.chest_name].container .. '\n|' .. stacksize .. '\n|' .. lang:formatNum( math.floor( chest.chance*1000 + 0.5 ) /10 ) .. ' %' .. '\n' if ns ~= s or nc ~= c then r = r 			end table.insert( objectList, { p.chests[chest.chest_name].structID , p.chests[chest.chest_name].structure, r } ) end m = m + nc	end table.sort( objectList, function(a,b) return a[1] < b[1] end ) local struct = "" local t = "" local nt = 1 local ntt = 0 for v, w in pairs( objectList ) do		ntt = ntt + 1 if w[1] ~= struct then if t ~= "" then output = output .. "|rowspan=" .. nt .. t			end t = "|'''" .. p.current_frame:expandTemplate{ title = 'EnvLink', args = { w[2], id = w[1] } } .. "'''\n" .. w[3] struct = w[1] nt = 1 else t = t .. w[3] nt = nt + 1 end if ntt == m then output = output .. "|rowspan=" .. nt .. t		else t = t .. '|-' .. '\n' end end

return "|-\n| rowspan=" .. m .. "|'''" .. p.getItem(itemname, item_display_name) .. "'''\n" .. output end

p.getItem = function( itemname, item_display_name ) local s = "" local k = item_display_name local link = item_display_name local m = itemname if p.items[itemname].title ~= nil then k = p.items[itemname].title end if p.items[itemname].link ~= nil then link = p.items[itemname].link end if p.items[itemname].id ~= nil then m = p.items[itemname].id	end if p.items[itemname][1] == "item" then s = p.current_frame:expandTemplate{ title = 'ItemLink', args = { link, k , id = m } } elseif p.items[itemname][1] == "block" then s = p.current_frame:expandTemplate{ title = 'BlockLink', args = { link, k , id = m } } end if p.items[itemname].note ~= nil and p.items[itemname].note ~= "" then s = s .. p.current_frame:extensionTag( 'ref', p.notes3[p.items[itemname].note], { group='note', name=p.items[itemname].note } ) end return s end

q = {

tablelength = function(T) local count = 0 for _ in pairs(T) do count = count + 1 end return count end, deepcopy = function(orig) local orig_type = type(orig) local copy if orig_type == 'table' then copy = {} for orig_key, orig_value in next, orig, nil do	           copy[q.deepcopy(orig_key)] = q.deepcopy(orig_value) end setmetatable(copy, q.deepcopy(getmetatable(orig))) else -- number, string, boolean, etc copy = orig end return copy end, single_item_find_values = function( itemname, poolsKey, exclusions_param, other_exclusions_param ) local chances = {} local exclusions = q.deepcopy(exclusions_param or {}) local other_exclusions = q.deepcopy(other_exclusions_param or {}) for stacksize, other_exclusion_list in pairs(other_exclusions) do			if exclusions[stacksize] == nil then exclusions[stacksize] = {} end for _, other_exclusion in pairs(other_exclusion_list) do				local already_in_here = false for _, exclusion in pairs(exclusions[stacksize]) do					if exclusion["chest_name"] == other_exclusion["chest_name"] and exclusion["chance"] == other_exclusion["chance"] then already_in_here = true break end end if not already_in_here then table.insert( exclusions[stacksize], other_exclusion ) end end end

for chest_name, chest in pairs( p.chests ) do			local poolchances = {} for k, pool in pairs( chest[poolsKey] or chest.poolsJava or {} ) do				local poolitem = pool.items[itemname] if poolitem ~= nil then local stacksize = poolitem[1] if poolitem[1] ~= poolitem[2] then stacksize = stacksize .. "–" .. poolitem[2] end local itemweight = poolitem[3] local pool_total_item_weight = 0 for itemname, item in pairs(pool.items) do						pool_total_item_weight = pool_total_item_weight + item[3] end local chance = p.calc_chance_any_of_this_item_per_pool( 						pool.rolls[1], pool.rolls[2],						itemweight, pool_total_item_weight )

if poolchances[stacksize] == nil then poolchances[stacksize] = chance else poolchances[stacksize] = poolchances[stacksize] + (1 - poolchances[stacksize]) * chance end end end for stacksize, chance in pairs( poolchances ) do				local excluded = false for _, exclusion in pairs( exclusions[stacksize] or {} ) do					if exclusion["chest_name"] == chest_name and exclusion["chance"] == chance then excluded = true break end end if not excluded then if chances[stacksize] == nil then chances[stacksize] = {} end table.insert( chances[stacksize], { ["chance"]=chance, ["chest_name"]=chest_name, ["chest_type"]=( chest.chest_type or "chest" ) } ) end end end

return chances end, single_item_plural = function( itemname ) if string.sub( itemname, -2 ) == 'ss' or string.sub( itemname, -2 ) == 'ch' or string.sub( itemname, -2 ) == 'sh' or string.sub( itemname, -1 ) == 's' then return itemname .. 'es' end return itemname .. 's'	end, massage_args = function( args )

-- find what columns to put local columns = {} for k, _arg in pairs(args) do			if p.columns[_arg] ~= nil then columns[_arg] = true end end if q.tablelength(columns) == 0 then for column_name, v in pairs(p.columns) do				columns[column_name] = true end end -- find what chests to show

local chests = {} for k, _arg in pairs(args) do			if p.chests[_arg] ~= nil then table.insert( chests, _arg ) elseif p.synonyms[_arg] ~= nil then table.insert( chests, p.synonyms[_arg] ) end if p.display_names[_arg] ~= nil then local chestname = _arg if p.chests[chestname] == nil then chestname = p.synonyms[_arg] end p.chests[chestname].display_name = p.display_names[_arg] end end if #chests == 0 then for chest_name, chest in pairs(p.chests) do				local chest_type = ( chest.chest_type or "chest" ) if chest_type == "chest" or chest_type == "minecart with chest" then table.insert( chests, chest_name ) end end end table.sort( chests ) return chests, columns end,

sort_items = function( e1, e2 ) if e1.chanceany ~= e2.chanceany then return ( e1.chanceany > e2.chanceany ) end if e1.avgamount ~= e2.avgamount then return ( e1.avgamount > e2.avgamount ) end if e1.material == nil then e1.material = 0 if string.find( e1.itemname, "leather" ) ~= nil then e1.material = 1 end if string.find( e1.itemname, "iron" ) ~= nil then e1.material = 2 end if string.find( e1.itemname, "gold" ) ~= nil then e1.material = 3 end if string.find( e1.itemname, "diamond" ) ~= nil then e1.material = 4 end e1.armor = 0 if string.find( e1.itemname, "helmet" ) ~= nil or string.find( e1.itemname, "cap" ) ~= nil then e1.armor = 1 end if string.find( e1.itemname, "chestplate" ) ~= nil or string.find( e1.itemname, "tunic" ) ~= nil then e1.armor = 2 end if string.find( e1.itemname, "leggings" ) ~= nil or string.find( e1.itemname, "pants" ) ~= nil then e1.armor = 3 end if string.find( e1.itemname, "boots" ) ~= nil then e1.armor = 4 end end if e2.material == nil then e2.material = 0 if string.find( e2.itemname, "leather" ) ~= nil then e2.material = 1 end if string.find( e2.itemname, "iron" ) ~= nil then e2.material = 2 end if string.find( e2.itemname, "gold" ) ~= nil then e2.material = 3 end if string.find( e2.itemname, "diamond" ) ~= nil then e2.material = 4 end e2.armor = 0 if string.find( e2.itemname, "helmet" ) ~= nil or string.find( e2.itemname, "cap" ) ~= nil then e2.armor = 1 end if string.find( e2.itemname, "chestplate" ) ~= nil or string.find( e2.itemname, "tunic" ) ~= nil then e2.armor = 2 end if string.find( e2.itemname, "leggings" ) ~= nil or string.find( e2.itemname, "pants" ) ~= nil then e2.armor = 3 end if string.find( e2.itemname, "boots" ) ~= nil then e2.armor = 4 end end if e1.material ~= e2.material then return ( e1.material < e2.material ) end if e1.armor ~= e2.armor then return ( e1.armor < e2.armor ) end return ( e1.itemname < e2.itemname ) end, fill_in_chest_derivative_data = function( chest_names )

for k, chest_name in pairs(chest_names) do			local chest = p.chests[chest_name] if chest == nil then break end

chest.allRollsJava = {} chest.itemDataJava = {} for k, pool in pairs( chest.poolsJava or {} ) do				table.insert( chest.allRollsJava, ( pool.rolls[1] == pool.rolls[2] and pool.rolls[1] or pool.rolls[1]..'–'..pool.rolls[2] ) )

local total_weight = 0 for itemname, item in pairs(pool.items) do					total_weight = total_weight + item[3] end pool.totalweight = total_weight

q.fill_in_chest_item_details( chest.itemDataJava, pool, #chest.allRollsJava ) end

chest.allRollsJavaUpcoming = {} chest.itemDataJavaUpcoming = {} for k, pool in pairs( chest.poolsJavaUpcoming or chest.poolsJava or {} ) do				table.insert( chest.allRollsJavaUpcoming, ( pool.rolls[1] == pool.rolls[2] and pool.rolls[1] or pool.rolls[1]..'–'..pool.rolls[2] ) )

local total_weight = 0 for itemname, item in pairs(pool.items) do					total_weight = total_weight + item[3] end pool.totalweight = total_weight

q.fill_in_chest_item_details( chest.itemDataJavaUpcoming, pool, #chest.allRollsJavaUpcoming ) end

chest.allRollsBedrock = {} chest.itemDataBedrock = {} for k, pool in pairs( chest.poolsBedrock or chest.poolsJava or {} ) do				table.insert( chest.allRollsBedrock, ( pool.rolls[1] == pool.rolls[2] and pool.rolls[1] or pool.rolls[1]..'–'..pool.rolls[2] ) )

local total_weight = 0 for itemname, item in pairs(pool.items) do					total_weight = total_weight + item[3] end pool.totalweight = total_weight

q.fill_in_chest_item_details( chest.itemDataBedrock, pool, #chest.allRollsBedrock ) end

chest.allRollsBedrockUpcoming = {} chest.itemDataBedrockUpcoming = {} for k, pool in pairs( chest.poolsBedrockUpcoming or chest.poolsJava or {} ) do				table.insert( chest.allRollsBedrockUpcoming, ( pool.rolls[1] == pool.rolls[2] and pool.rolls[1] or pool.rolls[1]..'–'..pool.rolls[2] ) )

local total_weight = 0 for itemname, item in pairs(pool.items) do					total_weight = total_weight + item[3] end pool.totalweight = total_weight

q.fill_in_chest_item_details( chest.itemDataBedrockUpcoming, pool, #chest.allRollsBedrockUpcoming ) end end end,

fill_in_chest_item_details = function( data, pool, ct ) for item_name, item in pairs(pool.items) do			if p.items[item_name] then local min_stacksize = item[1] local max_stacksize = item[2] local min_pool_rolls = pool.rolls[1] local max_pool_rolls = pool.rolls[2] local item_weight = item[3] if data[item_name] == nil then data[item_name] = { avgamount = 0, chanceany = 0, itemname = item_name, sortsize = {}, sortweight = {}, sizes = {}, weights = {}, }					for i = 1, ct-1 do						data[item_name].sortsize[i] = 0 data[item_name].sortweight[i] = 0 data[item_name].sizes[i] = '—' data[item_name].weights[i] = '—' end end

data[item_name].avgamount = data[item_name].avgamount + p.calc_average_amount_this_item_per_pool( 					min_stacksize, max_stacksize, 					min_pool_rolls, max_pool_rolls, 					item_weight, pool.totalweight ) data[item_name].chanceany = data[item_name].chanceany + (1 - data[item_name].chanceany) * p.calc_chance_any_of_this_item_per_pool(					min_pool_rolls, max_pool_rolls, 					item_weight, pool.totalweight )

data[item_name].sortsize[ct] = ( min_stacksize + max_stacksize ) / 2 data[item_name].sortweight[ct] = item_weight; data[item_name].sizes[ct] = ( min_stacksize == max_stacksize and min_stacksize or min_stacksize .. '–' .. max_stacksize ) data[item_name].weights[ct] = p.current_frame:expandTemplate{ title = 'frac', args = { item_weight, pool.totalweight } } end end

for item_name, d in pairs(data) do			if not d.sizes[ct] then d.sortsize[ct] = 0 d.sortweight[ct] = 0 d.sizes[ct] = '—' d.weights[ct] = '—' end end end,

construct_ordered_items_from_first_chest = function( chest_names, suffix ) local items_from_first_table = {} local item_chests = {} local item_names_ordered = {} for item_name, item in pairs( p.chests[chest_names[1]]['itemData'..suffix] ) do			table.insert( items_from_first_table, item ) end table.sort( items_from_first_table, q.sort_items ) for k, item in pairs( items_from_first_table ) do			table.insert( item_names_ordered, item.itemname ) item_chests[item.itemname] = true end return item_names_ordered, item_chests end,

get_ordered_items_from_other_chests = function( chest_names, item_chests, suffix ) local items_not_from_first_table = {} for chest_idx = 2, #chest_names do			for item_name, item in pairs( p.chests[chest_names[chest_idx]]['itemData'..suffix] ) do				if item_chests[item_name] == nil then p.items[item_name].itemname = item_name table.insert( items_not_from_first_table, p.chests[chest_names[chest_idx]]['itemData'..suffix][item_name] ) item_chests[item_name] = true end end end

table.sort( items_not_from_first_table, q.sort_items ) return items_not_from_first_table end,

add_other_items_to_first_list = function( chest_names, item_names_ordered, item_chests, items_not_from_first_table ) for k, item in pairs( items_not_from_first_table ) do			table.insert( item_names_ordered, item.itemname ) end return item_names_ordered end,

set_up_ordered_item_rows = function( chest_names, item_names_ordered, suffix ) for k, itemname in pairs(item_names_ordered) do			item_names_ordered[k] = {itemname} for chest_idx = 1, #chest_names do				if suffix == 'JavaUpcoming' or p.chests[chest_names[chest_idx]]['pools'..suffix] ~= nil then local item_data = p.chests[chest_names[chest_idx]]['itemData'..suffix][itemname] if item_data == nil then table.insert( item_names_ordered[k], false ) else table.insert( item_names_ordered[k], item_data ) end end end end

return item_names_ordered end,

construct_ordered_item_rows = function( chest_names, suffix ) -- for the first chest, sort its by chance desc, then by avg amount desc, then alphabetically asc local item_names_ordered, item_chests = q.construct_ordered_items_from_first_chest( chest_names, suffix ) if #chest_names > 1 then -- after that, sort all the remaining items in list order local items_not_from_first_table = q.get_ordered_items_from_other_chests( chest_names, item_chests, suffix ) item_names_ordered = q.add_other_items_to_first_list( chest_names, item_names_ordered, item_chests, items_not_from_first_table ) end

-- set up item_names_ordered so that each is a row, representing chest values item_names_ordered = q.set_up_ordered_item_rows( chest_names, item_names_ordered, suffix ) return item_names_ordered end,

print_table = function( chest_names, columns, ordered_item_rows, suffix )

local html = {} local use_roll_row = false local use_superheader = false local superheader_sizes = {} for i = 1, #chest_names do			sh = p.chests[chest_names[i]].superheader if sh ~= nil then if superheader_sizes[sh] == nil then superheader_sizes[sh] = 0 end superheader_sizes[sh] = superheader_sizes[sh] + 1 use_superheader = true end local allRolls = p.chests[chest_names[i]]['allRolls'..suffix] if #allRolls > 1 then use_roll_row = true end end if columns['stacksize'] == nil and columns['weight'] == nil then use_roll_row = false end local rowspan = ( #chest_names > 1 and 1 or 0 ) + ( use_superheader and 1 or 0 ) + 1 local hide_col_description = rowspan > 1 and q.tablelength(columns) == 1 if use_roll_row then rowspan = rowspan + 1 end if q.tablelength(columns) == 1 then for column_name, v in pairs(columns) do				table.insert( html, "Values represent " ) table.insert( html, p.columns[column_name] ) table.insert( html, "\n" ) end end

if #chest_names == 1 then if q.tablelength(columns) == 1 then table.insert( html, " " ) end local chest_name = chest_names[1] local allRolls = p.chests[chest_name]['allRolls'..suffix] local chest_type = p.chests[chest_name].chest_type or "chest"

local display_name = p.chests[chest_name].display_name

chest_name = chest_name:gsub( "-", " " ) table.insert( html, "Each " ) table.insert( html, display_name or chest_name ) if chest_type ~= 'chest' and chest_type ~= 'minecart with chest' then table.insert( html, " contains " ) else table.insert( html, " chest contains " ) end if #allRolls == 1 then table.insert( html, allRolls[1] ) table.insert( html, " item stacks, " ) else table.insert( html, ' items drawn from ' ) table.insert( html, #allRolls ) table.insert( html, ' pools, ' ) end table.insert( html, " with the following distribution: \n" ) end table.insert( html, ' \n' ) table.insert( html, " " ) return table.concat( html ) end, titlecase = function( str ) local buf = {} for word in string.gfind(str, "%S+") do			if word == "and" then table.insert( buf, word ) else local first, rest = string.sub( word, 1, 1 ), string.sub( word, 2 ) table.insert( buf, string.upper(first) .. string.lower(rest) ) end end return table.concat( buf, " " ) end, capitalize = function( str ) return ( string.lower(str):gsub( "^%l", string.upper ) ) end,

lcfirst = function( str ) return ( string.gsub( str, "^%u", string.lower ) ) end, compare_tables = function( a, b ) local seen = {} for k, v in pairs( a ) do			if type( v ) ~= type( b[k] ) then return true end if v ~= b[k] then return true end if type( v ) == 'table' and q.compare_tables( v, b[k] ) then return true end seen[k] = true end for k, v in pairs( b ) do			if not seen[k] then return true end end return false end, }

string.lpad = function(str, len, char) if char == nil then char = ' ' end return string.rep(char, len - #(''..str)) .. str end

return p