1.15.2 List of Chunks from WorldGuard or WorldEdit

Discussion in 'Spigot Plugin Development' started by MrAxeTv, Feb 10, 2020.

  1. Hello there I will need help maybe some one know is it possible to get list of chunks in worldguard region
    or wordedit selection.
    Third option will be getting them between 2 location by for loop
    Think is what I am doing is changing blocks with packets and you can do that just per chunk so I need to run task for every chunk in region to do that

    Thanks
     
  2. Getting the chunks in a region is essentially a matter of coordinate manipulation, I don’t thunk that’s something WorldEdit would bundle into their API natively. The minimum chunk a region occupies is its minX/16 and minZ/16 and the maximum chunk is maxX/16 and maxZ/16. Just use a double for loop to go through each chunk X and Z between the two ranges.
     
    • Agree Agree x 1
  3. I did like +16 in X and Z loop so it goes fast thru all chunks
     
  4. You can also find the 4 corners of you region after that you can easily using a for loop find the remaining X / Z of every chunk in between
     
    • Like Like x 1
  5. You need to use 4 calculations.
    Obtain the region details
    (Psuedo Code)
    chunksUsed = Chunk(roundDown(region.Xmin / 16), roundDown(region.Zmin / 16)) to Chunk(roundDown(region.Xmax / 16, roundDown(region.Zmax / 16))