Jump to content

[1.8] terrain generator how to spawn in thesurface ??


perromercenary00

Recommended Posts

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 ??

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.