Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-276746

Splash and Lingering Potions don't pass on all the parameters when applying effects to entities

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.21.1
    • None
    • Windows 11, Java 21, Minecraft 1.21.1
    • Unconfirmed
    • Entities

      I'm not sure why this is the case, but while working on a mod, I noticed that my potion effect wasn't showing the icon on the screen unless I enabled particles as well. Turns out, the splash potion entity doesn't actually pass on that last parameter, so the only way for the HUD icon to show up requires particles to also be enabled.

      From the ThrownPotion.applySplash() method:

      for (MobEffectInstance mobEffectInstance : effects) {
          Holder<MobEffect> holder = mobEffectInstance.getEffect();
          if (holder.value().isInstantenous()) {
              holder.value().applyInstantenousEffect(this, this.getOwner(), livingEntity, mobEffectInstance.getAmplifier(), e);
          } else {
              int i = mobEffectInstance.mapDuration(duration -> (int) (e * (double)duration + 0.5));
              MobEffectInstance mobEffectInstance2 = new MobEffectInstance(
                  holder, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible()
              );
              if (!mobEffectInstance2.endsWithin(20)) {
                  livingEntity.addEffect(mobEffectInstance2, entity2);
              }
          }
      }

       

      mobEffectInstance2 should actually be:

      MobEffectInstance mobEffectInstance2 = new MobEffectInstance(
          holder, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible(), mobEffectInstance.showIcon()
      );

       

      This is also true for Lingering potions. In AreaEffectCloud.tick(), you can find where it applies status effects to entities and see it's missing the showIcon() parameter when a new mob effect instance is created from the PotionContents data. While this doesn't affect normal gameplay, it is something that caused me a bit of a headache trying to figure out, so I thought I should at least report it since it would be a fairly simple fix.

            Unassigned Unassigned
            Camellias Lily Camellias Loveheart
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: