Jump to content

Generate block on the surface instead of in the ground (Just like flowers)


Kander16

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.