mojira.dev
MC-259823

Inconsistencies with Text Display opacity

Setting the "text_opacity" NBT tag in an item display entity to anything less than 4 seemingly renders its text's opacity as 255, and setting it to 4-25 seems to render the text as completely invisible.

 

Steps to reproduce:

  • Summon a text display:

    /summon text_display ~ ~1.5 ~ {text:'"Text"'}
  • Set its opacity to something low but still visible:

    /data merge entity @e[type=text_display,limit=1] {text_opacity:26b}
  • Lower it by 1 down to 25:

    /data merge entity @e[type=text_display,limit=1] {text_opacity:25b}
  • Notice the text is now completely invisible.

  • Set it to 1 where it should barely be visible:

    /data merge entity @e[type=text_display,limit=1] {text_opacity:1b}
  • Notice the text is fully visible.

 

Attachments

Comments 6

Alpha of 4-25 being invisible is due to how core shaders for text are designed.

If you remove the following code from all text shaders, it will be visible and have the proper opacity. As such, this part of the bug is likely WAI.

if (color.a < 0.1) {
        discard;
    }

You can test this using the attached resource pack https://bugs.mojang.com/secure/attachment/522368/RemoveTextDisplayAlphaDiscard.zip

On the other hand, text_opacity values 0 to 3 still render fully visible. This range of values may be a bug...

Values from -128 to -1 render fully visible, but this is probably undefined behavior and WAI.

The default value is also -1 instead of the intended 255

This is unfortunately still present in the released version of 1.19.4

The reason why the default value is -1 is that the game uses byte type for text_opacity field and therefore the default value, 255, is overflowed to -1.

Because of this, value between -128 and -1 should work like opacity 128~255, and it does work like that when I test it.

PvPqnda

(Unassigned)

Confirmed

Platform

Low

Rendering

23w06a, 1.19.4, 1.20 Pre-release 4, 1.20.1

Retrieved