Getting PotionType in ProjectileLaunchEvent

Discussion in 'Plugin Development' started by Artellet, Jul 24, 2017.

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

    Artellet

    So, I've been messing around with my plugin for quite a while now, and recently I tried to get involved with messing around with the velocity of splash potions, and have run into a problem.

    This is the event I'm using:
    Code:
    void onProjectileLaunch(final ProjectileLaunchEvent e) {
    
    Obviously, I am trying to get the PotionType from a splash potion from "e", however, have had no luck in doing so.
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Artellet Get the projectile, check if it is a splash potion, if so: cast it and check the type.
     
  3. Offline

    mehboss

    or try messing around with PotionSplashEvent.
     
  4. Offline

    Artellet

    I've tried to do this, however, my IDE complains about it being an inconvertible type.
    I'm messing around with velocity, and I'm pretty sure I cannot modify the velocity from this event.
     
  5. Offline

    dumbasPL

    @Artellet try:
    Code:
        @EventHandler
        void onProjectileLaunch(final ProjectileLaunchEvent e) {
            if(e.getEntityType() == EntityType.SPLASH_POTION){
                ThrownPotion potion = (ThrownPotion) e.getEntity();
                for(PotionEffect effect : potion.getEffects()){
                    PotionEffectType effecttype= effect.getType();
                    if(effecttype == PotionEffectType.INVISIBILITY){
                        //do stuf
                    }
                }
            }
        }
     
  6. Offline

    timtower Administrator Administrator Moderator

    Then you might have the wrong type.
     
  7. Offline

    Artellet

    I would need to use PotionType, not PotionEffectType, as it does not work at all.

    How?
     
Thread Status:
Not open for further replies.

Share This Page