Skip to content

Datagen

Ethan Costa edited this page Oct 9, 2024 · 1 revision

Graveyards provide a GravestoneDatagen Provider.

Your Gravestone Provider Class should extends GravestoneDataProvider.

public class TestGravestoneProvider extends GravestoneDataProvider {

    public TestGravestoneProvider(PackOutput output) {
        super(output, "your_modid");
    }

    @Override
    protected void build(BiConsumer<ResourceLocation, GravestoneData> consumer) {
        registerGravestone(consumer, "your_modid:arachnophobe", 1, Optional.empty(),Optional.empty(), List.of(
                new GravestoneData.Monster(ResourceKey.create(Registries.ENTITY_TYPE, ResourceLocation.withDefaultNamespace("spider")), Optional.empty(), Optional.empty()),
                new GravestoneData.Monster(ResourceKey.create(Registries.ENTITY_TYPE, ResourceLocation.withDefaultNamespace("spider")), Optional.empty(), Optional.empty()),
                new GravestoneData.Monster(ResourceKey.create(Registries.ENTITY_TYPE, ResourceLocation.withDefaultNamespace("spider")), Optional.empty(), Optional.empty()),
                new GravestoneData.Monster(ResourceKey.create(Registries.ENTITY_TYPE, ResourceLocation.withDefaultNamespace("spider")), Optional.empty(), Optional.empty())
        ), new GravestoneData.Rewards(3, ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.fromNamespaceAndPath(Graveyards.MODID, "gravestones/level_1"))));

    }
}

You can use the utility method GravestoneDataProvider#registerGravestone

and then in your Datagen main class :

@EventBusSubscriber(modid = YourMod.MODID, bus = EventBusSubscriber.Bus.MOD)
public class ModDatagen {

    @SubscribeEvent
    public static void gatherData(GatherDataEvent event) {
        PackOutput output = generator.getPackOutput();

        generator.addProvider(
                event.includeServer(),
                new TestGravestoneProvider(output)
        );
    }
}

Clone this wiki locally