Skip to main content
Version: 1.20.x

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 and the modifier instance to be serialized. 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, 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
));