Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6026

PotionEffectType inconsistency on EntityPotionEffectEvent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • OS: PopOS! 20.04

    • git-Spigot-0509002-7c03d25 (MC: 1.16.1) (Implementing API version 1.16.1-R0.1-SNAPSHOT)
    • Yes

      When listening to the "EntityPotionEffectEvent" and retrieving the new applied effect with event#getNewEffect() and then getting the type of the PotionEffect , the type does not match with the APIs PotionEffectType enums.

      I cannot see a reason for this to not be working if not because of a spigot bug\improper code.

       

      // java
      @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
       public void onEntityPotionEffect(final EntityPotionEffectEvent event) {
       final Entity entity = event.getEntity();
       if (!(entity instanceof LivingEntity)) return;
       final LivingEntity livingEntity = (LivingEntity) entity;
       final EntityPotionEffectEvent.Action action = event.getAction();
       final EntityPotionEffectEvent.Cause cause = event.getCause();
       final PotionEffect potionEffect = event.getNewEffect();
       if (potionEffect == null) return;
       final PotionEffectType potionEffectType = potionEffect.getType();
       if (potionEffectType != PotionEffectType.POISON) {
         System.out.println(String.format("This is not poison, it is %s", potionEffectType.getName()));
         return;
       }
       

       

       

      When a poison potion effect gets applied to the player, either via a bottle, or via the command "/effect give TheViperShow poison 15 0" , the condition that check that the potionEffectType is NOT EQUAL to Poison , always fails, however it prints this:

      NOTE: This bugs also affects many other versions, I've tested 1.15.2 and 1.14.4 which had the same exact issue.

            Unassigned Unassigned
            TheViperShow Marco
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: