Skip to content

Commit

Permalink
Register StructureProcessors in one line
Browse files Browse the repository at this point in the history
  • Loading branch information
JT122406 committed May 29, 2024
1 parent f031dc8 commit 7a32658
Showing 1 changed file with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package generations.gg.generations.structures.generationsstructures.processors;

import com.mojang.serialization.Codec;
import generations.gg.generations.structures.generationsstructures.GenerationsStructures;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.fiery.FieryShrineProcessor;
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.fiery.FieryShrineRandomizerProcessor;
Expand All @@ -12,45 +13,42 @@
import generations.gg.generations.structures.generationsstructures.processors.structure_processors.shrines.staticShrine.StaticShrineRandomizerProcessor;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorType;
import org.jetbrains.annotations.NotNull;

/**
* Structure processor types for Generations Structures
* @see StructureProcessorType
* @author J.T. McQuigg (JT122406)
*/
public class StructureProcessors {
public static final StructureProcessorType<ScarletPokeCenterProcessor> SCARLET_POKECENTER_PROCESSOR = () -> ScarletPokeCenterProcessor.CODEC;
public static final StructureProcessorType<GymProcessor> GYM_PROCESSOR = () -> GymProcessor.CODEC;
public static final StructureProcessorType<PokeCenterProcessor> POKECENTER_PROCESSOR = () -> PokeCenterProcessor.CODEC;
public static final StructureProcessorType<FrozenShrineProcessor> FROZEN_SHRINE_PROCESSOR = () -> FrozenShrineProcessor.CODEC;
public static final StructureProcessorType<FieryShrineRandomizerProcessor> FIERY_SHRINE_RANDOMIZER_PROCESSOR = () -> FieryShrineRandomizerProcessor.CODEC;
public static final StructureProcessorType<FieryShrineProcessor> FIERY_SHRINE_PROCESSOR = () -> FieryShrineProcessor.CODEC;
public static final StructureProcessorType<StaticShrineRandomizerProcessor> STATIC_SHRINE_RANDOMIZER_PROCESSOR = () -> StaticShrineRandomizerProcessor.CODEC;
public static final StructureProcessorType<StaticShrineProcessor> STATIC_SHRINE_PROCESSOR = () -> StaticShrineProcessor.CODEC;
public static final StructureProcessorType<LugiaShrineRandomizerProcessor> LUGIA_SHRINE_RANDOMIZER_PROCESSOR = () -> LugiaShrineRandomizerProcessor.CODEC;
public static final StructureProcessorType<ScarletPokeCenterProcessor> SCARLET_POKECENTER_PROCESSOR = register("scarlet_pokeshop_processor", ScarletPokeCenterProcessor.CODEC);
public static final StructureProcessorType<GymProcessor> GYM_PROCESSOR = register("gym_processor", GymProcessor.CODEC);
public static final StructureProcessorType<PokeCenterProcessor> POKECENTER_PROCESSOR = register("pokecenter_processor", PokeCenterProcessor.CODEC);
public static final StructureProcessorType<FrozenShrineProcessor> FROZEN_SHRINE_PROCESSOR = register("shrines/frozen_shrine_processor", FrozenShrineProcessor.CODEC);
public static final StructureProcessorType<FieryShrineRandomizerProcessor> FIERY_SHRINE_RANDOMIZER_PROCESSOR = register("shrines/fiery_shrine_randomizer_processor", FieryShrineRandomizerProcessor.CODEC);
public static final StructureProcessorType<FieryShrineProcessor> FIERY_SHRINE_PROCESSOR = register("shrines/fiery_shrine_processor", FieryShrineProcessor.CODEC);
public static final StructureProcessorType<StaticShrineRandomizerProcessor> STATIC_SHRINE_RANDOMIZER_PROCESSOR = register("shrines/static_shrine_randomizer_processor", StaticShrineRandomizerProcessor.CODEC);
public static final StructureProcessorType<StaticShrineProcessor> STATIC_SHRINE_PROCESSOR = register("shrines/static_shrine_processor", StaticShrineProcessor.CODEC);
public static final StructureProcessorType<LugiaShrineRandomizerProcessor> LUGIA_SHRINE_RANDOMIZER_PROCESSOR = register("shrines/lugia_shrine_randomizer_processor", LugiaShrineRandomizerProcessor.CODEC);


/**
* Registers all custom structure processor types.
*/
public static void init() {
GenerationsStructures.LOGGER.info("Registering Structure Processors");
register("scarlet_pokeshop_processor", SCARLET_POKECENTER_PROCESSOR);
register("gym_processor", GYM_PROCESSOR);
register("pokecenter_processor", POKECENTER_PROCESSOR);
register("shrines/frozen_shrine_processor", FROZEN_SHRINE_PROCESSOR);
register("shrines/fiery_shrine_randomizer_processor", FIERY_SHRINE_RANDOMIZER_PROCESSOR);
register("shrines/fiery_shrine_processor", FIERY_SHRINE_PROCESSOR);
register("shrines/static_shrine_randomizer_processor", STATIC_SHRINE_RANDOMIZER_PROCESSOR);
register("shrines/static_shrine_processor", STATIC_SHRINE_PROCESSOR);
register("shrines/lugia_shrine_randomizer_processor", LUGIA_SHRINE_RANDOMIZER_PROCESSOR);
GenerationsStructures.LOGGER.info("Registering Custom Structure Processors");
}

/**
* Utility method for registering custom structure processor types.
* @param id The id of the structure processor type
* @param codec The codec for the structure processor type
* @return The registered structure processor type
*/
private static void register(String name, StructureProcessorType<?> processorType) {
Registry.register(BuiltInRegistries.STRUCTURE_PROCESSOR, GenerationsStructures.id(name), processorType);
private static <P extends StructureProcessor> @NotNull StructureProcessorType<P> register(String id, Codec<P> codec) {
StructureProcessorType<P> processorType = () -> codec;
return Registry.register(BuiltInRegistries.STRUCTURE_PROCESSOR, GenerationsStructures.id(id), processorType);
}
}

0 comments on commit 7a32658

Please sign in to comment.