Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.