knockback with health

Discussion in 'Plugin Development' started by Marcohan, Aug 19, 2015.

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

    Marcohan

    Hey! I'm trying to make a plugin where on damage you get knocked back depending on your health.

    Code:
    @EventHandler
    
    public void onHeathChange(EntityDamageEvent e){
    
    LivingEntity en = (LivingEntity) e.getEntity();
    
        if (e.getEntity() instanceof Player){
    
    
        }
    
    
    
    } 
    This is what I have so far
     
  2. Offline

    teej107

    @Marcohan multiply their velocity (direction) by their health
     
  3. Offline

    Marcohan

    Code:
    double health = en.getHealth();
    
            en.setVelocity(en.getLocation().getDirection().multiply(-health));
    Doesn't change the size of knockback
     
  4. Offline

    teej107

    @Marcohan Try and multiply it with a positive value. Idk if it will work.
     
  5. Offline

    CoolDude53

    @Marcohan You can multiply the velocity of the player in a task (because the normal knockback doesn't happen until after the event has fired), so you would amplify the knockback from the attack based on the health.
     
  6. Offline

    teej107

    @CoolDude53 Yeah that is another good thing to take into account.
     
  7. Offline

    Marcohan

    nope it doesn't knockback it draws in
     
  8. Offline

    teej107

    well......
     
Thread Status:
Not open for further replies.

Share This Page