TheRPGAdventurer Posted April 14, 2018 Posted April 14, 2018 public void generateNestAtNether(World world, Random random, int chunkX, int chunkZ) { if (RealmOfTheDragonsConfig.canSpawnNetherNest) { int x = (chunkX * RealmOfTheDragonsConfig.netherNestRarerityInX) + random.nextInt(RealmOfTheDragonsConfig.netherNestRarerityInX); int z = (chunkZ * RealmOfTheDragonsConfig.netherNestRarerityInZ) + random.nextInt(RealmOfTheDragonsConfig.netherNestRarerityInZ); for (int y = 85; y >= 5; y--) { if ((world.getBlockState(new BlockPos(x,y,z)).isBlockNormalCube()) && (world.isAirBlock(new BlockPos(x,y,z)))) { if((random.nextInt() * RealmOfTheDragonsConfig.netherNestRarity) <= 1) { boolean place = true; if(place) { dragonNestNether.generate(world, new BlockPos(x,y,z), random); Utils.getLogger().info("Nether Nest here at: " + new BlockPos(x,y,z)); } } } } } } I would like to limit them because they cause too much lag Quote
jabelar Posted April 14, 2018 Posted April 14, 2018 Count them or otherwise keep track of them and if there is already enough don't generate more. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
TheRPGAdventurer Posted April 14, 2018 Author Posted April 14, 2018 Just now, jabelar said: Count them or otherwise keep track of them and if there is already enough don't generate more. How do I count them? How do I keep track of them? Quote
jabelar Posted April 14, 2018 Posted April 14, 2018 2 hours ago, TheRPGAdventurer said: How do I count them? How do I keep track of them? This is your own code, so you create an int field and each time your world generator wants to generate you check if the field shows that enough have already been built and if not you build it and increment your counter. Note though that that wouldn't be saved so you should also make some world save data and store your int value there. There is are built in classes for saving data: WorldSavedData. How you do it depends if you want to store it per-dimension (different data for e.g. nether and overworld, these are two World instances in the code) or per save-file (same data for all dimensions). For the former use world.perWorldStorage, otherwise use world.mapStorage. Be sure to always call markDirty() on your data when you change a value, otherwise Minecraft will not save it. You can see diesieben07's simple example here: WorldSaveData example code Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.