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-162592 Guardian laser does not show up Resolved MC-167303 Guardian laser doesn´t render Resolved MC-168477 Visual Bug with Guardians Resolved MC-168761 Gaurdian Beam Not Showing Up Resolved MC-168892 Elder Guardian's Ray is a bubble trail 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);
...

Relates to MC-1279 and MC-63720

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