Don´t get a DamageAnimation when FallDamage

Discussion in 'Plugin Development' started by MiBB3L, Apr 4, 2021.

  1. Offline

    MiBB3L

    I have a problem with my DamageListener I want to remove the DamageAnimation when someone gets falldamage., but sometimes it works and sometimes it doesn´t. Does anyone have an idea why?

    Code:
    public void onDamage(EntityDamageEvent e) {
            Player p = (Player) e.getEntity();
            if(e.getCause().equals(DamageCause.FALL)) {
                double damage = e.getDamage();
                e.setCancelled(true);
                p.playSound(p.getLocation(), Sound.FALL_SMALL, 10, 1);
                if(p.getHealth() <= damage) {
                    p.setHealth(0.0D);
                }else {
                    p.setHealth(p.getHealth()-damage);
                }
               
            }
        }
     
  2. Offline

    davidclue

    Can you define by sometimes it works and sometimes it doesn't?
     
  3. Offline

    Amster

    if(p.getHealth() <= damage) {
    p.setHealth(0.0D);
    }
    If the player is full and takes 10 damage, and the players health is now at 10, wouldn't p.getHealt() = damage?
    Just a thought.
     
  4. Offline

    davidclue

    He checks for that before he applies the damage so that shouldn't cause any problems
     

Share This Page