Mojira Archive
MC-118863

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

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