1.8.8 Fastest way to clear a huge area?

Discussion in 'Spigot Plugin Development' started by OhSry, Feb 20, 2020.

  1. Hello, I am just wondering what is the fastest way to clear a huge area out?
    This is my code and I'm just wanting to make it more efficient
    Code (Text):
        public void doOblivion(Player p, Block broken) {
            synchronized (Tokens.getInstance()) {

                for (int x = broken.getX() - 40; x < broken.getX() + 40; x++) {
                    for (int y = broken.getY() - 40; y < broken.getY() + 40; y++) {
                        for (int z = broken.getZ() - 40; z < broken.getZ() + 40; z++) {
                            Location loc = new Location(p.getWorld(), x, y, z);
                            if (Tokens.getWGP().getRegionManager(p.getWorld()).getApplicableRegions(loc)
                                    .allows(DefaultFlag.BLOCK_BREAK)) {
                                loc.getBlock().getDrops().forEach(item -> p.getInventory().addItem(item));
  2. That's certainly the way that would mean the area has been destroyed in the least amount of time, but I'm guessing you might be making this post due to lag reasons. If it is due to lag reasons, you want to make the blocks be destroyed over multiple ticks, ie put it into a BukkitRunnable and destroy the blocks in chunks. Maybe you do a layer of blocks every tick for example.
    • Agree Agree x 1
  3. I still really need help with this. Like immediately, I've tried fawe but it freezes the server, I've tried nms, I've tried setType. Please someone help
  4. You have already been told what you can do, either split the work on multiple ticks and/or use a more efficient approach to set the blocks. If you are trying to back port one of the methods compare the referenced code from 1.14 to 1.8.
  5. I still really need help with this. Like immediately, I've tried fawe but it freezes the server, I've tried nms, I've tried setType. Please someone help
    I tried the first thing you said and it just caused WAYYY more lag. Its a prison server and I'm trying to get "excavation" to work.
  6. Post the code you tried it with.
  7. I've tried with like 25, theres no possible way for me to remember all the things I've tried
  8. And I also said above what I tried
  9. Without code there is still no way for us to tell if you implemented it correctly. Also for someone who doesn't know much about prison servers you didn't really explain a lot, like when exactly and how often are you calling this method? You could also create a timings report and post the link here.
  10. I'm just trying to know how to get rid of blocks fast...
  11. Code (Text):
    EditSession editSession = new EditSessionBuilder(w.getName()).fastmode(true).build();

            int boundsx1 = 0;
            int boundsx2 = 0;
            int boundsz1 = 0;
            int boundsz2 = 0;

            for (int x = bro.getX() - 60; x < bro.getX(); x++) {
                if (w.getBlockAt(x, y, bro.getZ()).getType().equals(Material.BEDROCK)) {
                    boundsx1 = x;

            for (int x = bro.getX(); x < bro.getX() + 60; x++) {
                if (w.getBlockAt(x, y, bro.getZ()).getType().equals(Material.BEDROCK)) {
                    boundsx2 = x;

            for (int z = bro.getZ(); z < bro.getZ() + 60; z++) {
                if (w.getBlockAt(bro.getX(), y, z).getType().equals(Material.BEDROCK)) {
                    boundsz2 = z;

            for (int z = bro.getZ() - 60; z < bro.getZ(); z++) {
                if (w.getBlockAt(bro.getX(), y, z).getType().equals(Material.BEDROCK)) {
                    boundsz1 = z;

            EditSession session = new EditSessionBuilder(w.getName()).fastmode(true).build();
            try {
                session.setBlocks(region, new BaseBlock(0));
            } catch (MaxChangedBlocksException e) {
                // TODO Auto-generated catch block
  12. I've managed to finally fix it, it seems like I tried to replace like 100k more blocks than I needed to, so I fixed it and it now does it in under 0.1s
  13. post the fix for future reference
  14. It sounds good so far, but what about a backup if things go screwy?
  15. Should I use that instead of fawe? Because it still seems to lag even with fawe clearing about 1440 blocks and 3600
  16. nope i thought you just were trying to figure out how you could go about clearing a large section of blocks in a short period of time and you can accomplish 20mil block changes/second this way but I haven’t figured out how to fix all of the bugs yet (such as lighting)

    https://www.spigotmc.org/threads/me...e-amount-of-blocks-up-to-14m-blocks-s.395868/ I got the ideas from here and just translated them to 1.8.8 (but my goal is to fix all the drawbacks for the chunk section strategy and there are still a couple i need to fix)
  17. Is rapidsetblock the fastest way I can currently use or is unstable as I don't care about lighting as its only a prison server.