Jump to content

Recommended Posts

Posted (edited)

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)));
			}
		}
    } 
}

 

2017-08-30_01.40.57.png

Edited by TheRPGAdventurer
screenshots
Posted
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)));
			}
		}
    } 
}

 

2017-08-30_01.40.57.png

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)));
Posted (edited)
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 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.