1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved No hitdelay after changing knockback

Discussion in 'Development' started by SkyZone, Jun 25, 2019.

  1. SkyZone

    SkyZone Slime

    Messages:
    95
    PHP:
    public function onDamage(EntityDamageEvent $event) {
            if(!
    $event->isCancelled()){
                
    $player $event->getEntity();
                if (
    $player instanceof Player) {
                    if (
    $this->manager->isInGame($player)) {
                        
    $event->setBaseDamage(0);
                        if (
    $event instanceof EntityDamageByEntityEvent) {
                            
    $attacker $event->getDamager();

                            if (
    $attacker instanceof Player) {
                                
    $item $attacker->getInventory()->getItemInHand();
                                if (
    $item instanceof Stick) {
                                    
    $event->setKnockBack($this->manager->knockback);
                                }
                            }
                        }
                    }
                }
            }
        }
    After changing the knockack the hitdelay is gone. Adding !$event->isCancelled() didn't help.

    Has anyone an idea, what the problem could be?
     
  2. Gianluxx

    Gianluxx Slime

    Messages:
    94
    GitHub:
    Gianluxx
    From what i read the problem could be the setBaseDamage(0). Try without
     
  3. SkyZone

    SkyZone Slime

    Messages:
    95
    Yeah works when removed. Thanks!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.