Solved How to get block which player is crouch standing on? [PlayerMoveEvent]

Discussion in 'Plugin Development' started by Ibas, Aug 19, 2013.

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

    Ibas

    With

    Code:java
    1. Location playerLoc = player.getLocation();
    2. playerLoc.setY(playerLoc.getY() - 1);
    3.  
    4. playerLoc.getBlock().getType();

    I get AIR but player is standing on edge of block and it's not air so how to get excact block where is player standing on?
     
  2. Offline

    callum.thepro

    Location playerLoc = player.getLocation();
    playerLoc.setY(playerLoc.getY() - 1);

    playerLoc.getBlock().getType();
     
  3. Offline

    Ibas


    Yes, with this I get AIR too if player is crouching at the corner of block.
     
  4. Offline

    callum.thepro

    the problem with this is there could potentially be 2 blocks if it is a corner which makes this difficult to get to an answer, what do you need to know the block for?
     
  5. Offline

    Wizardo367

    Get their x,y,z location in the form of doubles then round them off to the nearest integers, after that simply check which block it is. :)
     
Thread Status:
Not open for further replies.

Share This Page