onGround?

Discussion in 'Plugin Development' started by A5H73Y, Aug 9, 2012.

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

    A5H73Y

    I have a check to see if the player below him is a certain block, but how can i check that he is actually touching it?
    This is my code:
    Code:
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event){
    Block blockbelow = event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN);
    if (blockbelow.getTypeId() == plugin.getConfig().getInt("DeathID")){
    CODE
    }
     
  2. Offline

    TheSmallBones

    Check the highest block non air at the users coords, addY 1 to the block coords, compare it to the user's coords?

    Also: http://jd.bukkit.org/doxygen/dd/daa...1World.html#ad2552850581fade866235ebb33ee5dc3

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  3. Offline

    Firefly

    Block below = player.getLocation().subtract(0, 1, 0);
    if (below != null && below.getType() == Material.DERP) {
    //Do stuff
    }
     
  4. Offline

    McLuke500

    Just wondering because on the debug menu theres a g: true or false for being on the ground is there nothing similar added to the server side?
     
  5. Offline

    Firefly

    Not that I know of. Client side there is the method isOnGround that you can call.
     
  6. Offline

    A5H73Y

    Thank you very much!
     
  7. Offline

    desht

    That won't work if the player is in mid-air above a solid block (i.e. falling or jumping).

    I had to solve this problem for my AutoHop plugin: https://github.com/desht/autohop/blob/master/src/main/java/me/desht/autohop/AutoHop.java - it's not trivial, since you need to consider standing on steps, slabs, standing above non-solid blocks... see around line 164.
     
  8. Offline

    Firefly

    desht

    OP asked for code that checks if someone is physically touching the block. I don't know if he wants to account for jumping/falling with only partial space between a player and the block. If he did, he should've explicitly said so.
     
  9. Offline

    A5H73Y

    Thanks, after testing the previous code I was given it didnt really give the effect I wanted...
    Can you please explain it to me? Ive read your code and it doesnt really relate to anything I get, can you please narrow it down for me? "/
     
  10. Offline

    Firefly

    What's the effect you want?
     
  11. Offline

    travja

    I'd check if he's flying and then check to see if the block under him isn't air, if it isn't air, he's on the ground.
     
  12. Offline

    A5H73Y

    I want it to run the code as soon as you touch the deathblock, not in the air space above it "/
     
  13. Offline

    Firefly

    Listen to PlayerMoveEvent, and run my code inside of it.
     
Thread Status:
Not open for further replies.

Share This Page