Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[SOLVED][1.8] Ore Generation code


DanPerry1808
 Share

Recommended Posts

What is your problem? BlockPos is just a wrapper class that wraps x, y and z in one Object.

 

I'm having trouble with updating my generateSurface method, here's the code: private void generateSurface(World world, Random random, int blockX, int blockZ) {

for(int i = 0; i < 10; i++){

int Xcoord = blockX + random.nextInt(16);

int Ycoord = random.nextInt(28);

int Zcoord = blockZ + random.nextInt(16);

 

new WorldGenMinable(DanArmourMain.invisore, 4).generate(world, random, Xcoord, Ycoord, Zcoord);

}

 

}

 

hope this helps

Link to comment
Share on other sites

generate

now takes a BlockPos argument instead of 3 ints.

 

Sorry, I have lots of errors with this, I have no idea what's changed or what to change, here is my full class:

 

public class InvisOreWorldGeneration implements IWorldGenerator{

 

@Override

public void generate(Random random, int chunkX, int chunkZ, World world,

IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

switch(world.provider.getDimensionId()){

case -1 : generateNether(world, random, chunkX * 16, chunkZ * 16);

case 0 : generateSurface(world, random, chunkX * 16, chunkZ * 16);

}

 

}

 

private void generateSurface(World world, Random random, int blockX, int blockZ) {

for(int i = 0; i < 10; i++){

int Xcoord = blockX + random.nextInt(16);

int Ycoord = random.nextInt(28);

int Zcoord = blockZ + random.nextInt(16);

 

new WorldGenMinable(DanArmourMain.invisore, 4).generate(world, random, pos);

}

 

}

 

private void generateNether(World world, Random random, int i, int j) {

}

}

 

I've got an error on new WroldGenMineable because it needs invisore (my block) to be a block state. Also, inserting a BlockPos into the generate method means I have to put it into the generateSurface parameters, which in turn needs one in main generate method, which then causes an error with the @Override meaning that it no longer implements the needed method for IWorldGenerator.

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

To get the default block state (IBlockState) for your Block use the

getDefaultState

method.

For your BlockPos: all you need to do is wrap the 3 variables (Xcoord, Ycoord, Zcoord) into a BlockPos. Seriously.

 

Wow...such a simple change, an annoying one, but simple once it's been explained. Thank You. 8)

a.k.a. Sirius

width=400 height=82http://i.imgur.com/QRtYi6e.png[/img]

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.