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

Hi,

 

I have some trouble with generating my bush (strawberry bush) into the world and let it randomly spawn uppon the surface.

I took the code of WorldGenPumpkin and changed it but that does not work.

 

This is my code:

 

package com.chef.mod.generate;

import java.util.Random;

import com.chef.mod.Chef;

import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

public class BushGeneration extends WorldGenerator {
public int bugger;
    private static final String __OBFID = "CL_00000428";

    public boolean generate(World world, Random random, int x, int y, int z) {
        for (int l = 0; l < 64; ++l)
        {
            int i1 = x + random.nextInt( - random.nextInt(;
            int j1 = y + random.nextInt(4) - random.nextInt(4);
            int k1 = z + random.nextInt( - random.nextInt(;

            if (world.isAirBlock(i1, j1, k1) && world.getBlock(i1, j1 - 1, k1) == Blocks.grass && Chef.bushStrawberryBush.canPlaceBlockAt(world, i1, j1, k1)) {
                world.setBlock(i1, j1, k1, Chef.bushStrawberryBush, random.nextInt(75), 10);
            }
        }

        return true;
    }
}

 

Thanks.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

int j1 = y + random.nextInt(4) - random.nextInt(4);

 

Thats where u set the height, ofc your flowers get set in the groung

use the method

world.getHeightValue()

to get the height of a position

  • Author

I need to register it too, right?

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

  • Author

How do I do this then?

 

Cause GameRegistry.registerWorldGenerator(new BushGeneration(), 0);

 

Gives an error that I need to implements IWorldGenerator?

Or iam just being stupid. :P

 

Thanks.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

  • Author

Thanks.

 

Now it generates strawberry bushes, but I can't control how much bushes are generated.

(minimal bushes to spawn, maximum bushes to spawn and the chance to spawn)

No mather what I use as values, it seems to have no effect.

 

Thanks.

 

Code:

 

http://pastebin.com/f0yKEK72

 

http://pastebin.com/d1buwQVv

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

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.