Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Mod.EventBusSubscriber(modid = Necromod.MODID)
- public class NecromodWorldEvents
- {
- private static Method GETCODEC_METHOD;
- @SubscribeEvent
- public static void biomeLoadingEvent(final BiomeLoadingEvent event)
- {
- event.getGeneration().getStructures().add(() -> NecromodConfiguredStructures.CONFIGURED_SECRET_ROOM);
- NecromodTreeGeneration.generateTrees(event);
- }
- @SuppressWarnings("unchecked")
- @SubscribeEvent
- public void addDimensionalSpacing(final WorldEvent.Load event)
- {
- if(event.getWorld() instanceof ServerWorld)
- {
- ServerWorld serverWorld = (ServerWorld)event.getWorld();
- try
- {
- if(GETCODEC_METHOD == null) GETCODEC_METHOD = ObfuscationReflectionHelper.findMethod(ChunkGenerator.class, "func_230347_a_");
- ResourceLocation cgRL = Registry.CHUNK_GENERATOR.getKey((Codec<? extends ChunkGenerator>) GETCODEC_METHOD.invoke(serverWorld.getChunkSource().generator));
- if(cgRL != null && cgRL.getNamespace().equals("terraforged")) return;
- }
- catch(Exception e)
- {
- Necromod.LOGGER.error("Was unable to check if " + serverWorld.dimension().location() + " is using Terraforged's ChunkGenerator.");
- }
- if(serverWorld.getChunkSource().getGenerator() instanceof FlatChunkGenerator && serverWorld.dimension().equals(World.OVERWORLD))
- {
- return;
- }
- Map<Structure<?>, StructureSeparationSettings> tempMap = new HashMap<>(serverWorld.getChunkSource().generator.getSettings().structureConfig());
- tempMap.putIfAbsent(NecromodStructures.SECRET_ROOM.get(), DimensionStructuresSettings.DEFAULTS.get(NecromodStructures.SECRET_ROOM.get()));
- serverWorld.getChunkSource().generator.getSettings().structureConfig = tempMap;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement