mojira.dev
MC-165595

Guardian beam does not render when over a certain "Time" in level.dat

The bug

I was fighting with guardians and the fight is not how it was before - guardian beam rendering stopped working. Only bubbles render now.

This happens when the game time reaches 2800000.

Download the MC-165595 world attachment if you want to reproduce this.

Code analysis

Code analysis by @unknown can be found in this comment.
 

Linked issues

MC-242400 Guardian beam is invisible Resolved MC-239920 моб/ mob guardian Resolved MC-232477 Guardian beams don't render on Minecraft Realms Resolved MC-228660 i downloaded the 1.17 release expecting to see a new title scree panorama but i got the old 1.16 panorama instead Resolved MC-222669 Guardian's laser aren't shown Resolved

Attachments

Comments 22

Is this fixed for someone? If is, mark as Fixed. It is fixed for me

1.15.1 is already marked as affected, and I can reproduce this in 1.15.1 too. So this still is a problem for some players.

This happens in one of my worlds but not the other. It's quite annoying. Vanilla or not, resource packs or not, it still doesn't show. (in 1.15.2)

Also happened to me. Went to explore a Woodland Mansion and during the journey, I found an Ocean Monument. Tried to reproduce this and it happened. However, in creative, this doesn't work. You will see the beam normally, however, it is dark (MC-168398) Also, it is annoying. If you are above water, you do not know if it is attacking you, because you don't even see the bubbles (reason: MC-161917, which is very annoying.)

Welp, now I'm getting this issue. Apparently it doesn't happen in new worlds but will always not render on old worlds.

12 more comments

Is it 2800000 exactly? Or does it happen at a power of two value like 2097152?

The bug is still unresolved on 1.18.1. I encounter it on a self-owned private Minecraft Vanilla server. I have checked the "Time" in level.dat is 21396082, seems not only happen at power of two values.

As mentioned by @unknown, the reason this issue occurs is because of an integer overflow, caused by float to int conversions inside Mth.cos() and Mth.sin(). More specifically, it should overflow when the world time is above approximately 2745160 (might be slightly more or less than that), as that is the earliest number that would cause an overflow within GuardianRenderer#render(...):

...
float $$8 = (float)$$0.level.getGameTime() + $$2;
...
float $$18 = $$8 * 0.05f * -1.5f;
...
float $$31 = Mth.cos($$18 + 5.4977875f) * 0.282f;
...
GuardianRenderer.vertex($$46, $$48, $$49, $$31, $$41, $$32, $$20, $$21, $$22, 1.0f, $$50);
...

This bug is back using 1.19.3

W_V

Fantastime

Confirmed

Normal

Rendering

overflow, precision-loss

19w40a, 19w46a, 1.15 Pre-release 4, 1.15 Pre-release 6, 1.15, ..., 1.17.1, 21w43a, 1.18.1, 1.18.2, 22w11a

23w03a

Retrieved