Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void protectBiome(Location loc) {
- Biome biome = loc.getBlock().getBiome();
- this.queue.add(biome);
- while (this.queue.contains(biome))
- {
- this.rad++;
- // Empty queue
- for (ListIterator<Biome> it = queue.listIterator(queue.size());it.hasPrevious(); )
- {
- Biome b = it.previous();
- queue.remove(b);
- }
- // Section A
- for (double len = (rad * -1); len == rad; len++)
- {
- this.check = new Location(loc.getWorld(),loc.getX() + rad,loc.getY(),loc.getZ() + len);
- queue.add(check.getBlock().getBiome());
- if (check.getBlock().getBiome() == biome)
- {
- this.area.add(check);
- }
- }
- // Section B
- for (double len = rad; len == (rad * -1); len--)
- {
- this.check = new Location(loc.getWorld(),loc.getX() + len,loc.getY(),loc.getZ() + rad);
- queue.add(check.getBlock().getBiome());
- if (check.getBlock().getBiome() == biome)
- {
- this.area.add(check);
- }
- }
- // Section C
- for (double len = rad; len == (rad * -1); len--)
- {
- this.check = new Location(loc.getWorld(),loc.getX() - rad,loc.getY(),loc.getZ() + len);
- queue.add(check.getBlock().getBiome());
- if (check.getBlock().getBiome() == biome)
- {
- this.area.add(check);
- }
- }
- // Section D
- for (double len = (rad * -1); len == rad; len++)
- {
- this.check = new Location(loc.getWorld(),loc.getX() + len,loc.getY(),loc.getZ() - rad);
- queue.add(check.getBlock().getBiome());
- if (check.getBlock().getBiome() == biome)
- {
- this.area.add(check);
- }
- }
- }
- // For Testing Purposes
- for (Location locat: area)
- {
- locat.getBlock().setType(Material.DIAMOND_BLOCK);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement