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

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.

×   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

• Its when minecraft tries loading patchouli- Im on the correct version of it and everything is up to date
• I cannot get my custom entities to spawn naturally in the world. They spawn successfully from a spawn egg. I have tried a video and did what they said, but still doesn't work.   I put this in the entity's class: public static boolean canSpawn(EntityType<CarnAchillobator> entityType, ServerLevelAccessor levelAccessor, MobSpawnType mobSpawnType, BlockPos pos, RandomSource randomSource) { return Monster.checkMonsterSpawnRules(entityType, levelAccessor, mobSpawnType, pos, randomSource); }   I this in the main class: @SubscribeEvent public static void registerSpawnPlacementsEvent(@NotNull SpawnPlacementRegisterEvent event) { event.register(ModEntities.ACHILLOBATOR.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.WORLD_SURFACE, CarnAchillobator::canSpawn, SpawnPlacementRegisterEvent.Operation.AND); In the modid/biome_modifier directory, spawn_achillobator.json file: { "type": "forge:add_spawns", "biomes": [ "minecraft:jungle", "minecraft:sparse_jungle", "minecraft:windswept_forest", "minecraft:dark_forest", "minecraft:old_growth_birch_forest" ], "spawners": { "type": "wilddinos:achillobator", "weight": 100, "minCount": 1, "maxCount": 1 } }
• https://pastebin.com/dGHrxZMC
• Whenever i use physics mod in minecraft fabric it doesn't crash the game or anything like that but, it crashes my whole pc. It doesn't crash immediately, whenever i play for a long time like let's say about 10 - 30 minutes before it crashes.

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...