JaredBGreat Posted July 17, 2016 Posted July 17, 2016 I recently tried to update Doomlike Dungeons to 1.10.2; the update to 1.10 was so easy, it literally required no code changes to make it work. Unfortunately this doesn't seem to be the case with 1.10.2. The code produces no errors, but my IWorldGenerator class (GenerationHandler) never seems to be triggered or to trigger world-gen. Everything works correctly when I spawn a dungeon in with a cheat code, they never appear with natural world-gen -- the game runs normally but no dungeons ever generation (without cheats). I'm not sure if something has to be registered differently, or if there is some extra-registration, or what -- or if this is simply a bug in the new Forge version. I've tried moving the registration of the IWorldGenerator out the constructor, but this made no difference. From DoomlikeDungoens.java: @EventHandler public void init(FMLInitializationEvent event) { if(ConfigHandler.naturalSpawn) dungeonPlacer = new GenerationHandler(); } My IWorldGenerator: package jaredbgreat.dldungeons; /* * This mod is the creation and copyright (c) 2015 * of Jared Blackburn (JaredBGreat). * * It is licensed under the creative commons 4.0 attribution license: * * https://creativecommons.org/licenses/by/4.0/legalcode */ import static jaredbgreat.dldungeons.builder.Builder.placeDungeon; import java.util.HashSet; import java.util.Random; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary.Type; import net.minecraftforge.fml.common.IWorldGenerator; import net.minecraftforge.fml.common.registry.GameRegistry; /** * The class responcible for determine where dungeons generate. More * specifically, it will determine if a chunk being generated should be * the technical (not geometric) center of a dungeon. * * @author Jared Blackburn * */ public class GenerationHandler implements IWorldGenerator { private static int frequency; private static int factor = 6; private static int minXZ; private static Random mrand; private static HashSet<Integer> dimensions; public GenerationHandler() { GameRegistry.registerWorldGenerator(this, 100); } /** * Called when a new chunk generates to determine if a dungeon should be * built centered on that chunk. * * First it will make sure dungeons are aloud, including all config setting * and world setting as well as the dimension and biome of the chunk. * * If dungeons are allowed here then it will check if the chunk is the one * in its area to have a dungeon. To do this the map is logically divided * into square areas the size of which depend on the frequency scale. One * chunk in each area is the technical center around with a dungeon will * generate. The chunk coordinates are divided by the area's width using * integer division to round so that all chunks in the same area are given * the same two numbers. These numbers are then used to create a random * seeds from which coordinates from 0 to the area width are generated. If * the coords match the remainder of chunk coordinate divided by the width * of the area this chunk will have a dungeon; since all chunks in the area * will use the same random seed and thus have the same number one and only * one of them will have a dungeon (assuming dungeons are allowed in the * worlds and in that chunk). * * This allows dungeons to be placed randomly while ensuring a more consistent * distribution than simply giving each a random probability to have one. */ @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { // Prevent bad spawns if(world.isRemote) return; if((ConfigHandler.obeyRule && !world.getWorldInfo().isMapFeaturesEnabled()) || !ConfigHandler.naturalSpawn) return; boolean blockedBiome = false; Type[] types = BiomeDictionary.getTypesForBiome((world.getBiomeGenForCoords(new BlockPos(chunkX * 16, 63, chunkZ * 16)))); for(Type type : types) { blockedBiome = ConfigHandler.biomeExclusions.contains(type) || blockedBiome; } if(blockedBiome) return; if((dimensions.contains(Integer.valueOf(world.provider.getDimension())) != ConfigHandler.positiveDims)) return; if((Math.abs(chunkX - (world.getSpawnPoint().getX() / 16)) < minXZ) || (Math.abs(chunkZ - (world.getSpawnPoint().getZ() / 16)) < minXZ)) return; mrand = new Random(world.getSeed() + world.provider.getDimension() + (2027 * (long)(chunkX / factor)) + (1987 * (long)(chunkZ / factor))); int xrand = mrand.nextInt(); int zrand = mrand.nextInt(); int xuse = ((chunkX + xrand) % factor); int zuse = ((chunkZ + zrand) % factor); if((xuse == 0) && (zuse == 0)) { try { placeDungeon(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); } catch (Throwable e) { System.err.println("[DLDUNGEONS] Danger! Failed to finalize a dungeon after building!"); e.printStackTrace(); } } } /** * Sets the frequency scale and converts into the * width (and height) of the areas for which dungeons * are generated. * * @param freqScale */ public static void setFrequency(int freqScale) { if((freqScale % 2) == 0) factor = 2; else factor = 3; System.out.println("freqScale = " + freqScale); factor = (1 << (freqScale / 2)) * factor; System.out.println("factor = " + factor); } /** * Sets the minimum number of chunks from spawn a dungeon center must be. * * @param value */ public static void setMinXZ(int value) { minXZ = value; } /** * Sets list of dimension id's to check for dungeons being allowed. * * @param value */ public static void setDimensions(int[] value) { dimensions = new HashSet<Integer>(); for(int i = 0; i < value.length; i++) { dimensions.add(Integer.valueOf(value[i])); } } /** * Add a dimension id to the list of dimension to consider when * check if a dungeon is allowed. (What this means can vary.) * * @param value */ public static void addDimension(int value) { dimensions.add(Integer.valueOf(value)); } /** * Remove a dimension id from the list of those to consider when potentially * placing a dungeons. (What this means can vary.) * * @param value */ public static void subDimension(int value) { dimensions.remove(Integer.valueOf(value)); } } Does anyone know what's happened to break this? -- or is this actually Forge bug? Quote Developer of Doomlike Dungeons.
shadowfacts Posted July 17, 2016 Posted July 17, 2016 Show how you're registering your IWorldGenerator . Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
Draco18s Posted July 17, 2016 Posted July 17, 2016 It's in the constrictor for his generator Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
JaredBGreat Posted July 18, 2016 Author Posted July 18, 2016 So, does anyone know what's going on -- or should this be reported as a bug? Its the same code that worked for 1.10, and 1.9.4. I have tried moving the registration out of the constructor to the code block that creates it (since something don't like be registered on creation), but that made no difference. At this point, I'm thinking this actually is a Forge bug rather than an error of mine. Quote Developer of Doomlike Dungeons.
Choonster Posted July 18, 2016 Posted July 18, 2016 Try setting a breakpoint in GenerationHandler#generate , running Minecraft in debug mode and generating new chunks; is the breakpoint hit? Also set a breakpoint in GameRegistry.generateWorld and see if the GenerationHandler instance is in worldGenerators , worldGeneratorIndex and sortedGeneratorList . Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
JaredBGreat Posted July 18, 2016 Author Posted July 18, 2016 Well, I used the simple profiler I built in (since F3 info isn't that good for infrequence, time consuming events). It seems that GenerationHandler is working fine, but there was something wrong with the config. I don't understand it, but it wasn't reading the config, but after I simply deleted it and let a new one be generated everything worked -- no change in the config reading code. It wasn't generating dungeons because it was too close to spawn and hadn't read in the config changes I'd made to let them appear at a distance of 0. Text editors read it fine, and Minecraft reads the new one fine. So now it works, I just don't know what the problem was. Quote Developer of Doomlike Dungeons.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.