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

I'm trying to generate my bush block (like flower) on surface of the forest biome. It must generate on grass block only. I can't get it to work. Any ideas? I tried this:

 

 

public Random GenRand;
public int GenRandNum = 0;

public void generateSurface(World world, Random random, int i,int j) {

	GenRand = new Random();
	GenRandNum = GenRand.nextInt(50)+1;

	if(GenRandNum < 15) {
BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(i, j);
		if(biomegenbase == BiomeGenBase.forest) {
		for (int l=0; l<GenRandNum; l++) {
			int Xcoord1 = i + random.nextInt(16);
			int Ycoord1 = random.nextInt(90);
			int Zcoord1 = j + random.nextInt(16);

			if(world.getBlock(Xcoord1, Ycoord1-1, Zcoord1)==Blocks.grass) {
				(new WorldGenFlowers(PieCraft.RaspberryBush)).generate(world, random, Xcoord1, Ycoord1, Zcoord1);
			}
		}
	}

	}
}

 

 

But no luck..

_         

___ ___| |__  _ __ 

/ __/ __| '_ \| '_ \

\__ \__ \ | | | | | |

|___/___/_| |_|_| |_|

Hi

 

I'd like to mention first, that it is _java convention_ to name variable in camelCase.

 

Look at the point were you get your y-coordinate. Is it normal to randomly pick the height?

Wouldn't it be better to get the 'surface' block there?

 

Thus try the following:

world.setBlock(x, world.getTopSolidBlock(x,z)+1, z, /*yourblock*/, /*your meta*/, /*flag*/ );
//for the flag see: world.setBlock(int,int,int,Block,int,int);

 

Some other questions are:

- Is your worldgen correctly registered?

- Does your bush check if it can sustain

 

For the future: some System.out.println(msg) mostly help to see what is happening...

 

I hope my reply was helpful

Sincerely -pick

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

  • Author

- I don't have world gen, this is the method in my main class

- I don't know what that is

_         

___ ___| |__  _ __ 

/ __/ __| '_ \| '_ \

\__ \__ \ | | | | | |

|___/___/_| |_|_| |_|

G Day

 

Excuse me, worldgen = WorldGenerator class, the class you are talking about.

 

Well, each the block class delivers some methods you could overwrite. One of them is _canPlaceBlockOn(Block test)_.

So far I can tell you, there are two ways to define 'it must be grass underneath': while the world is being decorated (within your WorldGenerator) or within the block class itself (by above mentioned method).

 

Did you try the suggested code in my previous reply?

 

To push you a little bit more into the assumed 'correct' direction:

 

//within the generateX method:
int y = world.getTopSolidOrLiquidBlock(x,z);//y now has the coordinate of the topmost solid or liquid block
if(world.getBlock(x,y,z) == /*desired block, may grass*/){
    world.setBlock(x,y+1,z, /*bush*/);
    // y+1 because you want the bush _above_ grass, right?
}

 

Remember: Don't just copy-paste the example!

 

Hope this time I was more precise

Sincerely -pick

Since English is not my mother tongue, my sentences may are confusing.

 

I'm coding java for a long time now - just MC and forge stop me sometimes.

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.