Barrier World Generator

Discussion in 'Spigot Plugin Development' started by Lazertx, Jan 15, 2015.

  1. I am working on a void world generator that has a layer of barriers at layer zero and it works with any other block other than barriers. With barriers it just shows up as air.

    Here is my code for the generator
    Note: The %2 thing is just to show me that some blocks will generate at layers 0, but barriers won't.
    Code (Text):
    class SkyBlockGenerator extends ChunkGenerator {

        public byte[][] generateBlockSections(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) {
            byte[][] result = new byte[world.getMaxHeight() / 16][];
            for(int x = 0; x < 16; x++) {
                for(int z = 0; z < 16; z++) {
                    if (x % 2 == 0 && z % 2 == 0) {
                        setBlock( x, 1, z, result, Material.BARRIER);
                    } else {
                        setBlock( x, 1, z, result, Material.DIAMOND_BLOCK);
                    }
                }
            }
            return result;
        }

        void setBlock(int x, int y, int z, byte[][] chunk, Material material) {
            if (chunk[y >> 4] == null)
                chunk[y >> 4] = new byte[16 * 16 * 16];
            if (!(y <= 256 && y >= 0 && x <= 16 && x >= 0 && z <= 16 && z >= 0))
                return;
            try {
                chunk[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = (byte) material.getId();
            } catch (Exception e) {
            }
        }
    }
     
     
  2. Not a problem :)