Get the exact block that the player is standing on

Discussion in 'Plugin Development' started by LoveMST, Feb 9, 2014.

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

    LoveMST

    please guys if any one know how to do it please tell me i looked up for it on all bukkit forums and i tried it by myself but no clue how to please :D
     
  2. Offline

    Compressions

    LoveMST
    Code:
    Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
     
  3. Offline

    _Filip

    Compressions
    That's a slow method.
    Use
    Code:java
    1. Block block = p.getLocation().getWorld().getBlockAt(p.getLocation.getBlockX(), p.getLocation.getBlockY(), p.getLocation.getBlockZ());
     
  4. Offline

    LoveMST

    well i tried this but ... did not help cuz the player can stand on the corner of the block and the plugin will not register that block

    @swampshark19
    well i did not try that let me test it

    it doesn't help cuz if the player stand in the middle of like 4 blocks it only clear 2 with the two methods above !

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  5. Offline

    Compressions

    swampshark19 That actually gets the block at the lower half of the player.
     
  6. Offline

    VOLCOMXD22

    it would still get the x, y , and z locations so you can create a method that gets the block closest to the player
     
  7. Offline

    LoveMST

    @VOLCOMXD22 a little code will help :D

    any help :!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  8. Offline

    Garris0n

    Try something like player.getLocation().subtract(0, 0.01, 0).getBlock().

    That's...a slower method...and doesn't even work as needed.
     
  9. Offline

    LoveMST

    @Garris0n i used one and it works but the problem now is i want a code that get the nearest block from the player location
     
  10. Offline

    Garris0n

    That's not as simple as it sounds. What exactly are you trying to do?
     
  11. Offline

    LoveMST

    @Garris0n
    like i said up , iam trying to remove the block under the player like a tnt run mini game iv'e done every thing but every time the player stand like in the middle of 4 blocks it only clears 2 and the player can just sit there without any block remove thats why i need a method to check the nearest blocks to the player by 1 and the type of it equals x , for now i made an AFK method if the player dont move for a second and half he will be kicked , please help
     
  12. Offline

    Garris0n

    Maybe get all the blocks in a 3x3 square under them?

    Also, to tag people either type @ and their name or hit the tahg button. If you just type @ and link to their profile it doesn't alert them.
     
  13. Offline

    LoveMST

    Garris0n ohh :D , but is this the only way to to that
     
  14. Offline

    Garris0n

    Not necessarily, but it's the only simple way.
     
  15. Offline

    LoveMST

    Garris0n well ok , another question , if i want to move an animal like a caw for example like move it 3 blocks can i use set velocity to plus 3 to the x or z
     
  16. Offline

    Garris0n

Thread Status:
Not open for further replies.

Share This Page