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 }
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.
Block below = player.getLocation().subtract(0, 1, 0); if (below != null && below.getType() == Material.DERP) { //Do stuff }
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?
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.
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.
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? "/
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.