jtjj222

http://forums.bukkit.org/threads/the-always-up-to-date-defin

Aug 17th, 2012
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.01 KB | None | 0 0
  1. /**
  2. *  @author jtjj222
  3. *  As part of my series on terrain generation
  4. *  http://forums.bukkit.org/threads/the-always-up-to-date-definitive-guide-to-terrain-generation-part-one-prerequisites-and-setup.93982/
  5. *  Enjoy, use it as much as you want.
  6. */
  7.  
  8. public class BasicChunkGenerator extends ChunkGenerator {
  9.  
  10.     /**
  11.      *
  12.      * @param x
  13.      * X co-ordinate of the block to be set in the array
  14.      * @param y
  15.      * Y co-ordinate of the block to be set in the array
  16.      * @param z
  17.      * Z co-ordinate of the block to be set in the array
  18.      * @param chunk
  19.      * An array containing the Block id's of all the blocks in the chunk. The first offset
  20.      * is the block section number. There are 16 block sections, stacked vertically, each of which
  21.      * 16 by 16 by 16 blocks.
  22.      * @param material
  23.      * The material to set the block to.
  24.      */
  25.     void setBlock(int x, int y, int z, byte[][] chunk, Material material) {
  26.         if (chunk[y >> 4] == null)
  27.             chunk[y >> 4] = new byte[16 * 16 * 16];
  28.         if (!(y <= 256 && y >= 0 && x <= 16 && x >= 0 && z <= 16 && z >= 0))
  29.             return;
  30.         try {
  31.             chunk[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = (byte) material
  32.                     .getId();
  33.         } catch (Exception e) {
  34.             // do nothing
  35.         }
  36.     }
  37.  
  38.     @Override
  39.     /**
  40.      * @param world
  41.      * The world the chunk belongs to
  42.      * @param rand
  43.      * Don't use this, make a new random object using the world seed (world.getSeed())
  44.      * @param biome
  45.      * Use this to set/get the current biome
  46.      * @param ChunkX and ChunkZ
  47.      * The x and z co-ordinates of the current chunk.
  48.      */
  49.     public byte[][] generateBlockSections(World world, Random rand, int ChunkX,
  50.             int ChunkZ, BiomeGrid biome) {
  51.         return null;
  52.     }
  53.  
  54.     /**
  55.      * Returns a list of all of the block populators (that do "little" features)
  56.      * to be called after the chunk generator
  57.      */
  58.         @Override
  59.         public List<BlockPopulator> getDefaultPopulators(World world) {
  60.             ArrayList<BlockPopulator> pops = new ArrayList<BlockPopulator>();
  61.             //Add Block populators here
  62.             return pops;
  63.         }
  64. }
Add Comment
Please, Sign In to add comment