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

Effect duration hiding from tooltip does not take duration factor into account

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.12, Minecraft 1.12.1 Pre-Release 1, Minecraft 1.12.1, Minecraft 1.13, Minecraft 1.13.1-pre1, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w03b, Minecraft 19w03c, 1.16.2 Pre-release 1, 20w46a, 1.16.5, 21w05b, 21w06a, 21w08b, 1.20.1, 23w32a
    • Confirmed
    • (Unassigned)

      The bug

      The tooltip of items which apply effects like tipped arrows or potions is supposed to not show the duration if it is less than or equal to 20. It does however not consider the duration factor which is for example for tipped arrows 1 / 8 resulting in the tooltip showing 0:00 as duration.

      How to reproduce

      This can currently easily be reproduced using MC-98310. Once that bug is fixed this bug cannot be seen without looking at or modifying the code.

      1. Use the following command
        /give @p tipped_arrow{custom_potion_effects:[{id:speed,amplifier:0b,duration:20}]}
        
      2. Hover over the item to see the tooltip
        → No duration is shown because it is not greater than 20
      3. Use the following command
        /give @p tipped_arrow{custom_potion_effects:[{id:speed,amplifier:0b,duration:21}]}
        
      4. Hover over the item to see the tooltip
        → It shows "0:00" as duration

      Code analysis

      Based on 1.12 decompiled using MCP 9.40 PRE 1

      The method net.minecraft.potion.PotionUtils.addPotionTooltip(ItemStack, List<String>, float) does not take the durationFactor into account when testing if the duration is higher than 20. It should instead test for the following:

      potioneffect.getDuration() * durationFactor > 20
      

            Unassigned Unassigned
            marcono1234 Marcono1234
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: