Module:LootChest2

-- -- d: data -- -- f: helper functions -- -- p: the package, exposing: --    make_item_table --    make_chest_table -- d = {

-- The key-value pairs in d.items define how the item's sprite and label are put together. -- 	-- [] = {  [, ] [, ] [, ] [, ] [, ] } -- 	--   :       This is the name used when invoking this module via p.make_item_table. --                      It is also the name used later, in the loot tables in d.chests. -- 	--   :    Whether the sprite comes from BlockSprite or ItemSprite. --      "block" --      | "item" -- 	--   :              optional: the sprite id from the sprite sheet. --                        If left unspecified, defaults to . -- 	--   :            optional: the wiki page to link to. --                        If left unspecified, defaults to , but with dashes turned to spaces, and transformed to title case. -- 	--   :           optional: the text to display. --                        If left unspecified, defaults to , but with dashes turned to spaces, and: --                            * transformed to sentence case and possibly made plural, according to the value of, in p.make_item_table, or --                            * transformed to title case, in p.make_chest_table. -- 	--   :          optional: either false, or a string having a custom plural form. --                        This affects the header text of p.make_item_table, which starts with. --                        When false, the is left as-is. --                        When a string is given, is used in place of. --                        If left unspecified, is run through f.plural. -- 	--  , :   optional: up to two notes can be specified, by key. --                        The value of the notes (its text) is defined just below here, in d.notes. -- 	-- The order within this list doesn't matter. items = { ["acacia-log"]         = { "block", link="Log" }, ["acacia-sapling"]     = { "block", link="Sapling" }, ["activator-rail"]     = { "block" }, ["ancient-debris"]     = { "block", plural=false }, ["apple"]              = { "item" }, ["arrow"]              = { "item" }, ["bamboo"]             = { "item", plural=false }, ["barrel"]             = { "block" }, ["beetroot"]           = { "item" }, ["beetroot-seeds"]     = { "item", plural=false }, ["beetroot-soup"]		= { "item", plural=false }, ["bell"]				= { "block" }, ["birch-log"]          = { "block", link="Log" }, ["birch-sapling"]      = { "block", link="Sapling" }, ["black-wool"]         = { "block", link="Wool", plural=false }, ["block-of-gold"]      = { "block", plural="Blocks of gold" }, ["blue-ice"]			= { "block", plural=false }, ["bone"]               = { "item" }, ["bone-block"]         = { "block" }, ["book"]               = { "item" }, ["book-and-quill"]     = { "item", title="Book and Quill", plural=false }, ["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" }, ["chain"]              = { "block" }, ["chainmail-boots"]    = { "item", link="Armor", plural=false }, ["chainmail-chestplate"] = { "item", link="Armor" }, ["chainmail-helmet"]   = { "item", link="Armor" }, ["chainmail-leggings"] = { "item", link="Armor", plural=false }, ["clay"]				= { "item", link="Clay (ball)", plural=false }, ["clock"]				= { "item" }, ["coal"]               = { "item", plural=false }, ["cocoa-beans"]        = { "item", plural=false }, ["cooked-cod"]         = { "item", plural=false }, ["cooked-porkchop"]		= { "item" }, ["cooked-salmon"]      = { "item", plural=false }, ["compass"]            = { "item" }, ["crimson-fungus"]		= { "block", link="Fungus", plural="Crimson fungi" }, ["crimson-nylium"]		= { "block", link="Nylium", plural=false }, ["crimson-roots"]		= { "block", link="Roots", plural=false }, ["crossbow"]           = { "item" }, ["crying-obsidian"]		= { "block" }, ["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" }, ["diamond-hoe"]        = { "item", link="Hoe" }, ["diamond-horse-armor"] = { "item", link="Horse Armor", plural=false }, ["disc-13"]            = { "item", id='music-disc-13', title="Music Disc (13)", link="Music Disc", plural="Music discs (13)" }, ["disc-cat"]           = { "item", id='music-disc-cat', title="Music Disc (cat)", link="Music Disc", plural="Music discs (cat)" }, ["disc-mellohi"]       = { "item", id='music-disc-mellohi', title="Music Disc (mellohi)", link="Music Disc", plural="Music discs (mellohi)" }, ["disc-pigstep"]		= { "item", id='music-disc-pigstep', title = "Music Disc (Pigstep)", link="Music Disc", plural="Music discs (Pigstep)" }, ["disc-wait"]          = { "item", id='music-disc-wait', title="Music Disc (wait)", link="Music Disc", plural="Music discs (wait)" }, ["egg"]          		= { "item" }, ["emerald"]            = { "item" }, ["empty-map"]          = { "item", link="Map", title="Empty Map" }, ["enchanted-book"]     = { "item", id='enchanted-book', title="Enchanted Book", link="Enchanted Book", note="enchant-with-levels-30" }, ["enchanted-book-rnd"] = { "item", id='enchanted-book', title="Enchanted Book", link="Enchanted Book", note="enchant-randomly" }, ["enchanted-book-rnd-treasure"] = { "item", id='enchanted-book', title="Enchanted Book", link="Enchanted Book", note="enchant-randomly-treasure" }, ["enchanted-book-rnd-soul-speed"] = { "item", id='enchanted-book', title="Enchanted Book", link="Enchanted Book", note="enchant-randomly-soul-speed" }, ["enchanted-fishing-rod"] = { "item", id="fishing-rod", link="Fishing Rod", note="enchant-randomly" }, ["enchanted-golden-apple"] = { "item" }, ["ender-pearl"]        = { "item" }, ["feather"]            = { "item" }, ["fern"]				= { "block", link="Grass" }, ["fire-charge"]			= { "item" }, ["flint"]              = { "item", plural=false }, ["flint-and-steel"]    = { "item", plural=false }, ["flower-pot"]			= { "item" }, ["furnace"]            = { "block" }, ["gilded-blackstone"]	= { "block", plural=false }, ["glistering-melon-slice"] = { "item" }, ["glowstone"]			= { "block", plural=false }, ["golden-apple"]       = { "item" }, ["golden-boots"]		= { "item", link="Armor", plural=false }, ["golden-carrot"]		= { "item" }, ["golden-chestplate"]  = { "item", link="Armor" }, ["golden-helmet"]      = { "item", link="Armor" }, ["golden-horse-armor"] = { "item", link="Horse Armor", plural=false }, ["golden-leggings"]		= { "item", link="Armor", plural=false }, ["golden-sword"]       = { "item", link="Sword" }, ["gold-ingot"]         = { "item" }, ["gold-nugget"]        = { "item" }, ["grass"]				= { "block", link="Grass", plural=false }, ["gray-wool"]          = { "block", link="Wool", plural=false }, ["green-dye"]			= { "item", link="Dye", plural=false }, ["gunpowder"]          = { "item", plural=false }, ["heart-of-the-sea"]   = { "item", link="Heart of the Sea", plural=false }, ["ink-sac"]            = { "item" }, ["iron-boots"]         = { "item", link="Armor", plural=false }, ["iron-chestplate"]    = { "item", link="Armor" }, ["iron-helmet"]        = { "item", link="Armor" }, ["iron-horse-armor"]   = { "item", link="Horse Armor", plural=false }, ["iron-ingot"]         = { "item" }, ["iron-leggings"]      = { "item", link="Armor", plural=false }, ["iron-nugget"]        = { "item" }, ["iron-pickaxe"]       = { "item", link="Pickaxe" }, ["iron-shovel"]        = { "item", link="Shovel" }, ["iron-sword"]         = { "item", link="Sword" }, ["jungle-log"]         = { "block", link="Log" }, ["jungle-sapling"]     = { "block", link="Sapling" }, ["lapis-lazuli"]       = { "item", plural=false }, ["large-fern"]			= { "block", link="Grass" }, ["lead"]               = { "item" }, ["leather"]     		= { "item", plural=false }, ["leather-boots"]      = { "item", link="Armor", plural=false }, ["leather-cap"]        = { "item", link="Armor" }, ["leather-pants"]      = { "item", link="Armor", plural=false }, ["leather-tunic"]      = { "item", link="Armor" }, ["light-gray-wool"]    = { "block", link="Wool", plural=false }, ["light-weighted-pressure-plate"] = { "block", link="Pressure Plate" }, ["lodestone"]			= { "block" }, ["melon-seeds"]        = { "item", plural=false }, ["magma-cream"]        = { "item", plural=false }, ["name-tag"]           = { "item" }, ["netherite-boots"]    = { "item", link="Armor", plural=false }, ["netherite-chestplate"] = { "item", link="Armor" }, ["netherite-helmet"]   = { "item", link="Armor" }, ["netherite-ingot"]    = { "item" }, ["netherite-leggings"] = { "item", link="Armor", plural=false }, ["netherite-scrap"]    = { "item", plural=false }, ["nether-wart"]        = { "item", plural=false }, ["nether-quartz"]		= { "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 }, ["piglin-banner-pattern"] = { "item", id="banner-pattern", link="Banner Pattern" }, ["poisonous-potato"]   = { "item", plural="Poisonous potatoes" }, ["poppy"]				= { "block", link="Flower", plural="Poppies" }, ["potato"]             = { "item", plural="Potatoes" }, ["potion-of-regeneration"] = { "item", link="Potion", title="Potion of Regeneration", plural="Potions of Regeneration" }, ["potion-of-water-breathing"] = { "item", link="Potion", title="Potion of Water Breathing", plural="Potions of Water Breathing" }, ["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-beef"]		   = { "item", plural=false }, ["raw-cod"]            = { "item", plural=false }, ["raw-mutton"]			= { "item", plural=false }, ["raw-porkchop"]		= { "item" }, ["raw-salmon"]         = { "item", plural=false }, ["redstone"]           = { "item", id="redstone-dust", title="Redstone Dust", plural=false }, ["rotten-flesh"]       = { "item", plural=false }, ["saddle"]             = { "item" }, ["sand"]               = { "block", plural=false }, ["shears"]             = { "item", plural=false }, ["smooth-stone"]		= { "block", plural=false }, ["snowball"]			= { "item", link="Snowball" }, ["snow-block"]			= { "block", link="Snow Block" }, ["soul-sand"]			= { "block", plural=false }, ["spectral-arrow"]     = { "item" }, ["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" }, ["stone-bricks"]       = { "block", plural=false }, ["stone-pickaxe"]      = { "item", link="Pickaxe" }, ["string"]             = { "item" }, ["suspicious-stew"]    = { "item", plural=false, note="suspicious-stew" }, ["sweet-berries"]      = { "item", plural=false }, ["tall-grass"]			= { "block", link="Grass", plural=false }, ["tnt"]                = { "block", title="TNT", plural=false }, ["torch"]              = { "block" }, ["tripwire-hook"]      = { "block" }, ["water-bucket"]       = { "item" }, ["wheat"]              = { "item" }, ["wheat-seeds"]        = { "item", plural=false }, ["white-wool"]         = { "block", link="Wool", plural=false }, ["wooden-axe"]         = { "item", link="Axe" }, ["wooden-hoe"]         = { "item", link="Hoe" }, ["wooden-pickaxe"]     = { "item", link="Pickaxe" }, ["yellow-dye"]			= { "item", link="Dye", plural=false }, ["map"]                = { "item", link="Map", note="map" },

["damaged-netherite-boots"]				= { "item", id="netherite-boots", link="Armor", plural=false, note="damaged-0.2-0.65"}, ["random-enchanted-damaged-netherite-boots"] = { "item", id="netherite-boots", title="Randomly enchanted damaged netherite boots", link="Armor", plural=false, note="enchant-randomly", note1="damaged-0.2-0.65" }, ["damaged-netherite-chestplate"]		= { "item", id="netherite-chestplate", link="Armor", note="damaged-0.2-0.65"}, ["random-enchanted-damaged-netherite-chestplate"] = { "item", id="netherite-chestplate", title="Randomly enchanted damaged netherite chestplate", link="Armor", note="enchant-randomly", note1="damaged-0.2-0.65" }, ["damaged-netherite-helmet"]			= { "item", id="netherite-helmet", link="Armor", note="damaged-0.2-0.65"}, ["random-enchanted-damaged-netherite-helmet"] = { "item", id="netherite-helmet", title="Randomly enchanted damaged netherite helmet", link="Armor", note="enchant-randomly", note1="damaged-0.2-0.65" }, ["enchanted-netherite-hoe"]				= { "item", id="netherite-hoe", link="Hoe", note="enchant-with-levels-20-39" }, ["damaged-netherite-leggings"]			= { "item", id="netherite-leggings", link="Armor", plural=false, note="damaged-0.2-0.65"}, ["random-enchanted-damaged-netherite-leggings"]	= { "item", id="netherite-leggings", title="Randomly enchanted damaged netherite leggings", plural=false, link="Armor", note="enchant-randomly", note1="damaged-0.2-0.65" }, ["random-enchanted-netherite-shovel"]	= { "item", id="netherite-shovel", title="Randomly enchanted netherite shovel", link="Shovel", note="enchant-randomly"}, ["damaged-netherite-sword"]				= { "item", id="netherite-sword", link="Sword", note="damaged-0.2-0.65"}, ["random-enchanted-damaged-netherite-shovel"] = { "item", id="netherite-shovel", title="Randomly enchanted damaged netherite shovel", link="Shovel", note="enchant-randomly", note1="damaged-0.15-0.45"}, ["random-enchanted-damaged-netherite-sword"] = { "item", id="netherite-sword", title="Randomly enchanted damaged netherite sword", link="Sword", note="enchant-randomly", note1="damaged-0.2-0.65" }, ["enchanted-diamond-boots"]				= { "item", id="diamond-boots", link="Armor", plural=false, note="enchant-with-levels-20-39" }, ["enchanted-diamond-chestplate"]		= { "item", id="diamond-chestplate", link="Armor", note="enchant-with-levels-20-39" }, ["enchanted-diamond-helmet"]			= { "item", id="diamond-helmet", link="Armor", note="enchant-with-levels-20-39" }, ["enchanted-diamond-leggings"]			= { "item", id="diamond-leggings", link="Armor", plural=false, note="enchant-with-levels-20-39" }, ["enchanted-diamond-pickaxe"]			= { "item", id="diamond-pickaxe", link="Pickaxe", note="enchant-with-levels-20-39" }, ["enchanted-diamond-shovel"]			= { "item", id="diamond-shovel", link="Shovel", note="enchant-with-levels-20-39" }, ["enchanted-diamond-sword"]				= { "item", id="diamond-sword", link="Sword", note="enchant-with-levels-20-39" }, ["enchanted-iron-boots"]				= { "item", id="iron-boots", link="Armor", plural=false, note="enchant-with-levels-20-39" }, ["enchanted-iron-chestplate"]			= { "item", id="iron-chestplate", link="Armor", note="enchant-with-levels-20-39" }, ["enchanted-iron-helmet"]				= { "item", id="iron-helmet", link="Armor", note="enchant-with-levels-20-39" }, ["enchanted-iron-leggings"]				= { "item", id="iron-leggings", link="Armor", plural=false, note="enchant-with-levels-20-39" }, ["enchanted-iron-pickaxe"]				= { "item", id="iron-pickaxe", link="Pickaxe", note="enchant-with-levels-20-39" }, ["enchanted-iron-shovel"]				= { "item", id="iron-shovel", link="Shovel", note="enchant-with-levels-20-39" }, ["enchanted-iron-sword"]				= { "item", id="iron-sword", link="Sword", note="enchant-with-levels-20-39" }, ["random-enchanted-golden-axe"]			= { "item", id="golden-axe", title="Randomly enchanted golden axe", link="Axe", note="enchant-randomly" }, ["enchanted-golden-boots"]     		= { "item", id="golden-boots", link="Armor", plural=false, note="enchant-with-levels-20-39" }, ["random-enchanted-golden-boots"]		= { "item", id="golden-boots", title="Randomly enchanted golden boots", link="Armor", plural=false, note="enchant-randomly" }, ["enchanted-golden-boots-soul-speed"]  = { "item", id="golden-boots", title="Golden boots enchanted with Soul Speed", link="Armor", plural=false, note="enchant-randomly-soul-speed" }, ["enchanted-golden-chestplate"]			= { "item", id="golden-chestplate", link="Armor", note="enchant-with-levels-20-39" }, ["random-enchanted-golden-chestplate"]	= { "item", id="golden-chestplate", title="Randomly enchanted golden chestplate", link="Armor", note="enchant-randomly" }, ["enchanted-golden-helmet"]				= { "item", id="golden-helmet", link="Armor", note="enchant-with-levels-20-39" }, ["random-enchanted-golden-helmet"]		= { "item", id="golden-helmet", title="Randomly enchanted golden helmet", link="Armor", note="enchant-randomly" }, ["enchanted-golden-hoe"]				= { "item", id="golden-hoe", link="Hoe", note="enchant-with-levels-20-39" }, ["random-enchanted-golden-hoe"]			= { "item", id="golden-hoe", title="Randomly enchanted golden hoe", link="Hoe", note="enchant-randomly" }, ["enchanted-golden-leggings"]			= { "item", id="golden-leggings", link="Armor", plural=false, note="enchant-with-levels-20-39" }, ["random-enchanted-golden-leggings"]	= { "item", id="golden-leggings", title="Randomly enchanted golden leggings", link="Armor", plural=false, note="enchant-randomly" }, ["random-enchanted-golden-pickaxe"]		= { "item", id="golden-pickaxe", title="Randomly enchanted golden pickaxe", link="Pickaxe", note="enchant-randomly" }, ["random-enchanted-golden-shovel"]		= { "item", id="golden-shovel", title="Randomly enchanted golden shovel", link="Shovel", note="enchant-randomly" }, ["random-enchanted-golden-sword"]		= { "item", id="golden-sword", title="Randomly enchanted golden sword", link="Sword", note="enchant-randomly" }, ["random-enchanted-leather-boots"]		= { "item", id="leather-boots", title="Randomly enchanted leather boots", link="Armor", plural=false, note="enchant-randomly" }, ["random-enchanted-leather-cap"]		= { "item", id="leather-cap", title="Randomly enchanted leather cap", link="Armor", note="enchant-randomly" }, ["random-enchanted-leather-pants"]		= { "item", id="leather-pants", title="Randomly enchanted leather pants", link="Armor", plural=false, note="enchant-randomly" }, ["random-enchanted-leather-tunic"]		= { "item", id="leather-tunic", title="Randomly enchanted leather tunic", link="Armor", note="enchant-randomly" }, ["random-enchanted-damaged-crossbow"]	= { "item", id="crossbow", title="Randomly enchanted damaged crossbow", link="Crossbow", note="enchant-randomly", note1="damaged-0.1-0.5" },

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

-- The key-value pairs in d.notes define the text that goes into an item's note, to be displayed in a notelist. -- 	-- It gets rendered on the page like so: --  -- 	-- The order within this list doesn't matter. notes = { ["damaged-0.1-0.5"] =            "The item will only have between 10% and 50% of its total durability.", ["damaged-0.15-0.45"] =          "The item will only have between 15% and 45% of its total durability.", ["damaged-0.2-0.65"] =           "The item will only have between 20% and 65% of its total durability.", ["enchant-randomly"] =           "All enchantments are equally probable, except treasure enchantments, and any level of the enchantment is equally probable.", ["enchant-randomly-soul-speed"] = "Enchanted with a random level of Soul Speed.", ["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.", ["map"] =                        "Named unknown map, but changed to map 0, the scale level is 1:4, Maps from the same stack are stackable, but maps that are not stacked are unstackable despite looking identical.", ["nothing"] =                    "'Nothing' does not refer to the chance of an empty chest.  Instead, it refers to the chance that the random loot generator does not add any loot on a single roll.", ["suspicious-stew"] =            "The stew grants one of the following effects: 5–7 seconds of Blindness, 7–10 seconds of Jump Boost, 7-10 seconds of Night Vision, 10–20 seconds of Poison, 7–10 seconds of Saturation, or 6–8 seconds of Weakness." },

-- The key-value pairs in d.column_hovertext define the hovertext that goes onto a column header, using the tag. column_hovertext = { ["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.' },		-- The key-value pairs in d.chests define the loot tables. -- 	-- [] = { --   chest_table_display = { header = [, superheader = ] }, --   item_table_display  = { structure_id = , structure_text =  [, container = ] }, --   loot_tables = {  [, ] ... }	-- }	-- 	--   :      This is the name used when invoking this module via p.make_chest_table. -- 	--   :          When invoking this module via p.make_chest_table with multiple chests, this is a column header with the name of the chest. --                        This header spans all columns generated for this chest. --   :     optional: When invoking this module via p.make_chest_table with multiple chests, this is a column header with the name of the structure. --                        This header spans all columns generated for ALL chests having the same superheader, and sits above the chest header. --                        Typically you use this when one structure has multiple kinds of chests. --                        If left unspecified, the chest will not group with other chests under any superheader. -- 	--   <structure-id>:    When invoking this module via p.make_item_table, this id determines the sprite from. --   <structure-text>:  When invoking this module via p.make_item_table, this is the text next to the structure sprite. --   :       optional: When invoking this module via p.make_item_table, --                        Typically you use this when one structure has multiple kinds of chests. --                        If left unspecified, the chest entry will just show the structure link, and will not show any subtitle specifying a chest. -- 	--   <loot-table>: {    <loot-table> has the meaning: for the editions listed, use these loot_tables. --      <edition-list>,   The first element is an <edition-list>, --      ...        The rest are elements. --   }	-- 	--    <edition-list>:    A list of 1 or more elements. --   {	--       	--       [, ]	--       ...	--    }	-- 	--    :         These are the possible editions. For chests at parity, use: {"java","bedrock"} --      "java" --      | "bedrock" --      | "java-upcoming" --      | "bedrock-upcoming" -- 	--   : 	--    {	--       rolls = { <min-rolls>, <max-rolls> },  Each pool contains a min and a max number of "rolls", --      items = {                              and a list of 1 or more <item-entry> elements. --         <item-entry> --         [, <item-entry>] --         ...	--       }	--    }	-- 	--    <min-rolls>:       For each pool in a loot table, the game "rolls" (picks a random entry from the list of items) some number of times: between <min-rolls> and <max-rolls>. --   <max-rolls>:       See above. -- 	--   <item-entry>: --      [<item-name>] = { <min-stack-size>, <max-stack-size>, } -- 	--   <item-name>:       This name refers to (and must match) an entry in d.items. -- 	--   <min-stack-size>:  When the game picks this item, it chooses a stack size between <min-stack-size> and <max-stack-size>. --   <max-stack-size>:  See above. -- 	--   :          When the game does a "roll" in pool, each item may have its own "weight", so that higher weights are more likely to be picked. -- 	-- The order within this list doesn't matter. --  in the item table, sorting is alphabetical by <structure_text>, then by. --  in the chest table, items will sort by chance, then by avg#, then alphabetically. chests = { ["shipwreck-map"] = { -- shipwreck_map.json chest_table_display = { header="Map", superheader="Shipwreck" }, item_table_display = { structure_id="shipwreck", structure_text="Shipwreck", container="Map chest" }, loot_tables = { {					-- "java", "java-upcoming", "bedrock", "bedrock-upcoming" {"java"}, {						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}, }					},				},				{					{"bedrock"}, {						rolls = {1,1}, items = { ["buried-treasure-map"] = {1,1,1}, }					},					{						rolls = {3,3}, items = { ["compass"]            = {1,1,1}, ["map"]                = {1,1,1}, ["clock"]              = {1,1,1}, ["paper"]              = {1,10,20}, ["feather"]            = {1,5,10}, ["book"]               = {1,5,5}, }					},				},			}		},		["shipwreck-supply"] = { -- shipwreck_supply.json chest_table_display = { header="Supply", superheader="Shipwreck" }, item_table_display = { structure_id="shipwreck", structure_text="Shipwreck", container="Supply chest" }, loot_tables = { {					{"java","bedrock"}, {						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}, ["random-enchanted-leather-cap"]        = {1,1,3}, ["random-enchanted-leather-tunic"]      = {1,1,3}, ["random-enchanted-leather-pants"]      = {1,1,3}, ["random-enchanted-leather-boots"]      = {1,1,3}, }					},				},			}		},		["shipwreck-treasure"] = { -- shipwreck_treasure.json chest_table_display = { header="Treasure", superheader="Shipwreck" }, item_table_display = { structure_id="shipwreck", structure_text="Shipwreck", container="Treasure chest" }, loot_tables = { {					{"java","bedrock"}, {						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}, }					},				},			}		},		["buried-treasure"] = { -- buried_treasure.json chest_table_display = { header="Buried treasure" }, item_table_display = { structure_id="buried-treasure", structure_text="Buried treasure" }, loot_tables = { {					{"java"}, {						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}, }					},				},				{					{"bedrock"}, {						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}, }					},				},			}		},		["underwater-ruin-big"] = { -- underwater_ruin_big.json chest_table_display = { header="Big", superheader="Underwater ruins" }, item_table_display = { structure_id="underwater-ruins", structure_text="Underwater ruins", container="Big chest" }, loot_tables = { {					{"java","bedrock"}, {						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}, }					},				},			}		},		["underwater-ruin-small"] = { -- underwater_ruin_small.json chest_table_display = { header="Small", superheader="Underwater ruins" }, item_table_display = { structure_id="underwater-ruins", structure_text="Underwater ruins", container="Small chest" }, loot_tables = { {					{"java","bedrock"}, {						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}, }					},				},			}		},		["village-armorer"] = { -- village\village_armorer.json chest_table_display = { header="Armorer", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Armorer's chest" }, loot_tables = { {					{"java","bedrock"}, {						rolls = {1,5}, items = { ["iron-ingot"]    = {1,3,2}, ["bread"]         = {1,4,4}, ["iron-helmet"]   = {1,1,1}, ["emerald"]       = {1,1,1} }					},				},			},		},		["village-butcher"] = { -- village\village_butcher.json chest_table_display = { header="Butcher", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Butcher's chest" }, loot_tables = { {					{"java","bedrock"}, {						rolls = {1,5}, items = { ["emerald"]       = {1,1,1}, ["raw-porkchop"]  = {1,3,6}, ["wheat"]         = {1,3,6}, ["raw-beef"]      = {1,3,6}, ["raw-mutton"]    = {1,3,6}, ["coal"]          = {1,3,3} }					},				},			},		},		["village-cartographer"] = { -- village\village_cartographer.json chest_table_display = { header="Cartographer", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Cartographer's chest" }, loot_tables = { {					{"java"}, {						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} }					},				},				{					{"bedrock"}, {						rolls = {1,5}, items = { ["map"]           = {1,3,10}, ["paper"]         = {1,5,15}, ["compass"]       = {1,1,5}, ["bread"]         = {1,4,15}, ["oak-sapling"]   = {1,2,5} }					},				},			},		},		["village-fisherman"] = { -- village\village_fisher.json, Java-exclusive as of Java 1.14 / Bedrock 1.12 chest_table_display = { header="Fisherman", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Fisherman's chest" }, loot_tables = { {					{"java"}, {						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} }					},				},			},		},		["village-fletcher"] = { -- village\village_fletcher.json chest_table_display = { header="Fletcher", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Fletcher's chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-mason"] = { -- village\village_mason.json chest_table_display = { header="Mason", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Mason's chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-shepherd"] = { -- village\village_shepherd.json chest_table_display = { header="Shepherd", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Shepherd's chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-tannery"] = { -- village\village_tannery.json chest_table_display = { header="Tannery", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Tanner's chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-temple"] = { -- village\village_temple.json chest_table_display = { header="Temple", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Temple chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-toolsmith"] = { -- village\village_toolsmith.json chest_table_display = { header="Toolsmith", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Toolsmith's chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-weaponsmith"] = { -- village\village_weaponsmith.json chest_table_display = { header="Weaponsmith", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Weaponsmith's chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-desert-house"] = { -- village\village_desert_house.json chest_table_display = { header="Desert House", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Desert house chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-plains-house"] = { -- village\village_plains_house.json chest_table_display = { header="Plains house", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Plains house chest" }, loot_tables = { {					{"java","bedrock"}, {						rolls = {3,8}, items = { ["gold-nugget"]    = {1,3,1}, ["dandelion"]      = {1,1,2}, ["poppy"]          = {1,1,1}, ["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} }					},				},			},		},		["village-savanna-house"] = { -- village\village_savanna_house.json chest_table_display = { header="Savanna House", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Savanna house chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-snowy-house"] = { -- village\village_snowy_house.json chest_table_display = { header="Snowy House", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Snowy house chest" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["village-taiga-house"] = { -- village\village_taiga_house.json chest_table_display = { header="Taiga House", superheader="Village" }, item_table_display = { structure_id="village", structure_text="Village", container="Taiga house chest" }, loot_tables = { {					{"java"}, {						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} }					},				},				{					{"bedrock"}, {						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} }					},				},			},		},		["stronghold-altar"] = { -- stronghold_corridor.json chest_table_display = { header="Altar", superheader="Stronghold" }, item_table_display = { structure_id="stronghold", structure_text="Stronghold", container="Altar chest" }, loot_tables = { {					{"java"}, {						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}, }					},				},				{					{"bedrock"}, {						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}, }					},				},			},		},		["stronghold-library"] = { -- stronghold_library.json chest_table_display = { header="Library", superheader="Stronghold" }, item_table_display = { structure_id="stronghold", structure_text="Stronghold", container="Library chest" }, loot_tables = { {					{"java"}, {						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}, }					},				},				{					{"bedrock"}, {						rolls = {2,10}, items = { ["book"]               = {1,3,100}, ["paper"]              = {2,7,100}, ["map"]                = {1,1,5}, ["compass"]            = {1,1,5}, ["enchanted-book"]     = {1,1,60}, }					},				},			},		},		["stronghold-storeroom"] = { -- stronghold_crossing.json chest_table_display = { header="Storeroom", superheader="Stronghold" }, item_table_display = { structure_id="stronghold", structure_text="Stronghold", container="Storeroom chest" }, loot_tables = { {					{"java"}, {						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}, }					},				},				{					{"bedrock"}, {						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}, }					},				},			},		},		["bonus"] = { -- spawn_bonus_chest.json chest_table_display = { header="Bonus" }, item_table_display = { structure_id="day", structure_text="Bonus chest" }, loot_tables = { {					{"java"}, {						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}, }					},				},				{					{"bedrock"}, {						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,4}, ["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,2}, }					},					{						rolls = {1,1}, items = { ["brown-mushroom"]             = {1,2,2}, }					},				},			},		},		["dungeon"] = { -- simple_dungeon.json chest_table_display = { header="Dungeon" }, item_table_display = { structure_id="dungeon", structure_text="Dungeon" }, loot_tables = { {					{"java","bedrock"}, {						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}, }					},				},			},		},		["mineshaft"] = { -- abandoned_mineshaft.json chest_table_display = { header="Mineshaft" }, item_table_display = { structure_id="abandoned-mineshaft", structure_text="Mineshaft" }, loot_tables = { {					{"java","bedrock"}, {						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}, }					},				},			},		},		["nether-fortress"] = { -- nether_bridge.json chest_table_display = { header="Nether fortress" }, item_table_display = { structure_id="nether-fortress", structure_text="Nether fortress" }, loot_tables = { {					{"java","bedrock"}, {						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}, }					},				},			},		},		["desert-temple"] = { -- desert_pyramid.json chest_table_display = { header="Desert temple" }, item_table_display = { structure_id="desert-temple", structure_text="Desert temple" }, loot_tables = { {					{"java","bedrock"}, {						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}, }					},				},			},		},		["jungle-temple"] = { -- jungle_temple.json chest_table_display = { header="Chest", superheader="Jungle temple" }, item_table_display = { structure_id="jungle-temple", structure_text="Jungle temple", container="Chest" }, loot_tables = { {					{"java"}, {						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} }					},				},				{					{"bedrock"}, {						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} }					},				},			},		},		["jungle-temple-dispenser"] = { -- jungle_temple_dispenser.json chest_table_display = { header="Dispenser", superheader="Jungle temple" }, item_table_display = { structure_id="jungle-temple", structure_text="Jungle temple", container="Dispenser" }, loot_tables = { {					{"java"}, {						rolls = {1,2}, items = { ["arrow"] = {2,7,30} }					},				},				{					{"bedrock"}, {						rolls = {2,2}, items = { ["arrow"] = {2,7,30} }					},				},			},		},		["end-city"] = { -- end_city_treasure.json chest_table_display = { header="End city" }, item_table_display = { structure_id="end-city", structure_text="End city" }, loot_tables = { {					{"java","bedrock"}, {						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}, }					},				},			},		},		["igloo"] = { chest_table_display = { header="Igloo" }, item_table_display = { structure_id="igloo", structure_text="Igloo" }, loot_tables = { {					{"java","bedrock"}, {						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}, }					},				},			},		},		["pillager-outpost"] = { chest_table_display = { header="Pillager outpost" }, item_table_display = { structure_id="pillager-outpost", structure_text="Pillager outpost" }, loot_tables = { {					{"java","bedrock"}, {						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} }					},				},			},		},		["bastion-bridge"] = { -- bastion_bridge.json chest_table_display = { header="Bridge", superheader="Bastion remnant" }, item_table_display = { structure_id="bastion-remnant", structure_text="Bastion remnant", container="Bridge chest" }, loot_tables = { {					{"java-upcoming","bedrock-upcoming"}, {						rolls = {1,1}, items = { ["lodestone"] = {1,1,1}, }					},					{						rolls = {1,2}, items = { ["spectral-arrow"] = {5,18,1}, ["gilded-blackstone"] = {5,10,1}, ["crying-obsidian"] = {3,8,1}, ["block-of-gold"] = {1,1,1}, ["gold-ingot"] = {2,8,1}, ["iron-ingot"] = {2,8,1}, ["golden-sword"] = {1,1,1}, ["random-enchanted-golden-chestplate"] = {1,1,1}, ["random-enchanted-golden-helmet"] = {1,1,1}, ["random-enchanted-golden-leggings"] = {1,1,1}, ["random-enchanted-golden-boots"] = {1,1,1}, }					},					{						rolls = {2,4}, items = { ["string"] = {1,6,1}, ["leather"] = {1,3,1}, ["arrow"] = {5,17,1}, ["iron-nugget"] = {2,6,1}, ["gold-nugget"] = {2,6,1}, }					}				},			},		},		["bastion-hoglin-stable"] = { -- bastion_hoglin_stable.json chest_table_display = { header="Hoglin stable", superheader="Bastion remnant" }, item_table_display = { structure_id="bastion-remnant", structure_text="Bastion remnant", container="Hoglin stable chest" }, loot_tables = { {					{"java-upcoming","bedrock-upcoming"}, {						rolls = {1,1}, items = { ["random-enchanted-damaged-netherite-shovel"] = {1,1,10}, ["netherite-scrap"] = {1,1,10}, ["ancient-debris"] = {1,1,10}, ["saddle"] = {1,1,15}, ["block-of-gold"] = {2,4,10}, ["random-enchanted-golden-hoe"] = {1,1,10}, ["empty"] = {1,1,10}, }					},					{						rolls = {3,4}, items = { ["glowstone"] = {1,5,1}, ["gilded-blackstone"] = {1,5,1}, ["soul-sand"] = {2,7,1}, ["crimson-nylium"] = {2,7,1}, ["gold-nugget"] = {2,8,1}, ["leather"] = {1,3,1}, ["arrow"] = {5,17,1}, ["string"] = {3,8,1}, ["raw-porkchop"] = {2,5,1}, ["cooked-porkchop"] = {2,5,1}, ["crimson-fungus"] = {2,7,1}, ["crimson-roots"] = {2,7,1}, }					},				},			},		},		["bastion-other"] = { -- bastion_other.json chest_table_display = { header="Other", superheader="Bastion remnant" }, item_table_display = { structure_id="bastion-remnant", structure_text="Bastion remnant", container="Other chest" }, loot_tables = { {					{"java-upcoming","bedrock-upcoming"}, {						rolls = {1,1}, items = { ["random-enchanted-damaged-crossbow"] = {1,1,10}, ["ancient-debris"] = {1,1,5}, ["netherite-scrap"] = {1,1,5}, ["spectral-arrow"] = {5,20,10}, ["piglin-banner-pattern"] = {1,1,10}, ["disc-pigstep"] = {1,1,10}, ["empty"] = {1,1,10}, }					},					{						rolls = {2,2}, items = { ["enchanted-book-rnd-soul-speed"] = {1,1,1}, ["enchanted-golden-boots-soul-speed"] = {1,1,1}, ["block-of-gold"] = {1,1,1}, ["crossbow"] = {1,1,1}, ["gold-ingot"] = {1,6,1}, ["iron-ingot"] = {1,6,1}, ["golden-sword"] = {1,1,1}, ["golden-chestplate"] = {1,1,1}, ["golden-helmet"] = {1,1,1}, ["golden-leggings"] = {1,1,1}, ["golden-boots"] = {1,1,1}, ["empty"] = {1,1,2}, }					},					{						rolls = {3,5}, items = { ["crying-obsidian"] = {1,5,1}, ["gilded-blackstone"] = {1,5,1}, ["chain"] = {2,10,1}, ["magma-cream"] = {2,6,1}, ["bone-block"] = {2,6,1}, ["iron-nugget"] = {2,8,1}, ["obsidian"] = {4,6,1}, ["gold-nugget"] = {2,8,1}, ["string"] = {4,6,1}, ["arrow"] = {5,17,2}, }					},				},			},		},		["bastion-treasure"] = { -- bastion_treasure.json chest_table_display = { header="Treasure", superheader="Bastion remnant" }, item_table_display = { structure_id="bastion-remnant", structure_text="Bastion remnant", container="Treasure chest" }, loot_tables = { {					{"java-upcoming","bedrock-upcoming"}, {						rolls = {1,1}, items = { ["netherite-ingot"] = {1,1,10}, ["ancient-debris"] = {1,1,10}, ["netherite-scrap"] = {1,1,10}, ["ancient-debris"] = {2,2,5}, ["random-enchanted-damaged-netherite-sword"] = {1,1,10}, ["random-enchanted-damaged-netherite-chestplate"] = {1,1,6}, ["random-enchanted-damaged-netherite-helmet"] = {1,1,6}, ["random-enchanted-damaged-netherite-leggings"] = {1,1,6}, ["random-enchanted-damaged-netherite-boots"] = {1,1,6}, ["damaged-netherite-sword"] = {1,1,6}, ["damaged-netherite-chestplate"] = {1,1,5}, ["damaged-netherite-helmet"] = {1,1,5}, ["damaged-netherite-leggings"] = {1,1,5}, ["damaged-netherite-boots"] = {1,1,5}, ["diamond"] = {1,3,5}, }					},					{						rolls = {2,4}, items = { ["spectral-arrow"] = {5,21,1}, ["block-of-gold"] = {2,5,1}, ["gold-ingot"] = {3,9,1}, ["iron-ingot"] = {3,9,1}, ["crying-obsidian"] = {1,5,1}, ["nether-quartz"] = {8,23,1}, ["gilded-blackstone"] = {1,5,1}, ["magma-cream"] = {2,8,1}, ["iron-nugget"] = {8,16,1}, }					},				},			},		},		["ruined-portal"] = { --ruined_portal.json chest_table_display = { header="Ruined portal" }, item_table_display = { structure_id="ruined-portal", structure_text="Ruined portal" }, loot_tables = { {					{"java-upcoming","bedrock-upcoming"}, {						rolls = {4,8}, items = { ["obsidian"] = {1,2,40}, ["flint"] = {1,4,40}, ["iron-nugget"] = {9,18,40}, ["flint-and-steel"] = {1,1,40}, ["fire-charge"] = {1,1,40}, ["golden-apple"] = {1,1,40}, ["gold-nugget"] = {4,24,15}, ["random-enchanted-golden-sword"] = {1,1,15}, ["random-enchanted-golden-axe"] = {1,1,15}, ["random-enchanted-golden-hoe"] = {1,1,15}, ["random-enchanted-golden-pickaxe"] = {1,1,15}, ["random-enchanted-golden-shovel"] = {1,1,15}, ["random-enchanted-golden-helmet"] = {1,1,15}, ["random-enchanted-golden-chestplate"] = {1,1,15}, ["random-enchanted-golden-leggings"] = {1,1,15}, ["random-enchanted-golden-boots"] = {1,1,15}, ["glistering-melon-slice"] = {4,13,5}, ["golden-horse-armor"] = {1,1,5}, ["light-weighted-pressure-plate"] = {1,1,5}, ["golden-carrot"] = {4,12,5}, ["clock"] = {1,1,5}, ["gold-ingot"] = {2,8,5}, ["bell"] = {1,1,1}, ["enchanted-golden-apple"] = {1,1,1}, ["block-of-gold"] = {1,2,1}, }					},				},			},		},		["woodland-mansion"] = { -- woodland_mansion.json chest_table_display = { header="Woodland mansion" }, item_table_display = { structure_id="woodland-mansion", structure_text="Woodland mansion" }, loot_tables = { {					{"java"}, {						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}, }					},				},				{					{"bedrock"}, {						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}, }					},				},			},		},	} }

f = {

-- this math is at the top simply for ease of inspection. 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, get_item = function( item_key, item_display_name ) local html = {} local item_title = item_display_name local item_link = item_display_name local item_id = item_key local sprite_type = d.items[item_key][1] local note_key = d.items[item_key].note local note_key_1 = d.items[item_key].note1 if d.items[item_key].title ~= nil then item_title = d.items[item_key].title end if d.items[item_key].link ~= nil then item_link = d.items[item_key].link end if d.items[item_key].id ~= nil then item_id = d.items[item_key].id		end if sprite_type == "item" or sprite_type == "block" then table.insert( html, p.current_frame:expandTemplate{ title = f.title_case(sprite_type) .. 'Link', args = { item_link, item_title , id = item_id } } ) end if note_key ~= nil and d.notes[note_key] ~= nil then table.insert( html, p.current_frame:extensionTag( 'ref', d.notes[note_key], { group='note', name=note_key } ) ) end if note_key_1 ~= nil and d.notes[note_key_1] ~= nil then if note_key == nil or d.notes[note_key] == nil or note_key ~= note_key_1 then table.insert( html, p.current_frame:extensionTag( 'ref', d.notes[note_key_1], { group='note', name=note_key_1 } ) ) end end return table.concat( html ) end, find_chances_for_items = function( item_names ) local chances = {} local lang = mw.getContentLanguage for chest_name, chest in pairs(d.chests) do			for _, loot_table in pairs(chest.loot_tables or {}) do				local chest_has_java = false local chest_has_java_upcoming = false local chest_has_bedrock = false local chest_has_bedrock_upcoming = false for _, edition in pairs(loot_table[1]) do					chest_has_java = chest_has_java or edition == 'java' chest_has_java_upcoming = chest_has_java_upcoming or edition == 'java-upcoming' chest_has_bedrock = chest_has_bedrock or edition == 'bedrock' chest_has_bedrock_upcoming = chest_has_bedrock_upcoming or edition == 'bedrock-upcoming' end if chest_has_java and not chest_has_java_upcoming then table.insert( loot_table[1], 'java-upcoming' ) end if chest_has_bedrock and not chest_has_bedrock_upcoming then table.insert( loot_table[1], 'bedrock-upcoming' ) end for _, item_name in pairs(item_names) do					local loot_table_chances_per_stacksize = {} for pool_idx, pool in pairs(loot_table) do						if pool_idx > 1 then local item_numbers = pool.items[item_name] if item_numbers ~= nil then local stack_size_min = item_numbers[1] local stack_size_max = item_numbers[2] local stack_size = stack_size_min if stack_size_min ~= stack_size_max then stack_size = stack_size_min .. "–" .. stack_size_max end local item_weight = item_numbers[3] local pool_total_item_weight = 0 for item_name, item in pairs(pool.items) do									pool_total_item_weight = pool_total_item_weight + item[3] end local chance = f.round( f.calc_chance_any_of_this_item_per_pool( pool.rolls[1], pool.rolls[2], item_weight, pool_total_item_weight ), 3 ) if loot_table_chances_per_stacksize[stack_size] == nil then loot_table_chances_per_stacksize[stack_size] = chance else loot_table_chances_per_stacksize[stack_size] = loot_table_chances_per_stacksize[stack_size] + (1 - loot_table_chances_per_stacksize[stack_size]) * chance end end end end for stack_size, chance in pairs( loot_table_chances_per_stacksize ) do local key = item_name .. '/' .. chest_name .. '/' .. lang:formatNum( chance * 100 ) .. '/' .. stack_size if chances[key] == nil then chances[key] = {} end for _, edition in pairs(loot_table[1]) do							chances[key][edition] = true end end end end end return chances end, -- this is so cell templates only get expanded once. java_upcoming_v_expanded = nil, bedrock_upcoming_v_expanded = nil, java_upcoming_expanded = nil, java_until_expanded = nil, bedrock_upcoming_expanded = nil, bedrock_until_expanded = nil, yes_expanded = nil, no_expanded = nil, planned_expanded = nil, unknown_expanded = nil, needs_testing_expanded = nil, java_upcoming_cell = function if f.java_upcoming_v_expanded == nil then f.java_upcoming_v_expanded = p.current_frame:expandTemplate{ title = 'v', args = { 'java-upcoming', link = 'none' } } end if f.java_upcoming_expanded == nil then f.java_upcoming_expanded = p.current_frame:expandTemplate{ title = 'Upcoming', args = { 'JE ' .. f.java_upcoming_v_expanded } } end return f.java_upcoming_expanded end, java_until_cell = function if f.java_upcoming_v_expanded == nil then f.java_upcoming_v_expanded = p.current_frame:expandTemplate{ title = 'v', args = { 'java-upcoming', link = 'none' } } end if f.java_until_expanded == nil then f.java_until_expanded = p.current_frame:expandTemplate{ title = 'Until', args = { 'JE ' .. f.java_upcoming_v_expanded } } end return f.java_until_expanded end, bedrock_upcoming_cell = function if f.bedrock_upcoming_v_expanded == nil then f.bedrock_upcoming_v_expanded = p.current_frame:expandTemplate{ title = 'v', args = { 'bedrock-upcoming', link = 'none' } } end if f.bedrock_upcoming_expanded == nil then f.bedrock_upcoming_expanded = p.current_frame:expandTemplate{ title = 'Upcoming', args = { 'BE ' .. f.bedrock_upcoming_v_expanded } } end return f.bedrock_upcoming_expanded end, bedrock_until_cell = function if f.bedrock_upcoming_v_expanded == nil then f.bedrock_upcoming_v_expanded = p.current_frame:expandTemplate{ title = 'v', args = { 'bedrock-upcoming', link = 'none' } } end if f.bedrock_until_expanded == nil then f.bedrock_until_expanded = p.current_frame:expandTemplate{ title = 'Until', args = { 'BE ' .. f.bedrock_upcoming_v_expanded } } end return f.bedrock_until_expanded end, yes_cell = function if f.yes_expanded == nil then f.yes_expanded = p.current_frame:expandTemplate{ title = 'Table Choice', args = { 'Yes' } } end return f.yes_expanded end, no_cell = function if f.no_expanded == nil then f.no_expanded = p.current_frame:expandTemplate{ title = 'Table Choice', args = { 'No' } } end return f.no_expanded end, planned_cell = function if f.planned_expanded == nil then f.planned_expanded = p.current_frame:expandTemplate{ title = 'Table Choice', args = { 'Planned', 'Yes' } } end return f.planned_expanded end, -- not currently used. unknown_cell = function if f.needs_testing_expanded == nil then f.needs_testing_expanded = p.current_frame:expandTemplate{ title = 'needs testing', args = { 'This loot information has not been tested, in this edition.' } } end if f.unknown_expanded == nil then f.unknown_expanded = p.current_frame:expandTemplate{ title = 'Table Choice', args = { 'Unknown' } } .. ' ' .. f.needs_testing_expanded end return f.unknown_expanded end,

has_entries = function(_table) for _ in pairs(_table) do 			return true end return false end,

has_one_entry = function(_table) local first = false local second = false for _ in pairs(_table) do			if first then second = true end first = true if first and second then return false end end return first and not second end,

round = function(num, num_decimal_places) local mult = 10^(num_decimal_places or 0) return math.floor(num * mult + 0.5) / mult end, split = function (s, delimiter) result = {}; for match in (s..delimiter):gmatch("(.-)"..delimiter) do	       table.insert(result, match); end return result; end, title_case = 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, plural = function( item_name ) if string.sub( item_name, -2 ) == 'ch' or string.sub( item_name, -2 ) == 'sh' or string.sub( item_name, -2 ) == 'zh' or string.sub( item_name, -1 ) == 's'			or string.sub( item_name, -1 ) == 'x'			or string.sub( item_name, -1 ) == 'z' then return item_name .. 'es' end return item_name .. 's'	end, }

p = {

make_item_table = 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 error_msg = "" local item_names = {} if args[1] == "!!!ALL!!!" then for item_name, v in pairs( d.items ) do				table.insert( item_names, item_name ) end else item_names = mw.text.split( args[1], ',' ) end local single_item = f.has_one_entry( item_names ) -- error message for unknown items for x, item_name in pairs( item_names ) do			if d.items[item_name] == nil then error_msg = error_msg .. " Unknown item '" .. item_name .. "'. \n" end end -- calculate the chances, change from an associative array to an array, and sort local chances_hash = f.find_chances_for_items( item_names ) local chances_list = {} for key, editions in pairs( chances_hash ) do			table.insert( chances_list, { key, editions } ) end table.sort( chances_list, function(a,b) return a[1] < b[1] end ) -- build the html local html = {} local item_expanded = {} local chest_expanded = {} local chances, key, editions local key_split, item_display_name, item_key, chest_key, chance, stacksize

table.insert( html, error_msg ) if f.has_entries( chances_list ) then if single_item then item_key = item_names[1] if d.items[item_key].plural ~= nil and d.items[item_key].plural ~= false then item_display_name = d.items[item_key].plural else if d.items[item_key].title ~= nil then item_display_name = f.capitalize( d.items[item_key].title ) else item_display_name = f.capitalize( string.gsub( item_key, '-', ' ' ) ) end if d.items[item_key].plural == nil or d.items[item_key].plural ~= false then item_display_name = f.plural( item_display_name ) end end local chest_text = 'chests' if f.has_one_entry( chances_list ) then chest_text = 'chest' end table.insert( html, item_display_name .. ' may be found in the following ' .. chest_text .. ', with the following distribution: \n' ) end table.insert( html, '{| class="wikitable sortable" \n' ) if not single_item then table.insert( html, '! Item \n' ) end table.insert( html, '! Container \n' ) table.insert( html, '! # Stacks \n' ) table.insert( html, '! <abbr title="' )			table.insert( html, d.column_hovertext['stacksize'] )			table.insert( html, '"> Stack Size \n' ) table.insert( html, '! <abbr title="' )			table.insert( html, d.column_hovertext['weight'] )			table.insert( html, '"> Weight \n' ) table.insert( html, '! <abbr title="' )			table.insert( html, d.column_hovertext['items'] )			table.insert( html, '"> # Items \n' ) table.insert( html, '! <abbr title="' )			table.insert( html, d.column_hovertext['chance'] )			table.insert( html, '"> Chance \n' ) table.insert( html, '! <abbr title="' )			table.insert( html, d.column_hovertext['chests'] )			table.insert( html, '"> # Chests \n' ) table.insert( html, '! Java \n! Bedrock \n' ) end for _, chances in pairs( chances_list ) do			key = chances[1] editions = chances[2] key_split = f.split( key, '/' ) item_key = key_split[1] chest_key = key_split[2] chance = key_split[3] stacksize = key_split[4] if d.items[item_key].title ~= nil then item_display_name = d.items[item_key].title else item_display_name = f.title_case( string.gsub( item_key, '-', ' ' ) ) end local java_cell, bedrock_cell if editions['java'] ~= nil and editions['java-upcoming'] == nil then java_cell = f.planned_cell .. f.java_until_cell elseif editions['java'] == nil and editions['java-upcoming'] ~= nil then java_cell = f.planned_cell .. f.java_upcoming_cell elseif editions['java'] ~= nil and editions['java-upcoming'] ~= nil then java_cell = f.yes_cell else java_cell = f.no_cell end if editions['bedrock'] ~= nil and editions['bedrock-upcoming'] == nil then bedrock_cell = f.planned_cell .. f.bedrock_until_cell elseif editions['bedrock'] == nil and editions['bedrock-upcoming'] ~= nil then bedrock_cell = f.planned_cell .. f.bedrock_upcoming_cell elseif editions['bedrock'] ~= nil and editions['bedrock-upcoming'] ~= nil then bedrock_cell = f.yes_cell else bedrock_cell = f.no_cell end if not single_item and item_expanded[item_key] == nil then item_expanded[item_key] = f.get_item( item_key, item_display_name ) end local item_table_display = d.chests[chest_key]['item_table_display'] if chest_expanded[chest_key] == nil then chest_expanded[chest_key] = p.current_frame:expandTemplate{ title = 'EnvLink', args = { item_table_display.structure_text, id = item_table_display.structure_id } } end table.insert( html, '|-\n' ) if not single_item then table.insert( html, "|" .. item_expanded[item_key] .. "\n" ) end table.insert( html, "|" .. chest_expanded[chest_key] .. "" ) if item_table_display.container ~= nil then table.insert( html, " " .. string.gsub( item_table_display.container, ' ', ' ' ) ) end table.insert( html, '\n' ) table.insert( html, "|style='text-align:center;'|" .. 0 .. '\n' ) table.insert( html, "|style='text-align:center;'|" .. stacksize .. '\n' ) table.insert( html, "|style='text-align:center;'|" .. 0 .. '\n' ) table.insert( html, "|style='text-align:center;'|" .. 0 .. '\n' ) table.insert( html, "|style='text-align:center;'|" .. chance .. '%\n' ) table.insert( html, "|style='text-align:center;'|" .. 0 .. '\n' ) table.insert( html, '|' .. java_cell .. '\n' ) table.insert( html, '|' .. bedrock_cell .. '\n' ) end if f.has_entries( chances_list ) then table.insert( html, '|}\n' ) table.insert( html, p.current_frame:extensionTag( 'references', "", { group="note" } ) ) end return table.concat( html ) end, make_chest_table = function( ... ) end }

return p