mojira.dev
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

Linked issues

Attachments

Comments 7

Can confirm for 1.12.1.

Confirmed for 1.13.1-pre1

Confirmed for 1.13.1 also the commands should be update to:

/give @p tipped_arrow{CustomPotionEffects:[{Id:1b,Amplifier:0b,Duration:20}]

and

/give @p tipped_arrow{CustomPotionEffects:[{Id:1b,Amplifier:0b,Duration:21}]}

Can confirm that this issue is still present in 21w05b.

Can confirm in 21w06a.

Can confirm in 1.16.5 and 21w08b.

marcono1234

(Unassigned)

Confirmed

(Unassigned)

effect, effect-duration, tooltip

Minecraft 1.12, Minecraft 1.12.1 Pre-Release 1, Minecraft 1.12.1, Minecraft 1.13, Minecraft 1.13.1-pre1, ..., 21w05b, 21w06a, 21w08b, 1.20.1, 23w32a

Retrieved