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

good nigths

im a little newby whit terrain generators and im using the guide from

http://www.orangetutorial.com/world-generation/

 

well i alredy has done this code and im generating a block underground using

 

WorldGenMinable minable = new WorldGenMinable(MercenaryModBlocks.girable.getDefaultState() , (minVeinSize + random.nextInt(maxVeinSize - minVeinSize))  );

 

actualy a i wanna spwn a block on the surface to spawn and structure from this block

what object of  WorldGen i must use to spawn a block on the surface ??

Hi,

this is fairly simple.

first of all, you can use this to get the position right on the surface


BlockPos pos = new BlockPos(chunkX*16, 0, chunkZ*16);
pos = world.getHorizon(pos);

 

Now lets say, you want to have little pillar out of cobblestone, lets create a small class:

 

public class CobblePillar extends WorldGenerator
{
@Override
public boolean generate(World world, Random random, BlockPos pos)
{
     for (int i=0; i<=5; i++)
     {
           world.setBlockState(pos.add(0, i, 0), Blocks.cobblestone.getDefaultState(), 2);
     }
     return true;
}
}


 

Now, lets call the code in your generator class:

 


CobblePillar pillar = new CobblePillar();

pillar.generate(world, random, pos);

 

This would be it, have fun :)

  • Author

hay

i solved it on other way 

 

            BlockPos posM = world.getTopSolidOrLiquidBlock(pos);

            world.setBlockState(posM, MercenaryModBlocks.hierbaVerde.getDefaultState() );

            minable.generate(world, random, posM );

 

the trou ble is that im using minable  WorldGenMinable and its spawn to many  in the surface the others dont semm to fit how im triying to do i think i have to spend mi time doing mi own WorldGenMercenary or something like

Those sentences though. xD

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

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.