mojira.dev
MC-169806

Incorrect logic in LightTexture#block(int)

In function LightTexture#block(int) there's the following logic:

return (packed >> 4) & 0xFFFF;

If the input values contain any non-zero bit in the low bits of the upper portion (eg 0x00EF_0000), the result of this expression will be 0xF000, instead of the expected value of (0x0000). This doesn't appear to be an active issue in the limited usage of this function in vanilla code, but is incorrect nonetheless.

Fix is to mask first, before shifting:

return (packed & 0xFFFF) >> 4;

 

EDIT: Updated the SRG name to official, which I forgot to do when I posted the ticket.

Comments 1

Can confirm in 1.18 Pre-release 1.

gigaherz

(Unassigned)

Community Consensus

Rendering

1.15.1, 1.18 Pre-release 1, 24w21b, 1.21.1, 1.21.3

Retrieved