faster/better way to iterate blocks that are only in (bigger) one of two selections/squares

Discussion in 'Plugin Development' started by Smerfa, Jul 21, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Smerfa

    I have 2 squares -> selections
    one is big, and second is smaller and is in bigger one, and I want iterate only over blocks that are in bigger one but isn't in smaller.

    There is any better way than this loop?
    Code:java
    1. SquareSel big = new SquareSel(new BlockPointer(-100, 0, -100, world), new BlockPointer(100, 256, 100));
    2. SquareSel small = new SquareSel(new BlockPointer(-75, 10, -75, world), new BlockPointer(25, 200, 50));
    3.  
    4. for (int x = big.getMinPoint().getX(); x <= big.getMaxPoint().getX(); x++)
    5. {
    6. for (int y = big.getMinPoint().getY(); y <= big.getMaxPoint().getY(); y++)
    7. {
    8. for (int z = big.getMinPoint().getZ(); z <= big.getMaxPoint().getZ(); z++)
    9. {
    10. if (small.contains(new BlockPointer(x, y, z, world)))
    11. {
    12. continue;
    13. }
    14. // do something with this block...
    15. }
    16. }
    17. }
     
  2. Offline

    fireblast709

    Smerfa I don't think there is. Any optimalization would probably occur around the checks themselves
     
    Smerfa likes this.
Thread Status:
Not open for further replies.

Share This Page