Posted August 30, 20178 yr So guys I thought my code wasn't working til I found the issue. You see, when I spawn my structure in the nether, It spawns above the bedrock on the uppermost layer of the nether not on the world below it. I have screenshots. public void generateNestAtNether(World world, Random random, int chunkX, int chunkZ) { int x = chunkX * 16 + random.nextInt(16); int z = chunkZ * 16 + random.nextInt(16); int xy = x >> 4; int zy = z >> 4; int height = world.getChunkFromChunkCoords(xy, zy).getHeight(new BlockPos(x & 15, 0, z & 15)); int y = height - 1; BlockPos pos = new BlockPos(chunkX, y, chunkZ); if(world.getBiomeForCoordsBody(new BlockPos (x,y,z)).getBiomeClass().equals(BiomeHell.class)) { if((random.nextInt(120) + 1) <= 1) { boolean place = true; for(int Y = 0; Y < 3; Y++) { for(int Z = 0; Z < 7; Z++) { for(int X = 0; X < 7; X++) { if(world.getBlockState(new BlockPos(X + x, Y + y + 1, Z + z)).getBlock() != Blocks.AIR) { place = false; } } } } if(place) { dragonNestNether.generate(world, random, new BlockPos(x,y,z)); } Utils.getLogger().info("Nest here at: " + dragonNestNether.generate(world, random, new BlockPos(x,y,z))); } } } } Edited August 30, 20178 yr by TheRPGAdventurer screenshots
August 30, 20178 yr Author Just now, TheRPGAdventurer said: So guys I thought my code wasn't working til I found the issue. You see, when I spawn my structure in the nether, It spawns above the bedrock on the uppermost layer of the nether not on the world below it. I have screenshots. public void generateNestAtNether(World world, Random random, int chunkX, int chunkZ) { int x = chunkX * 16 + random.nextInt(16); int z = chunkZ * 16 + random.nextInt(16); int xy = x >> 4; int zy = z >> 4; int height = world.getChunkFromChunkCoords(xy, zy).getHeight(new BlockPos(x & 15, 0, z & 15)); int y = height - 1; BlockPos pos = new BlockPos(chunkX, y, chunkZ); if(world.getBiomeForCoordsBody(new BlockPos (x,y,z)).getBiomeClass().equals(BiomeHell.class)) { if((random.nextInt(120) + 1) <= 1) { boolean place = true; for(int Y = 0; Y < 3; Y++) { for(int Z = 0; Z < 7; Z++) { for(int X = 0; X < 7; X++) { if(world.getBlockState(new BlockPos(X + x, Y + y + 1, Z + z)).getBlock() != Blocks.AIR) { place = false; } } } } if(place) { dragonNestNether.generate(world, random, new BlockPos(x,y,z)); } Utils.getLogger().info("Nest here at: " + dragonNestNether.generate(world, random, new BlockPos(x,y,z))); } } } } Also, how do I make my code give me the exact location of the structure instead of saying "Nest here at true" in the console. Utils.getLogger().info("Nest here at: " + dragonNestNether.generate(world, random, new BlockPos(x,y,z)));
August 30, 20178 yr 2 hours ago, TheRPGAdventurer said: int height = world.getChunkFromChunkCoords(xy, zy).getHeight(new BlockPos(x & 15, 0, z & 15)); The getHeight method returns (generally) the topmost solids block. In the nether, that's the bedrock on top of the world. If you want your structure to generate at a different altitude, you need to use a different y co-ordinate. 2 hours ago, TheRPGAdventurer said: Also, how do I make my code give me the exact location of the structure instead of saying "Nest here at true" in the console. Utils.getLogger().info("Nest here at: " + dragonNestNether.generate(world, random, new BlockPos(x,y,z))); The generate method returns a boolean. If you want to print a BlockPos, then put a BlockPos inside the logger statement. Edited August 30, 20178 yr by Jay Avery
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.