mojira.dev
MC-312732

Text opacity on text displays sometimes interpolates in the wrong direction.

This bug has been around for quite some time, but I still could not find any existing report about it.

When changing the text_opacity of a text display with a non-zero interpolation_duration, it will sometimes interpolate to the maximum/minimum value, then overflow/underflow and interpolate from the minimum/maximum value. Specifically whenever it needs to interpolate between 127 and 128.

For example, if you spawn a text display like this:

/summon minecraft:text_display ~ ~ ~ {text:asdf,interpolation_duration:20,text_opacity:120}

Position yourself on the south side so you can see it.

Then try to change the text_opacity to 140:

/data merge entity @n[type=minecraft:text_display] {text_opacity:140}

Instead of interpolating from 120 to 140 like I’d expect, it first interpolates down to 0, then jumps to 255, and then finally interpolates down to 140. You can interpolate it back to 120 again to see the effect in reverse:

/data merge entity @n[type=minecraft:text_display] {text_opacity:120}

The actual cause is fairly simple. The text opacity value is stored as a signed byte in the text display, so anything between 128 and 255 is stored as a negative number. To fix the bug, you just need to make sure that `createFreshTextRenderState` and `createInterpolatedTextRenderState` in `Display.TextDisplay` add 256 to the text opacity if it is negative before sending it off to the `LinearIntInterpolator`.

Fun fact, this bug was first introduced in version 1.20, but still affects 26.3 and 26.4-snapshot-4. This means text displays only had one single version (1.19.4) where this interpolation worked correctly (unless it was fixed in some minor version in-between and then broke again).

Comments 0

No comments.

Acuadragon100

(Unassigned)

Unconfirmed

26.3

Retrieved