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

Remove splash potion effects

Discussion in 'Development' started by Emirhan Akpınar, Sep 13, 2018.

  1. Emirhan Akpınar

    Emirhan Akpınar Slime

    Messages:
    90
    How can i remove splash potion effects? Example, i throwed jump boost potion, and its give jump effect. How can i cancel this?
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
  3. Emirhan Akpınar

    Emirhan Akpınar Slime

    Messages:
    90
  4. Emirhan Akpınar

    Emirhan Akpınar Slime

    Messages:
    90
    I am only want remove splash potion entity effects.
     
  5. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    You would to cache the latest splash entities that died into an array/splqueue and save the affected players in a range to the potion, and then later remove the players effects based on the cached potions' effects
     
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    The safest method would be by listening to ProjectileHitEvent. During the event, set the projectile's potion ID to 0.
    PHP:
    public function onProjectileHit(ProjectileHitEvent $event){
        
    $projectile $event->getEntity();
        if(
    $projectile instanceof SplashPotion){
            
    //check here if $projectile->getPotionId() is LEAPING, LONG_LEAPING or STRONG_LEAPING?
            
    $projectile->setPotionId(Potion::WATER);
        }
    }
     
    XenialDan likes this.
  7. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    I'd better use the EntityDeathEvent, because splash potions may break on the ground next to the player
     
  8. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    There is a ProjectileHitBlockEvent and ProjectileHitEntityEvent which extend ProjectileHitEvent, so ProjectileHitEvent should cover that case.
    IIRC, entities don't die (anymore?) in cases where they're supposed to despawn.
     
    XenialDan likes 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.