Getting fall height of player

Discussion in 'Plugin Development' started by Ensign Trojan, Jun 9, 2013.

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

    Ensign Trojan

    How can i check height of player fall? I mean I know that i can check damage of event and compare it with this what i want (if fall from 3 blocks then do smt, if fall from <4 then do smth else) BUT
    this will not work if player wears some equipment like chest or helmet, can you help me wiith this? :)
  2. Offline


    Not tested though it should work:
        public static int getFallHeight(Player p){
            int y1 = (int) p.getLocation().getY();
            int y2 = 0;
            Block b = p.getLocation().getBlock();
            while(!(b = b.getRelative(BlockFace.DOWN)).getType().isSolid())
                y2 = b.getY();
            return y1-y2;
    Note that this is before they actually hit ground and it is essentially an estimate. And after reading your post again I realise this isn't what you're looking for, sorry.

    Did a few tests with various armor types (and featherfalling enchant) and found that the raw damage is always posted for the fall damage even if the player actually takes less damage. An estimate on how far they fell is falldamage+3. Hopefully that should help a little.

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


    Works only if player take any damage
    1. if (event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) {
    2. float fDist = eventEntity.getFallDistance();
    3. //do something
    4. }
Thread Status:
Not open for further replies.

Share This Page