# How do I generate blocks onthe surface (Like flowers)

## Recommended Posts

Hi,

My question is that I wanted to create a plant (StrawberryBush) that grows on top of grass, how do I do this?

I think its the easiest way with the events, but I don't know how to do this.

Thanks.

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

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

##### Share on other sites

```//Appears to be x coordinate (offset by +-  I'd assume from the middle of the chunk
int i1 = p_76484_3_ + p_76484_2_.nextInt( - p_76484_2_.nextInt(;
//y +- 4 (probably from top block at center of chunk
int j1 = p_76484_4_ + p_76484_2_.nextInt(4) - p_76484_2_.nextInt(4);
//z coordinate of the chunk +- 8 (once again, probably from center)
int k1 = p_76484_5_ + p_76484_2_.nextInt( - p_76484_2_.nextInt(;

//If the the block at given location is air and the block below it is grass (And as a final check, can we really put it there) spawn the block!
if (p_76484_1_.isAirBlock(i1, j1, k1) && p_76484_1_.getBlock(i1, j1 - 1, k1) == Blocks.grass && Blocks.pumpkin.canPlaceBlockAt(p_76484_1_, i1, j1, k1))
{```

I have no idea what

`p_76484_2_.nextInt(4),`

inside the set block is.

##### Share on other sites

I have no idea what p_76484_2_.nextInt(4), inside the set block is.

Setting a random metadata facing, perhaps.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

DO NOT PM ME WITH PROBLEMS. No help will be given.

##### Share on other sites

Hi,

Do i need to register it too before this actually works?

I think of

`world.setBlock(i1, j1, k1, Chef.bushStrawberryBush, random.nextInt(75), 10);`

that the

`random.nextInt(75), 10)`

the chance to spawn is.

Thanks.

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

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

##### Share on other sites

Use an event, an event is something that happens in minecraft like a chuk load or terain gen, that is how they spawn caves and caverns and mineshaft, well you get the idea. there is a tutorial on them in the forge or a really good one @ http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-forge-1-6-4-1-8-eventhandler-and (soory if it isnt a hyper link) but that contains things like terrain gen. So TRY IT OUT .But yes that needs to be in some sort of forge-registered class and a tickhandler probobly that watches Chunk.Load but would be very complicated, i would highly suggest that you use events though. They greatly reduce lag be being called upon only when needed. This is irrelevant but FYI, strawberries aren't grown on bushes

##### Share on other sites

Ok, I will try it out.

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

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

##### Share on other sites

Which event do I use?

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

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

##### Share on other sites

Decoratebiome event, right?

If you ask me, I think this is where it generates the pumpkins and things like that.

```    @HasResult
public static class Decorate extends DecorateBiomeEvent
{
/** Use CUSTOM to filter custom event types
*/
public static enum EventType { BIG_SHROOM, CACTUS, CLAY, DEAD_BUSH, LILYPAD, FLOWERS, GRASS, LAKE, PUMPKIN, REED, SAND, SAND_PASS2, SHROOM, TREE, CUSTOM }

public final EventType type;

public Decorate(World world, Random rand, int worldX, int worldZ, EventType type)
{
super(world, rand, worldX, worldZ);
this.type = type;
}
}
}[/Code]```

but how do I let him generate my own strawberrybush?

Thanks.

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

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

##### Share on other sites

I've never worked with this event before, sorry. I dont like random stuff that much. But that i do not know but i do know that you can but some registery is involved hence;

``` public static enum EventType

{
BIG_SHROOM,  CACTUS,  CLAY,  DEAD_BUSH,  LILYPAD,  FLOWERS,  GRASS,  LAKE,  PUMPKIN,  REED,  SAND,  SAND_PASS2,  SHROOM,  TREE,  CUSTOM // < that;

private EventType() {}
}```

##### Share on other sites

Is there a reason you dont use IWorldGenerator? That would make things easier

## 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.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

• ### Posts

• I did copy/past the log when I ran the cmd, I just didnt want to assume that was the kind of help offered.
• If you want our help, you need to post the output of the command. I believe windows has support for using pipes to redirect output to a file, something like? jstack pid > output.txt where pid is the process id.
• if (player.isShiftKeyDown() && hand == InteractionHand.MAIN_HAND && block == Blocks.MOSS_BLOCK){ if (!level.isClientSide){ player.drop(ItemInit.STONE_PEBBLE.get().getDefaultInstance(), false); level.playSound(null, event.getPos(), SoundEvents.MOSS_PLACE, SoundSource.BLOCKS, 1f, 1f); //player null plays to everyon near block } } GOT IT! Thanks all. The player being passed in the first code I commented stopped it from playing to me. The link you send me @warjort finished it up for me!
• That code only plays the sound on the client for the player dropping the pebble. https://forge.gemwire.uk/wiki/Sounds#Level
• if (player.isShiftKeyDown() && hand == InteractionHand.MAIN_HAND && block == Blocks.MOSS_BLOCK){ if (!level.isClientSide){ player.drop(ItemInit.STONE_PEBBLE.get().getDefaultInstance(), false); } else { level.playSound(player, event.getPos(), SoundEvents.MOSS_PLACE, SoundSource.BLOCKS, 1f, 1f); } }   That worked! Thanks. I'm not quite sure why though? Does it have to do with sounds only being able to play on the client/server?

• 9
• 4
• 0
• 0
• 4
• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...