From 40c49319fd3c6fcccbd2262e84145d0a8a793ba7 Mon Sep 17 00:00:00 2001 From: "Joseph T. McQuigg" Date: Mon, 22 Apr 2024 14:53:25 -0400 Subject: [PATCH] Remove Old Village Generation --- .../village/PlaceInVillage.java | 78 ------------------- .../generations_structures.accesswidener | 3 - .../fabric/GenerationsStructuresFabric.java | 3 - .../forge/GenerationsStructuresForge.java | 3 - .../forge/events/LifeCycleEvents.java | 14 ---- 5 files changed, 101 deletions(-) delete mode 100644 common/src/main/java/generations/gg/generations/structures/generationsstructures/village/PlaceInVillage.java delete mode 100644 forge/src/main/java/generations/gg/generations/structures/generationsstructures/forge/events/LifeCycleEvents.java diff --git a/common/src/main/java/generations/gg/generations/structures/generationsstructures/village/PlaceInVillage.java b/common/src/main/java/generations/gg/generations/structures/generationsstructures/village/PlaceInVillage.java deleted file mode 100644 index 9ed3fb4..0000000 --- a/common/src/main/java/generations/gg/generations/structures/generationsstructures/village/PlaceInVillage.java +++ /dev/null @@ -1,78 +0,0 @@ -package generations.gg.generations.structures.generationsstructures.village; - -import com.mojang.datafixers.util.Pair; -import generations.gg.generations.structures.generationsstructures.GenerationsStructures; -import generations.gg.generations.structures.generationsstructures.config.Config; -import generations.gg.generations.structures.generationsstructures.structures.GenerationsStructuresKeys; -import net.minecraft.core.Holder; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; -import net.minecraft.core.registries.Registries; -import net.minecraft.data.worldgen.ProcessorLists; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.level.levelgen.structure.pools.SinglePoolElement; -import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement; -import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class is used to add structures to villages. - * We do this by adding the structures to the existing village structure pool. - * @author Joseph T. McQuigg - */ -public class PlaceInVillage { - - /** - * Adds a building to a village structure pool. - * - * @param serverRegistry The server registry. - * @param poolRL The pool to add the building to. - * @param processorList The processor list to use. - * @param nbtPieceRL The nbt piece to add. - * @param projection The projection to use. - * @param weight The weight of the building. - */ - private static void addBuildingToPool(RegistryAccess.Frozen serverRegistry, ResourceLocation poolRL, ResourceKey processorList, ResourceLocation nbtPieceRL, StructureTemplatePool.Projection projection, int weight) { - Registry templatePoolRegistry = serverRegistry.registry(Registries.TEMPLATE_POOL).orElseThrow(); - Registry processorListRegistry = serverRegistry.registry(Registries.PROCESSOR_LIST).orElseThrow(); - StructureTemplatePool pool = templatePoolRegistry.get(poolRL); - Holder processorList1 = processorListRegistry.getHolderOrThrow(processorList); - if (pool == null) return; - - SinglePoolElement piece = SinglePoolElement.legacy(nbtPieceRL.toString(), processorList1).apply(projection); - - for (int i = 0; i < weight; i++) - pool.templates.add(piece); - - List> listOfPieceEntries = new ArrayList<>(pool.rawTemplates); - listOfPieceEntries.add(new Pair<>(piece, weight)); - pool.rawTemplates = listOfPieceEntries; - } - - /** - * Adds structures to villages. - * @param server The server to add the structures to. - */ - public static void addStructuresToVillages(MinecraftServer server) { - Config.VillageStructureGeneration config = GenerationsStructures.CONFIG.villageStructureGeneration; - if (!config.AllowStructuresInVillages) return; - GenerationsStructures.LOGGER.info("Adding structures to villages"); - RegistryAccess.Frozen serverRegistry = server.registryAccess(); - addBuildingToPool(serverRegistry, getPoolRL("plains/streets"), ProcessorLists.STREET_PLAINS, new ResourceLocation("village/plains/streets/straight_05"), StructureTemplatePool.Projection.TERRAIN_MATCHING, 1000); - //addBuildingToPool(serverRegistry, getPoolRL("plains/houses"), ProcessorLists.EMPTY, GenerationsStructuresKeys.PLAINS_POKEMART_1.location(), StructureTemplatePool.Projection.RIGID, 8); - //addBuildingToPool(serverRegistry, getPoolRL("plains/houses"), ProcessorLists.EMPTY, GenerationsStructuresKeys.PLAINS_POKECENTER_1.location(), StructureTemplatePool.Projection.RIGID, 8); - //addBuildingToPool(serverRegistry, getPoolRL("plains/houses"), ProcessorLists.EMPTY, GenerationsStructuresKeys.PLAINS_POKEMART_2.location(), StructureTemplatePool.Projection.RIGID, 8); - //addBuildingToPool(serverRegistry, getPoolRL("plains/houses"), ProcessorLists.EMPTY, GenerationsStructuresKeys.PLAINS_POKECENTER_2.location(), StructureTemplatePool.Projection.RIGID, 8); - //addBuildingToPool(serverRegistry, getPoolRL("plains/houses"), ProcessorLists.EMPTY, GenerationsStructuresKeys.PLAINS_POKEMART_3.location(), StructureTemplatePool.Projection.RIGID, 8); - //addBuildingToPool(serverRegistry, getPoolRL("plains/houses"), ProcessorLists.EMPTY, GenerationsStructuresKeys.PLAINS_POKECENTER_3.location(), StructureTemplatePool.Projection.RIGID, 8); - } - - private static ResourceLocation getPoolRL(String poolName) { - return new ResourceLocation("minecraft", "village/" + poolName); - } -} diff --git a/common/src/main/resources/generations_structures.accesswidener b/common/src/main/resources/generations_structures.accesswidener index ddec532..8c506b2 100644 --- a/common/src/main/resources/generations_structures.accesswidener +++ b/common/src/main/resources/generations_structures.accesswidener @@ -1,7 +1,4 @@ accessWidener v2 named accessible field net/minecraft/data/worldgen/ProcessorLists EMPTY Lnet/minecraft/resources/ResourceKey; -accessible field net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool templates Lit/unimi/dsi/fastutil/objects/ObjectArrayList; -mutable field net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool rawTemplates Ljava/util/List; -accessible field net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool rawTemplates Ljava/util/List; accessible field net/minecraft/data/worldgen/PlainVillagePools TERMINATORS_KEY Lnet/minecraft/resources/ResourceKey; \ No newline at end of file diff --git a/fabric/src/main/java/generations/gg/generations/structures/generationsstructures/fabric/GenerationsStructuresFabric.java b/fabric/src/main/java/generations/gg/generations/structures/generationsstructures/fabric/GenerationsStructuresFabric.java index c5a1e03..5d0cd51 100644 --- a/fabric/src/main/java/generations/gg/generations/structures/generationsstructures/fabric/GenerationsStructuresFabric.java +++ b/fabric/src/main/java/generations/gg/generations/structures/generationsstructures/fabric/GenerationsStructuresFabric.java @@ -3,9 +3,7 @@ import generations.gg.generations.structures.generationsstructures.GenerationsStructures; import generations.gg.generations.structures.generationsstructures.integration.Default; import generations.gg.generations.structures.generationsstructures.processors.StructureProcessors; -import generations.gg.generations.structures.generationsstructures.village.PlaceInVillage; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; /** * Fabric initializer for Generations Structures @@ -18,6 +16,5 @@ public class GenerationsStructuresFabric implements ModInitializer { public void onInitialize() { GenerationsStructures.init(new Default()); //TODO: FabricLoader.getInstance().isModLoaded(potionstudios.byg.BYG.MOD_ID) ? new BYG() : new Default() StructureProcessors.init(); - ServerLifecycleEvents.SERVER_STARTING.register(PlaceInVillage::addStructuresToVillages); } } diff --git a/forge/src/main/java/generations/gg/generations/structures/generationsstructures/forge/GenerationsStructuresForge.java b/forge/src/main/java/generations/gg/generations/structures/generationsstructures/forge/GenerationsStructuresForge.java index 2f413af..a235c2e 100644 --- a/forge/src/main/java/generations/gg/generations/structures/generationsstructures/forge/GenerationsStructuresForge.java +++ b/forge/src/main/java/generations/gg/generations/structures/generationsstructures/forge/GenerationsStructuresForge.java @@ -1,12 +1,10 @@ package generations.gg.generations.structures.generationsstructures.forge; import generations.gg.generations.structures.generationsstructures.GenerationsStructures; -import generations.gg.generations.structures.generationsstructures.forge.events.LifeCycleEvents; import generations.gg.generations.structures.generationsstructures.forge.integration.BOP; import generations.gg.generations.structures.generationsstructures.integration.Default; import generations.gg.generations.structures.generationsstructures.integration.Integration; import generations.gg.generations.structures.generationsstructures.processors.StructureProcessors; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; @@ -28,7 +26,6 @@ public GenerationsStructuresForge() { GenerationsStructures.init(integration); IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.addListener(this::commonSetup); - MinecraftForge.EVENT_BUS.addListener(LifeCycleEvents::aboutToStartEvent); } /** diff --git a/forge/src/main/java/generations/gg/generations/structures/generationsstructures/forge/events/LifeCycleEvents.java b/forge/src/main/java/generations/gg/generations/structures/generationsstructures/forge/events/LifeCycleEvents.java deleted file mode 100644 index 1a70c4c..0000000 --- a/forge/src/main/java/generations/gg/generations/structures/generationsstructures/forge/events/LifeCycleEvents.java +++ /dev/null @@ -1,14 +0,0 @@ -package generations.gg.generations.structures.generationsstructures.forge.events; - -import generations.gg.generations.structures.generationsstructures.village.PlaceInVillage; -import net.minecraftforge.event.server.ServerAboutToStartEvent; - -public class LifeCycleEvents { - /** - * Adds all custom structures to villages. - * @see ServerAboutToStartEvent - */ - public static void aboutToStartEvent(final ServerAboutToStartEvent event) { - PlaceInVillage.addStructuresToVillages(event.getServer()); - } -}