Solved WorldGen: create a "plot" then empty chunks

Discussion in 'Plugin Development' started by Thej0y, Jun 14, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Thej0y

    Hi,

    I'm trying to make a world generator that would load (example)4 chunks (2x2) and then leave the rest of chunks empty.

    I can't find how to get the chunk position in world. Whant i'm trying to do is something like this:

    ** this code is just to give an idea, it actually dont work and been written directly on here...
    Code:
     
          If(chunkPosX <= 2 && chunkPosZ <= 2){
              // example of my world generating settings
                for (x = 0; x < 16; x++){
                    for (z = 0; z < 16; z++){
                        setBlock(result, x, 64, z, (byte) Material.BEDROCK.getId());
                    }
                }
                for (x = 0; x < 16; x++){
                    for (z = 0; z < 16; z++){
                        setBlock(result, x, 65, z, (byte) Material.GRASS.getId());
                    }
                }
              // example end
          }else{
                for (x = 0; x < 16; x++){
                    for (z = 0; z < 16; z++){
                      for(y = 0;y<=256;y++){
                            setBlock(result, x, y, z, (byte) Material.AIR.getId());
                        }
                    }
                }
     
          }
    
    in this code, the if() statement is what i'm trying to do :p

    Edit: would it be better to create an empty world THEN add a land?

    Thanks for you help :)
     
  2. Offline

    bennie3211


    I think its easier to make a empty world and then add your 4 chunks.
     
  3. Offline

    Zacky1

    It all depends on how you plan to use this, are you going to use it to generate new chunks? or is the world going to be "locked" with 5 chunks (from what I understood)...

    If the answer is yes (aka generate new chunks) then you would need to create a chunk generator.. your if statement is completely wrong though, chunk creation starts at 0, 0. So you could just check if the current chunk is 0, 0 and if it is set the material to air...

    Code snippit perhaps:
    Code:java
    1. if{chunkPosX == 0 && chunkPosZ == 0{
    2. for(x=0; x<16; x++){
    3. for(z=0; z<16; z++{
    4. setBlock(Material.Air);
    5. }
    6. }
    7. }else{
    8. //setbedrock
    9. }


    But then your chunk generation is being delayed everytime it's being ran since it has to check an extra statement... but yeah, thats up to you
     
Thread Status:
Not open for further replies.

Share This Page