Change the knockback

Discussion in 'Development' started by Notjblus, May 4, 2020.

  1. Notjblus

    Notjblus Silverfish

    Messages:
    23
    GitHub:
    DevJblus
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    488
    GitHub:
    GamakCZ
    PHP:
    /** @var EntityDamageByEntityEvent $event */
    $event->setKnockBack($knockback);
     
  3. aminozomty

    aminozomty Silverfish

    Messages:
    15
    GitHub:
    aminozomty
    if you want to remove the knockback
    it's here :
    PHP:
    <?php

    namespace test;


    use 
    pocketmine\player;
    use 
    pocketmine\server;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\entity\Entity;
        
    class 
    main extends PluginBase implements Listener{
        
        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
        }
        public function 
    onDamage(EntityDamageEvent $event) {
            
    $entity $event->getEntity();
            if (
    $event instanceof EntityDamageByEntityEvent and $entity instanceof Player) {
                
    $damager $event->getDamager();
                if (
    $damager instanceof Player) {
                    
    $event->setKnockBack(0);
                }
            }
        }
    }
     

Share This Page

  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.