Infinite Chunk Loading

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

  1. If anyone finds the thread and needs the solution is to use this method.

    Thanks to DarkSeraphim for helping me with this.



    I am working on a SkyBlock plugin and I have updated my chunk generator so that there are barriers at layer 0. I also want to update an previously generated chunks by setting any blocks that are not barriers at layer 0 to barriers.

    You can see my code here

    Code (Text):
    @EventHandler
        public void onChunkLoad(ChunkLoadEvent event) {
            if (event.getWorld() == SkyBlock.p.getSkyBlockWorld()) {
                Chunk chunk = event.getChunk();
                int blockX = chunk.getX() << 4;
                int blockZ = chunk.getZ() << 4;

                for (int x = blockX; x < blockX + 16; x++) {
                    for (int z = blockZ; z < blockZ + 16; z++) {
                        Block block = new Location(SkyBlock.p.getSkyBlockWorld(), x, 0, z).getBlock();

                        if (block.getType() != Material.BARRIER) {
                            block.setType(Material.BARRIER);
                        }
                    }
                }
            }
        }

    I believe the issue is that there is an infinite loop created by this because the blocks that are being set at the edge of the chunk will update the physics and all of the blocks and some of the blocks are in a new chunk and this causes new chunks to be loaded and ultimately create an infinite loop of chunk loading.

    Edit: Full stack-trace

    If anyone has any ideas for how I could fix this it would be greatly appreciated
     
    #1 Lazertx, Jan 17, 2015
    Last edited: Jan 17, 2015
  2. Post the entire stack-trace
     
    • Like Like x 1
  3. I appreciate the help it fixed my issue.