How Lootr Works - LootrMinecraft/Lootr GitHub Wiki
(As of 1.21.1 100 and later, this is no longer accurate and must be updated.)
Lootr primarily functions by detecting block entities (descended from RandomizableContainerBlockEntity, associated with blocks such as minecraft:chest, minecraft:barrel, etc) that have a specific loot table associated with them. For example, when a "dungeon" feature is created (the mossy cobblestone box with a zombie spawner and a chest), it generates a chest with the loot table minecraft:chests/simple_dungeon.
Whenever one of these block entities is detected during world generation, its location (and the dimension it spawned in) is stored. Later, after ensuring that the chunk has been fully generated, and that all chunks in a 5x5 radius around it have also been generated, the chest will be replaced with the Lootr equivalent.
This system ensures that Lootr detects as many compatible containers as possible.
Conversion Tags
In all recent versions, Lootr determines which blocks can be converted into which Lootr equivalent based on block tags.
Please note: regardless of what is contained within the tags, only those blocks which have an associated block entity that descends from RandomizableContainerBlockEntity` will be considered.
The following tags exist:
lootr:convert/barrelscontains all eligible blocks that should be replaced with Lootr'slootr:lootr_barrel[default:minecraft:barrel,#c:barrels]lootr:convert/chestscontains all eligible blocks that should be replaced with Lootr'slootr:lootr_chest[default:minecraft:chest,#c:chests/wooden]lootr:convert/trapped_chestscontains all eligible blocks that should be replaced with Lootr'slootr:lootr_trapped_chest[default:minecraft:trapped_chest,#c:chests/trapped]lootr:convert/shulkerscontains all eligible blocks that should be replaced with Lootr'slootr:lootr_shulker[default:minecraft:shulker_box]
These four tags are transcluded into:
lootr:convert/blocks
In addition, there is a tag specifically to allow for blacklisting certain blocks. All blocks contained in this will be ignored, even if they are contained within other tags.
lootr:convert/blacklist
Adding New Blocks
To add new blocks that are not automatically detected by Lootr, you will need to create a data pack.
Example data packs generated by Lootr exist in the source code for BetterEnd and BetterNether.
Configuration
In both phases (the detection & later replacement), various configuration options are consulted, including:
- Global disabling of Lootr conversion
- If the block is already a Lootr container
- If the block is located outside of the current world border (if this configuration option is enabled)
- If the dimension has been blocked (or specifically allowed)
- If the mod id of the dimension has been blocked
- If the container is within a structure that has been blocked (or specifically allowed) via tag (if structures are generated by the server)
- If the loot table specifically has been blacklisted (i.e., if the
loot_table_blacklistcontained the entryminecraft:chests/simple_dungeon) - If the mod id of the loot table specifically has been blacklisted (i.e., if the
loot_modid_blacklistcontained the entryminecraftfor the loot tableminecraft:chests/simple_dungeon)