Get the "left/right"-neighbor of a block

Discussion in 'Plugin Development' started by Meldanor, Feb 12, 2011.

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

    Meldanor

    Hi guys,

    I'm really happy with the API and I want to programm a plugin, where players can build hatches for their castles or their houses.
    I don't know, how to find out, what is the left and the right neighbor block of one block.
    I know, that in a 3D-world, there is no left and right, there are just the x,y and z coordinate and the orientation.
    Anyone an idea, how I can get the block, which is one position to the right of my origin block? The right side means the right side of the players view.

    Greetz
    Mel
     
  2. Offline

    Isabaellchen

    Player.getLocation().getYaw() will give you the rotation of the player on the y axis.
    You have four cases 0°-90°, 90°-180°, 180°-270° and 270°-360°/0°
    you then have to test if your neighbour-blocks to the origin block are at x-1/x+1, z-1/z+1, x+1/x-1 and z+1/z-1 depending on each case.
     
  3. Offline

    Meldanor

    Thanks for the hint, I had a lag on my brain, so simple. Question ist, what the rotations resemple.
    0-90°(or is it a half pi ) stands for north and is it going clockwise? I'm missing some comments in the code and some examples for the java doc.

    Edit:
    90° = NORTH
    180° = EAST
    270° = SOUTH
    360° = WEST

    And it is in degree instead of the mostly used radiants
     
Thread Status:
Not open for further replies.

Share This Page