World Generation - Data Values

Discussion in 'Plugin Development' started by nathanaelps, Oct 23, 2012.

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

    nathanaelps

    Is it possible to assign a data value to a block during world generation? Let's imagine that I want a solid floor of birch logs across my entire world, and that's it:

    Code:
    void setBlock(short[][] result, int x, int y, int z, short blkid) { //setBlock by MatorKaleen on bukkit.org
      if (result[y >> 4] == null) {
        result[y >> 4] = new short[4096]; }
      result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
    }
     
    @Override
    public short[][] generateExtBlockSections(World world, Random random, int  chunkX, int chunkZ, BiomeGrid biomes){
     
      int sectionVolume = world.getMaxHeight()/16*256; //since each [] of the ouput is 1/16th the world height
      short[][] output = new short[16][sectionVolume];
      output[0][0] = 0; //Otherwise, returns an empty output, which makes MC think it's a world hole.
     
      int y=0;
      for(int x=0; x<16; x++) {
        for(int z=0; z<16; z++) {
          setBlock(output, x,y,z, (short) 17); //17 is log
     
        }
      }
     
      return output;
    
    This makes a solid floor of OAK logs, since I haven't set block data.
    Is it possible to set block data on world generation?
    (as it is, I'm using a block populator instead, but that seems... like foolish complication.)

    ~~edited for formatting problems
     
  2. Offline

    MatorKaleen

    Nope, thats not possible. You can only access the block values later, either with a block populator or with a delayed task.

    Mator
     
  3. world.getMaxHeight()/16*256
    the *256 should be gone

    EDIT: I dont get your calculation now, I think the getMAxWorld size dont belongs to there
     
  4. Offline

    nathanaelps

    Maybe I'm doing it wrong--That in case the world height has been set (in server.properties) to something besides 256. It translates to:

    Maximum world height split into 16 areas, times the x and z width of the chunk.
    world.getMaxHeight / 16 * 16 * 16
    world.getMaxheight / 16 * 256

    Does that make sense?

    Darn.
    Thanks.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  5. the size of 1 chunk section is always the same, as far I know....
     
  6. Offline

    nathanaelps

    Hm. Wiki agrees with you. What was that big to-do that happened when we changed to Anvil format? Wasn't there suddenly "the ability to make worlds as tall as 4096 meters"? And why does the server.properties have the setting at all?
     
  7. Offline

    Hoolean

    The server.properties one applies for block placement I believe! Also, with the right generator, I believe you could go as high as 4096 but it would be extremely slow and laggy :D
     
  8. Offline

    MatorKaleen

    With the anvil world type you can create worlds as high, as you want.

    The easiest way to do this is this:
    Code:
    byte[][] result = new byte[world.getMaxHeight() / 16][];
    Check out this ;) *click*
     
    nathanaelps likes this.
  9. Offline

    nathanaelps

    Eh, I see! So it's not that there are always 16 "mini chunks" per chunk, it's that each "mini chunk" is 16x16x16, and thus 4096 blocks, regardless of how tall the world is. Good. I'll fix my code.
     
Thread Status:
Not open for further replies.

Share This Page