Bigger chunks // custom areas

Discussion in 'Plugin Development' started by DeamonZ, Dec 3, 2014.

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

    DeamonZ

    Hello,

    Me and a friend want to develop a kind of villages plugin.
    We are making it so you can conquer other villages and claim your ones ed.
    We wanted very big plots of 128 x 128 (8 x 8 chunks) and when you enter it would say welcome to village.
    I've been working on defining these plots by myself hand coded but is there a faster way of doing this?
    We want around 80 x 80 plots.
    So far i have done it like this:
    Code:java
    1. World w = Bukkit.getWorld("World");
    2. Chunk a1 = w.getChunkAt(1, 1);
    3. Chunk a2 = w.getChunkAt(17, 1);
    4. Chunk a3 = w.getChunkAt(33, 1);
    5. Chunk a4 = w.getChunkAt(49, 1);
    6.  
    7. Chunk b1 = w.getChunkAt(1, 17);
    8. Chunk b2 = w.getChunkAt(17, 17);
    9. Chunk b3 = w.getChunkAt(33, 17);
    10. Chunk b4 = w.getChunkAt(49, 17);
    11.  
    12. Chunk c1 = w.getChunkAt(1, 33);
    13. Chunk c2 = w.getChunkAt(17, 33);
    14. Chunk c3 = w.getChunkAt(33, 33);
    15. Chunk c4 = w.getChunkAt(49, 33);
    16.  
    17. Chunk d1 = w.getChunkAt(1, 49);
    18. Chunk d2 = w.getChunkAt(17, 49);
    19. Chunk d3 = w.getChunkAt(33, 49);
    20. Chunk d4 = w.getChunkAt(49, 49);

    And thats just for one plot ...

    So do any of you know if I could do this in a way faster and cleaner way?
     
  2. Offline

    Skionz

    DeamonZ Use for loops which increment x and/or y or use arrays which store the locations.
     
  3. Offline

    DeamonZ

    How do you loop that?
    I thought with something like this:
    Code:java
    1. int i = 16;
    2. i++;
    3.  

    but that would result in 17, which is good for one chunk.
     
  4. Offline

    Skionz

    DeamonZ This is how I iterate through arrays. I am not sure if you can use an enhanced for with an array but I wouldn't be surprised if you could.
    Code:
    for(int i = 0; i < array.length; i++) {
        System.out.println(array[i]);
    }
     
  5. Offline

    DeamonZ

    Uggh, Sorry but I still don't understand.
    Could you explain it like i would have 3 ints and want to nummer them automaticly
    Code:java
    1. Int chunk1, chunk2, chunk3;
    2. chunk1 = 1;
    3. chunk2 = 2;
    4. chunk3 = 3;
     
  6. Offline

    Skionz

    DeamonZ So you do you want to 'claim' a square of chunks? Or a bunch of random chunks which locations are hardcoded?
     
  7. Offline

    DeamonZ

    I quickly worked out a kind of map of the idea.

    The big, colored squires is the plot. (So this is a map of 4 plots)
    Each plot contains 64 chunks (8x8 chunks).
    These can be claimed as a village.
    I colored some squires black so you can see the chunks.
    [​IMG]
     
  8. Offline

    Skionz

    DeamonZ Then yes you would use a for loop incrementing or decrementing x and z.
     
  9. Offline

    coasterman10

    You're making a common beginner mistake of coding every single object when you should use a Collection or array.

    If you want a fixed amount of chunks, use a two-dimensional array, or if you ever may need to change it just use a List, either a List<List<Chunk>> for two-dimensional mapping or a List<Chunk> and wrap the index around for each row.
     
  10. Offline

    DeamonZ

    coasterman10 but then I still must add all 51200 chunks(because thats our map size) by hand.
     
Thread Status:
Not open for further replies.

Share This Page