Best way to place a lot of blocks?

Discussion in 'Spigot Plugin Development' started by jbs1222, Aug 7, 2018.

  1. So I just released this plugin today that creates custom mazes for you:
    As you can see from the screenshot, the plugin will have to generate a LOT of blocks. I know that my current way of placing blocks (just setting the type of every block one by one in the same tick) is not the most efficient way of doing this. Do you guys have any suggestions as to how I can reduce lag?
  2. Normally i would say "move the generation into an WorldGenerator". But this seems unsiutable here.
    Altough a whole maze world would be interesting, too...

    So i got at least some more ideas for you:
    • Disable a physics check when placed (i'm pretty sure some setblock method got this as boolean parameter)
    • Split it up in several Tasks
      • Make a configurable amount of blocks per tick
      • schedule as much tasks as needed by this amount (those needs to be sync tasks)
      • Maybe make a configurable timout between those tasks
    I like the idea of generating mazes...
    Would you mind if i decompile it to see your maze generation algorithm?
  3. Thanks for the ideas! You can see my source code on the plugin page. I use a recursive backtracker algorithm
  4. FAWE API has some pretty useful methods you might want to look into if you're looking for fast block placement