Worldgen and loot
These types add a mod’s features to biomes and its items to loot tables, each behind a switch the mod reads from its settings. Use them in place of each loader’s own biome modifiers and loot events, which differ between Fabric and Forge.
At a glance
Section titled “At a glance”| Type | Summary | Status | Since | Side | Thread |
|---|---|---|---|---|---|
BiomeFeatures |
Adds placed features to biomes. | Experimental | 2.1.0 | both | setup |
LootAdditions |
Adds a pool to a loot table, or a chance to replace a brushed archaeology item. | Experimental | 2.1.0 | both | setup |
Quick start
Section titled “Quick start”The placed feature is the mod’s data/mymod/worldgen/placed_feature/maple.json. With
mapleEnabled, a BooleanSupplier that reads the mod’s settings, in your mod’s common
initializer:
ResourceKey<PlacedFeature> maple = ResourceKey.create(Registries.PLACED_FEATURE, id("maple"));BiomeFeatures.add(maple, BiomeTags.IS_FOREST, GenerationStep.Decoration.VEGETAL_DECORATION, mapleEnabled);BiomeFeatures
Section titled “BiomeFeatures”Experimental · Since 2.1.0 · Side: both · Thread: setup
BiomeFeatures adds a mod’s placed features, such as its trees, to the biomes a tag names,
behind a switch the mod reads from its settings. A biome tag of the mod’s own lets data packs
choose the biomes; its file is data/mymod/tags/worldgen/biome/has_maples.json. With maple
and mapleEnabled as in the quick start:
BiomeFeatures.add(maple, RegistryLookups.biomeTagKey(id("has_maples")), GenerationStep.Decoration.VEGETAL_DECORATION, mapleEnabled);- A feature key with no placed feature in the server’s data fails when the server starts.
- A mod ships no Forge biome modifier JSON: Stope’s Forge jar carries the one biome modifier every mod’s features go through.
LootAdditions
Section titled “LootAdditions”Experimental · Since 2.1.0 · Side: both · Thread: setup
LootAdditions adds pools to loot tables and replacement items to archaeology loot, each
behind a switch the mod reads from its settings. With MAPLE_SAPLING, the sapling’s
Registered handle, and mapleEnabled as in the quick start:
LootAdditions.addPool(BuiltInLootTables.VILLAGE_PLAINS_HOUSE, () -> LootPool.lootPool() .add(LootItem.lootTableItem(MAPLE_SAPLING.get())) .when(LootItemRandomChanceCondition.randomChance(0.25f)), mapleEnabled);LootAdditions.replaceBrushed(BuiltInLootTables.DESERT_PYRAMID_ARCHAEOLOGY, 0.05f, random -> new ItemStack(MAPLE_SAPLING.get()), mapleEnabled);- A mod ships no Forge loot modifier JSON: Stope’s Forge jar carries the one global loot modifier every added pool goes through.
- A
LootAdditions#replaceBrushedaddition whose roll hits but whose item is empty passes the brush on to the next addition for that table. - Brushed replacements work the same on Fabric and Forge.
Edge cases
Section titled “Edge cases”Two Forge differences follow from Forge’s global loot modifiers:
- On Forge a pool applies to the table the game rolled. A pool added to a table that another
table reaches through a
loot_tableentry rolls on Fabric but not on Forge. Add pools to the table the game rolls; chest tables are rolled directly. - A data pack that replaces
data/forge/loot_modifiers/global_loot_modifiers.jsonwith"replace": trueand leaves outstope:poolsturns off every added pool on Forge.
See also
Section titled “See also”- Block behavior and rendering: saplings that grow a mod’s trees.
- Config files and settings screens: the settings these switches read.