Custom Chunk generation stops at 93%

Discussion in 'Plugin Development' started by olsyboy, Dec 30, 2015.

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

    olsyboy

    I am creating my own chunks using a chunk generator. However, for some reason it just stops.
    Here is all code that goes with it:
    ChunkCreator.java (open)

    Code:
    package me.olsyboy.t.generation;
    
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.block.Biome;
    import org.bukkit.generator.BlockPopulator;
    import org.bukkit.generator.ChunkGenerator;
    
    public class ChunkCreator extends ChunkGenerator {
    
        /**
         *
         * @param x
         * X co-ordinate of the block to be set in the array
         * @param y
         * Y co-ordinate of the block to be set in the array
         * @param z
         * Z co-ordinate of the block to be set in the array
         * @param chunk
         * An array containing the Block id's of all the blocks in the chunk. The first offset
         * is the block section number. There are 16 block sections, stacked vertically, each of which
         * 16 by 16 by 16 blocks.
         * @param material
         * The material to set the block to.
         */
        void setBlock(int x, int y, int z, byte[][] chunk, Material material) {
            //if the Block section the block is in hasn't been used yet, allocate it
            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) {
                // do nothing
            }
        }
    
        @Override
        /**
         * @param world
         * The world the chunk belongs to
         * @param rand
         * Don't use this, make a new random object using the world seed (world.getSeed())
         * @param biome
         * Use this to set/get the current biome
         * @param ChunkX and ChunkZ
         * The x and z co-ordinates of the current chunk.
         */
        public byte[][] generateBlockSections(World world, Random rand, int ChunkX,
                int ChunkZ, BiomeGrid biome) {
            world.setBiome(ChunkX*16, ChunkZ*16, Biome.FOREST);
            byte[][] chunk = new byte[world.getMaxHeight() / 16][];
            for (int x=0; x<16; x++) { //loop through all of the blocks in the chunk that are lower than maxHeight
                for (int z=0; z<16; z++) {
                    int maxHeight = 60; //how thick we want out flat terrain to be
                    for (int y=0;y<maxHeight;y++) {
                        setBlock(x,y,z,chunk,Material.STONE); //set the current block to stone
                    }
                }
            }
         
            return chunk;
        }
        /**
         * Returns a list of all of the block populators (that do "little" features)
         * to be called after the chunk generator
         */
        @Override
        public List<BlockPopulator> getDefaultPopulators(World world) {
            System.out.println("2");
            ArrayList<BlockPopulator> pops = new ArrayList<BlockPopulator>();
            pops.add(new GrassPopulator());
            pops.add(new RoadPopulator());
            return pops;
        }
    }
    

    RoadPopulator.java (open)

    Code:
    package me.olsyboy.t.generation;
    
    import java.util.Random;
    
    import org.bukkit.Chunk;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.generator.BlockPopulator;
    
    public class RoadPopulator extends BlockPopulator {
        @Override
        public void populate(World world, Random rand, Chunk chunk) {
            for (int x = 0; x < 16; x++) {
                for (int z = 0; z < 16; z++) {
                    int realX = x + chunk.getX() * 16; // find the world location of
                                                       // chunk location x
                    int realZ = z + chunk.getZ() * 16;
                    if (realX % 151 == 0 || realZ % 151 == 0) {
                        if (realX < (151 * 10 + 1) && realZ < (151*10 + 1) && realX > -01 && realZ > -01) {
                            world.getBlockAt(realX, 61, realZ).setType(Material.SEA_LANTERN);
                            world.getBlockAt(realX, 61, realZ).setTypeIdAndData(44, (byte) 1, true);
                        }
                    }
                }
            }
        }
    }
    

    GrassPopulator.java (open)
    Code:
    package me.olsyboy.t.generation;
    
    import java.util.Random;
    
    import org.bukkit.Chunk;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.block.Biome;
    import org.bukkit.generator.BlockPopulator;
    
    public class GrassPopulator extends BlockPopulator {
    
        [USER=32110]@Override[/USER]
        public void populate(World world, Random rand, Chunk chunk) {
            for (int x = 0; x < 16; x++) {
                for (int z = 0; z < 16; z++) {
                    int realX = x + chunk.getX() * 16; // find the world location of
                                                       // chunk location x
                    int realZ = z + chunk.getZ() * 16;
                    world.getBlockAt(realX, 60, realZ).setType(Material.GRASS);
                }
            }
        }
    }
    


    log (open)

    Code:
    [11:39:24] [Server thread/INFO]: Starting minecraft server version 1.8.7
    [11:39:24] [Server thread/WARN]: To start the server with more ram, launch it as "java -Xmx1024M -Xms1024M -jar minecraft_server.jar"
    [11:39:24] [Server thread/INFO]: Loading properties
    [11:39:24] [Server thread/INFO]: Default game type: SURVIVAL
    [11:39:24] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-6d0ae89-a03743b (MC: 1.8.7) (Implementing API version 1.8.7-R0.1-SNAPSHOT)
    [11:39:24] [Server thread/INFO]: Debug logging is disabled
    [11:39:24] [Server thread/INFO]: Using 4 threads for Netty based IO
    [11:39:24] [Server thread/INFO]: Server Ping Player Sample Count: 12
    [11:39:24] [Server thread/INFO]: Generating keypair
    [11:39:25] [Server thread/INFO]: Starting Minecraft server on *:25565
    [11:39:25] [Server thread/INFO]: Using default channel type
    [11:39:25] [Server thread/INFO]: Set PluginClassLoader as parallel capable
    [11:39:25] [Server thread/INFO]: [BarAPI] Loading BarAPI v3.3
    [11:39:25] [Server thread/INFO]: [t] Loading tv1.0
    [11:39:25] [Server thread/INFO]: [t] Enabling tv1.0
    [11:39:25] [Server thread/INFO]: **** Beginning UUID conversion, this may take A LONG time ****
    [11:39:25] [Server thread/INFO]: Preparing level "world"
    [11:39:25] [Server thread/INFO]: -------- World Settings For [world] --------
    [11:39:25] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [11:39:25] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [11:39:25] [Server thread/INFO]: Mob Spawn Range: 4
    [11:39:25] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [11:39:25] [Server thread/INFO]: Cane Growth Modifier: 100%
    [11:39:25] [Server thread/INFO]: Melon Growth Modifier: 100%
    [11:39:25] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [11:39:25] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [11:39:25] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [11:39:25] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [11:39:25] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [11:39:25] [Server thread/INFO]: Anti X-Ray: true
    [11:39:25] [Server thread/INFO]:     Engine Mode: 1
    [11:39:25] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [11:39:25] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [11:39:26] [Server thread/INFO]: View Distance: 10
    [11:39:26] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [11:39:26] [Server thread/INFO]: Item Despawn Rate: 6000
    [11:39:26] [Server thread/INFO]: Item Merge Radius: 2.5
    [11:39:26] [Server thread/INFO]: Random Lighting Updates: false
    [11:39:26] [Server thread/INFO]: Structure Info Saving: true
    [11:39:26] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [11:39:26] [Server thread/INFO]: Max TNT Explosions: 100
    [11:39:26] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [11:39:26] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [11:39:26] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [11:39:26] [Server thread/INFO]: Sending up to 10 chunks per packet
    [11:39:26] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [11:39:26] [Server thread/INFO]: Max Entity Collisions: 8
    [11:39:26] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [11:39:26] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [11:39:26] [Server thread/INFO]: Clear tick list: false
    [11:39:26] [Server thread/INFO]: Experience Merge Radius: 3.0
    [11:39:26] [Server thread/INFO]: -------- World Settings For [world_nether] --------
    [11:39:26] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [11:39:26] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [11:39:26] [Server thread/INFO]: Mob Spawn Range: 4
    [11:39:26] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Cane Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Melon Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Anti X-Ray: true
    [11:39:26] [Server thread/INFO]:     Engine Mode: 1
    [11:39:26] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [11:39:26] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [11:39:26] [Server thread/INFO]: View Distance: 10
    [11:39:26] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [11:39:26] [Server thread/INFO]: Item Despawn Rate: 6000
    [11:39:26] [Server thread/INFO]: Item Merge Radius: 2.5
    [11:39:26] [Server thread/INFO]: Random Lighting Updates: false
    [11:39:26] [Server thread/INFO]: Structure Info Saving: true
    [11:39:26] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [11:39:26] [Server thread/INFO]: Max TNT Explosions: 100
    [11:39:26] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [11:39:26] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [11:39:26] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [11:39:26] [Server thread/INFO]: Sending up to 10 chunks per packet
    [11:39:26] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [11:39:26] [Server thread/INFO]: Max Entity Collisions: 8
    [11:39:26] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [11:39:26] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [11:39:26] [Server thread/INFO]: Clear tick list: false
    [11:39:26] [Server thread/INFO]: Experience Merge Radius: 3.0
    [11:39:26] [Server thread/INFO]: -------- World Settings For [world_the_end] --------
    [11:39:26] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [11:39:26] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [11:39:26] [Server thread/INFO]: Mob Spawn Range: 4
    [11:39:26] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Cane Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Melon Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [11:39:26] [Server thread/INFO]: Anti X-Ray: true
    [11:39:26] [Server thread/INFO]:     Engine Mode: 1
    [11:39:26] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [11:39:26] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [11:39:26] [Server thread/INFO]: View Distance: 10
    [11:39:26] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [11:39:26] [Server thread/INFO]: Item Despawn Rate: 6000
    [11:39:26] [Server thread/INFO]: Item Merge Radius: 2.5
    [11:39:26] [Server thread/INFO]: Random Lighting Updates: false
    [11:39:26] [Server thread/INFO]: Structure Info Saving: true
    [11:39:26] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [11:39:26] [Server thread/INFO]: Max TNT Explosions: 100
    [11:39:26] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [11:39:26] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [11:39:26] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [11:39:26] [Server thread/INFO]: Sending up to 10 chunks per packet
    [11:39:26] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [11:39:26] [Server thread/INFO]: Max Entity Collisions: 8
    [11:39:26] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [11:39:26] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [11:39:26] [Server thread/INFO]: Clear tick list: false
    [11:39:26] [Server thread/INFO]: Experience Merge Radius: 3.0
    [11:39:26] [Server thread/INFO]: Preparing start region for level 0 (Seed: -3789833037238244731)
    [11:39:27] [Server thread/INFO]: Preparing spawn area: 44%
    [11:39:27] [Server thread/INFO]: Preparing start region for level 1 (Seed: -3789833037238244731)
    [11:39:28] [Server thread/INFO]: Preparing spawn area: 83%
    [11:39:29] [Server thread/INFO]: Preparing start region for level 2 (Seed: -3789833037238244731)
    [11:39:29] [Server thread/INFO]: [BarAPI] Enabling BarAPI v3.3
    [11:39:29] [Server thread/INFO]: [BarAPI] Loaded
    [11:39:29] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [11:39:29] [Server thread/INFO]: Done (3.562s)! For help, type "help" or "?"
    [11:39:29] [Server thread/INFO]: -------- World Settings For [Plots] --------
    [11:39:29] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [11:39:29] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [11:39:29] [Server thread/INFO]: Mob Spawn Range: 4
    [11:39:29] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [11:39:29] [Server thread/INFO]: Cane Growth Modifier: 100%
    [11:39:29] [Server thread/INFO]: Melon Growth Modifier: 100%
    [11:39:29] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [11:39:29] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [11:39:29] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [11:39:29] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [11:39:29] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [11:39:29] [Server thread/INFO]: Anti X-Ray: true
    [11:39:29] [Server thread/INFO]:     Engine Mode: 1
    [11:39:29] [Server thread/INFO]:     Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
    [11:39:29] [Server thread/INFO]:     Replace Blocks: [1, 5]
    [11:39:29] [Server thread/INFO]: View Distance: 10
    [11:39:29] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [11:39:29] [Server thread/INFO]: Item Despawn Rate: 6000
    [11:39:29] [Server thread/INFO]: Item Merge Radius: 2.5
    [11:39:29] [Server thread/INFO]: Random Lighting Updates: false
    [11:39:29] [Server thread/INFO]: Structure Info Saving: true
    [11:39:29] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [11:39:29] [Server thread/INFO]: Max TNT Explosions: 100
    [11:39:29] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [11:39:29] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [11:39:29] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
    [11:39:29] [Server thread/INFO]: Sending up to 10 chunks per packet
    [11:39:29] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [11:39:29] [Server thread/INFO]: Max Entity Collisions: 8
    [11:39:29] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
    [11:39:29] [Server thread/INFO]: Chunks to Grow per Tick: 650
    [11:39:29] [Server thread/INFO]: Clear tick list: false
    [11:39:29] [Server thread/INFO]: Experience Merge Radius: 3.0
    [11:39:29] [Server thread/INFO]: Preparing start region for level 3 (Seed: 3611841485514589073)
    [11:39:30] [Server thread/INFO]: Preparing spawn area for Plots, 0%
    [11:39:31] [Server thread/INFO]: Preparing spawn area for Plots, 4%
    [11:39:32] [Server thread/INFO]: Preparing spawn area for Plots, 12%
    [11:39:33] [Server thread/INFO]: Preparing spawn area for Plots, 16%
    [11:39:34] [Server thread/INFO]: Preparing spawn area for Plots, 20%
    [11:39:35] [Server thread/INFO]: Preparing spawn area for Plots, 28%
    [11:39:36] [Server thread/INFO]: Preparing spawn area for Plots, 32%
    [11:39:37] [Server thread/INFO]: Preparing spawn area for Plots, 40%
    [11:39:38] [Server thread/INFO]: Preparing spawn area for Plots, 52%
    [11:39:39] [Server thread/INFO]: Preparing spawn area for Plots, 69%
    [11:39:40] [Server thread/INFO]: Preparing spawn area for Plots, 81%
    [11:39:41] [Server thread/INFO]: Preparing spawn area for Plots, 93%
    


    If anyone can help I would be very appreciative.
    I did some debugging messages, and it seemed to stop after a lot of road population. But I don't really know the cause of this.
     
  2. Offline

    olsyboy

    The rest of the server works, but it makes a normal world.
     
  3. Offline

    mcdorli

    Try use generateExtBlockSections, instead of generateBlockSections. It uses short instead ofbytes, so you can use item id's over 255.
    BTW.:
    You should look into how spigot world generation works, it's quite different, and a bit friendlier
    And you shouldn't just copy code from the "definitive guide to world generation" tutorial
     
  4. Offline

    olsyboy

    Thanks :D I have never done it before lol
    Have you got any resource I could use?
     
  5. Offline

    mcdorli

Thread Status:
Not open for further replies.

Share This Page