Skip to content

Commit

Permalink
ProcessorList Datagen
Browse files Browse the repository at this point in the history
  • Loading branch information
JT122406 committed Nov 29, 2023
1 parent 58c9f2b commit f225a2a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package generations.gg.generations.structures.generationsstructures.processors;

import com.google.common.collect.ImmutableList;
import generations.gg.generations.structures.generationsstructures.GenerationsStructures;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;

/**
* This class is used to hold all the ProcessorLists
* @see net.minecraft.data.worldgen.ProcessorLists
* @author Joseph T. McQuigg
*/
public class GenerationsProcessorLists {

public static ResourceKey<StructureProcessorList> GYM_PROCESSOR_LIST = create("gym_processor_list");
public static ResourceKey<StructureProcessorList> SCARLET_POKESHOP_PROCESSOR_LIST = create("scarlet_pokeshop_processor_list");

/**
* This method is used to bootstrap the processorlists.
* @param context The bootstrap context
*/
public static void bootstrap(BootstapContext<StructureProcessorList> context) {
StructureProcessors.init();
register(context, SCARLET_POKESHOP_PROCESSOR_LIST, new StructureProcessorList(ImmutableList.of(new ScarletPokeShopProcessor())));
register(context, GYM_PROCESSOR_LIST, new StructureProcessorList(ImmutableList.of(new GymProcessor())));
}

/**
* Registers a ProcessorList with the given key and StructureProcessorList.
* @param context The bootstrap context
* @param key The key for the ProcessorList
* @param structureProcessorList The StructureProcessorList to register
*/
private static void register(BootstapContext<StructureProcessorList> context, ResourceKey<StructureProcessorList> key, StructureProcessorList structureProcessorList) {
context.register(key, structureProcessorList);
}

/**
* Creates a ResourceKey for the ProcessorList.
* @param name of the structure set or directory with name.
* @return ResourceKey<StructureProcessorList>
*/
private static ResourceKey<StructureProcessorList> create(String name) {
return ResourceKey.create(Registries.PROCESSOR_LIST, GenerationsStructures.id(name));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public class GenerationsStructuresFabric implements ModInitializer {
public void onInitialize() {
GenerationsStructures.init(FabricLoader.getInstance().isModLoaded(potionstudios.byg.BYG.MOD_ID) ? new BYG() : new Default());
StructureProcessors.init();
PlaceInVillage.addStructuresToVillages();
//PlaceInVillage.addStructuresToVillages();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package generations.gg.generations.structures.generationsstructures.forge.datagen;

import generations.gg.generations.structures.generationsstructures.GenerationsStructures;
import generations.gg.generations.structures.generationsstructures.processors.GenerationsProcessorLists;
import generations.gg.generations.structures.generationsstructures.structures.GenerationsStructureSettings;
import generations.gg.generations.structures.generationsstructures.structures.GenerationsStructuresKeys;
import generations.gg.generations.structures.generationsstructures.tags.GenerationsBiomeTags;
Expand Down Expand Up @@ -48,7 +49,8 @@ public static void gatherData(GatherDataEvent event) {
private static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
.add(Registries.TEMPLATE_POOL, GenerationsTemplatePools::bootstrap)
.add(Registries.STRUCTURE, GenerationsStructureSettings::bootstrap)
.add(Registries.STRUCTURE_SET, GenerationsStructureSets::bootstrap);
.add(Registries.STRUCTURE_SET, GenerationsStructureSets::bootstrap)
.add(Registries.PROCESSOR_LIST, GenerationsProcessorLists::bootstrap);

private static class GenerationsStructuresBiomeTagsProvider extends BiomeTagsProvider {

Expand Down

0 comments on commit f225a2a

Please sign in to comment.