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

Solved Snowball Damage

Discussion in 'Development' started by Dadoue, Dec 24, 2020.

  1. Dadoue

    Dadoue Spider

    Messages:
    7
    Hello, how to change the damage of snowballs? thank you in advance
     
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    In that case, you want to change the value of the base damage using EntityDamageEvent
     
  3. Dadoue

    Dadoue Spider

    Messages:
    7
    I tried this but it doesn't change anything
    PHP:
    public function onDamage(EntityDamageEvent $event) {
        if(
    $event instanceof EntityDamageByChildEntityEvent){
            
    $child $event->getChild();
            if(
    $child instanceof Snowball){
            
    $event->setModifier(5EntityDamageEvent::CAUSE_ENTITY_ATTACK);
            }
        }
    }
     
  4. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Dadoue and minijaham like this.
  5. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Like GamakCZ said above, use setBaseDamage() function instead of setModifier.

    PHP:
    public function onDamage(EntityDamageEvent $event) {
        if(
    $event instanceof EntityDamageByChildEntityEvent){
            
    $child $event->getChild();
            if(
    $child instanceof Snowball){
            
    // You can also use $event->getBaseDamage() to get the original damage!
            
    $event->setBaseDamage($value);
            }
        }
    }
     
    GamakCZ and Dadoue like this.
  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.