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

Extending a potion effect that you already have can cause the timer to display wrongly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: Minecraft 1.7.4, Minecraft 14w02c, Minecraft 14w05b, Minecraft 14w30c, Minecraft 14w31a, Minecraft 1.8-pre1, Minecraft 1.8, Minecraft 1.8.1, Minecraft 1.8.2-pre6, Minecraft 1.8.6, Minecraft 15w36d, Minecraft 1.9.2, Minecraft 16w36a, Minecraft 1.11, Minecraft 16w50a, Minecraft 1.11.2, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w45b, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w08b, Minecraft 19w09a
    • Fix Version/s: None
    • Labels:
    • Confirmation Status:
      Confirmed
    • Category:
      UI

      Description

      The bug

      Normally, when getting an effect with a duration of or longer than 1639 seconds, '**:**' is displayed in the HUD. However, if the effect is applied while you already had it (but for a shorter duration), that doesn't happen instead a duration higher than 27 minutes is displayed.
      Leaving and re-entering the world fixes it.

      Expected behavior

      '**:**' be displayed.

      Actual behavior

      '27:18' is displayed.

      How to reproduce

      1. Use the following command
        /effect give @s minecraft:speed 10
        
      2. While the effect is still active, use
        /effect give @s minecraft:speed 1000000
        

      Code analysis

      The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta, applies to 1.12.2 as well.

      The reason why this happens is because the method net.minecraft.potion.PotionEffect.combine(PotionEffect) (and others as well) are not using the value of the net.minecraft.potion.PotionEffect.isPotionDurationMax field of the other potion.

      public void combine(PotionEffect other)
      {
          if (this.field_188420_b != other.field_188420_b)
          {
              LOGGER.warn("This method should only be called for matching effects!");
          }
      
          if (other.amplifier > this.amplifier)
          {
              this.amplifier = other.amplifier;
              this.duration = other.duration;
              // Added this
              this.isPotionDurationMax = other.isPotionDurationMax;
          }
          else if (other.amplifier == this.amplifier && this.duration < other.duration)
          {
              this.duration = other.duration;
              // Added this
              this.isPotionDurationMax = other.isPotionDurationMax;
          }
          else if (!other.isAmbient && this.isAmbient)
          {
              this.isAmbient = other.isAmbient;
          }
      
          this.field_188421_h = other.field_188421_h;
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Andrio Celos Andrio Celos
              • Votes:
                3 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  CHK:

                  Potential Duplicates