Disable Knockback on Hit - but keep damage?

Discussion in 'Plugin Development' started by KittyKatt, Oct 18, 2012.

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

    KittyKatt

    Is there any way I could disable the Knockback effect when a player gets hit, but still keep the event damage?

    Code:
        public void onPlayerAttackPlayer(EntityDamageByEntityEvent event)
        {
            if (!event.isCancelled())
            {
                // PLAYER ATTACK PLAYER
                if ((event.getEntity() instanceof HumanEntity) && (event.getDamager() instanceof HumanEntity))
                {
                    // GET VICTIM AND ATTACKER
                    Player victim = (Player) event.getEntity();
                    Player attacker = (Player) event.getDamager();
                    
                    // GET EVENT DAMAGE
                    int damage = event.getDamage();
                    
                    // SEND DAMAGE TO PLAYER - BECAUSE EVENT IS CANCELING
                    victim.damage(damage);
                    
                    // CANCEL EVENT - TO STOP KNOCKBACK EFFECT
                    event.setCancelled(true);
                }
            }
        }
    
    Got it fixed, cancel the event but send event damage to the player.

    Damage ignores armor defense, also the deathcause messes up and will be "died for no reason" instead of "player1 killed player2".

    =((((((((((((

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

    KittyKatt

    Anyone?
     
  3. Offline

    Cirno

    Check if the player has armor, if so, then I think you divide the damage upon the amount of armor the person is wearing. Also, since you are dealing the damage manually via code, it will always spit out Died for no reason. Try overriding the death message with something else, just create your own event or something.
     
  4. I'm also attempting this. Any help or examples anyone? I'm a noob, sorry.
     
Thread Status:
Not open for further replies.

Share This Page