Removing Specific type of block globally

Discussion in 'Spigot Plugin Development' started by Technerder, May 27, 2017.

  1. i am trying to remove all tall grass in a world, i understand this js extremely resource intensive, i looked online and saw some code on bukkit forums:

    Code (Text):

    @EventHandler
        public void onChunkLoaded(final ChunkLoadEvent c) {
            Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    Chunk chunk = c.getChunk();
                    for(int x = 0; x <= 16; x++) {
                        for(int y = 0; y <= 256; y++) {
                            for(int z = 0; z <= 16; z++) {
                                Block b = chunk.getBlock(x, y, z);
                                if(b.getType() == Material.MELON_BLOCK) {
                                    ParticleEffect.HEART.display(b.getLocation(), 1.0F, 2.0F, 1.0F, 1, 10);
                                }
                            }
                        }
                    }
                }
            }, 0, 1);
        }
    However is this the best way to do it? Using s bukkit runnable is somewhat better. However is there any other way i can remove a specific block from the world?
     
  2. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    Why use a runnable? It should work without that.
     
  3. this is a completly different thing.
    it plays a heart effect for every melon block in the chunk.
     
  4. I fear this would cause a bunch of lag.
     
    • Agree Agree x 1
  5. I know, I found this code on bukkit forums, this gets the location and summons particles, I can modify his to set that block to air instead!

    that's why I am looking for an alternative.
     
  6. i would recommend overriding the BiomeDecorator for every BiomeBases.
    Or WorldGenTallPlant.
    haven't done something similar but that's the way of how they are generated.