Getting the outline of a chunk?

Discussion in 'Plugin Development' started by belven000, Aug 14, 2014.

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

    belven000

    Hi,
    My maths skills within the 3D world are a little poor. Curently I have this:

    Code:java
    1.  
    2. private void showClaims(Player p) {
    3. if (isInATeam(p)) {
    4. Team t = getTeam(p);
    5. int y = (int) p.getLocation().getY();
    6.  
    7. for (Chunk c : t.ownedChunks) {
    8.  
    9. for (int x = 0; x < 15; x++) {
    10. for (int z = 0; z < 15; z++) {
    11. Block b = c.getBlock(x, y, z);
    12. p.sendBlockChange(b.getLocation(),
    13. Material.REDSTONE_BLOCK, b.getData());
    14. }
    15. }
    16. }
    17. }
    18. }


    This works fine but it changes ALL the blocks within the region at the players Y axis. I only want to change the blocks around the edge of each chunk.

    To my knowledge I would need to change blocks in these co-ords:

    x: 0 - 15 while z is 0 = South wall
    z: 0 - 15 while x is 0 = West Wall
    x: 0 - 15 while z is 15 = North Wall
    z: 0 - 15 while x is 15 = East Wall

    I'm hoping someone has done this before. Any help would be great :D
     
  2. Offline

    Jogy34

    Just check if either X or Z are equal to 0 or 15
     
  3. Offline

    belven000

    Jogy34 it only seems to get the north and west wall:

    Code:java
    1.  
    2. for (Chunk c : t.ownedChunks) {
    3. for (int x = 0; x < 15; x++) {
    4. for (int z = 0; z < 15; z++) {
    5. if (z == 15 || z == 0 || x == 15 || x == 0) {
    6. Block b = c.getBlock(x, y, z);
    7. p.sendBlockChange(b.getLocation(),
    8. Material.REDSTONE_BLOCK, b.getData());
    9. }
    10. }
    11. }
    12. }
    13.  
     
  4. Offline

    PureGero

    You have
    for (int z = 0; z < 15; z++){
    This will make z always smaller than 15 so z == 15 will always return false.
    Simply change it to:
    for (int z = 0; z < 16; z++){
    and same for x
     
  5. Offline

    DinosParkour

    or z <= 15 and x <= 15
     
  6. Offline

    belven000

    PureGero lol, schoolboy error ;)
    Thanks mate :D
     
Thread Status:
Not open for further replies.

Share This Page