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

The Structure Itself: http://pastie.org/8306221

The Generation Class: http://pastie.org/8306224

 

Yes, the generator is registered.

 

The blocks generate and all, my problem here is with the Y value. I have been testing generation in a super flat world (as it is pure grass / dirt) and find that the blocks are generating anywhere between levels 1-4, whereas I would like them to be above ground at all times. How do I get this to happen? I assume some changes need to be done with the Y value, I've tinkered with it here and there, and am still not getting the product I'd like.

 

Thanks in advance.

world.getTopSolidOrLiquidBlock(x pos, z pos);  Gives you the height (y value) of the top block at the x/z position.

 

If you guys dont get it.. then well ya.. try harder...

  • Author

world.getTopSolidOrLiquidBlock(x pos, z pos);  Gives you the height (y value) of the top block at the x/z position.

 

That works, but now they are spawning a little too often for my taste ( every few blocks or so). How could I limit the amount per chunk?

 

Code now looks like:

 

private void generateSurface(World world, Random random, int i, int j) {
	int firstBlockXCoord = i + random.nextInt(16);
	//		int firstBlockYCoord = random.nextInt(256);
	int firstBlockZCoord = j + random.nextInt(16);
	new AirTempleStructure().generate(world, random, firstBlockXCoord, world.getTopSolidOrLiquidBlock(firstBlockXCoord, firstBlockZCoord) - 1, firstBlockZCoord);
}

private void generateSurface(World world, Random random, int i, int j) {
    if(random.nextInt(4) == 0){
	int firstBlockXCoord = i + random.nextInt(16);
	//		int firstBlockYCoord = random.nextInt(256);
	int firstBlockZCoord = j + random.nextInt(16);
	new AirTempleStructure().generate(world, random, firstBlockXCoord, world.getTopSolidOrLiquidBlock(firstBlockXCoord, firstBlockZCoord) - 1, firstBlockZCoord);
    }
}

In this case this means that every chunk has a 1/4 chance to spawn your structure. This ratio easily can be changed to your taste of course.

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

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.