Skip to main content
Version: 1.20.5 - 1.20.6

Global Loot Modifier Generation

Global Loot Modifiers (GLMs) can be generated for a mod by subclassing GlobalLootModifierProvider and implementing #start. Each GLM can be added generated by calling #add and specifying the name of the modifier, the modifier instance to be serialized, and an optional list of conditions which determine whether the GLM should be loaded. After implementation, the provider must be added to the DataGenerator.

// On the MOD event bus
@SubscribeEvent
public void gatherData(GatherDataEvent event) {
event.getGenerator().addProvider(
// Tell generator to run only when server data are generating
event.includeServer(),
output -> new MyGlobalLootModifierProvider(output, event.getLookupProvider(), MOD_ID)
);
}

// In some GlobalLootModifierProvider#start
this.add("example_modifier",
new ExampleModifier(
new LootItemCondition[] {
WeatherCheck.weather().setRaining(true).build() // Executes when raining
},
"val1",
10,
Items.DIRT
),
// If this item exists and is registered, then this GLM will be loaded
new ItemExistsCondition("other_mod", "other_mod_item")
);