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.
 

Related issues

Attachments

Comments

migrated
[media][media][media]
migrated

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

SPGoding

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.

_BOBE

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)

migrated

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.)

migrated

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

SeaOfPixels

Big issue still present in 20w16a

migrated

@unknown, there is no need to say you confirmed for 20w16a. Saying you can also confirm this is enough. 20w16a is already in "Affects Versions" list.

migrated

How did Arisa add 19w40a? Is it because it is a bot?

migrated

When this gets fixed, I think that it will still be invisible, but optimizing the game should help, similar to MC-179845

migrated

Still present in 1.16 Pre-release 8

migrated

Still happens in 1.16.3, was wondering why I kept taking damage clearing out an ocean monument. All the beams were invisible.

FireRainV

Happens even when a world was created at 1.16.3, once it happens, this effect becomes permanent.
Optimizing, reloading chunks or resource packs won't have any effect.

Tried to re-create the world it happened to me at, the effect was visible, no idea what triggers it.

FireRainV

I found the bug cause:
After creating backups upon backups, deleting files in those backups...
When I tried to use NBTExplorer to modify the "Time" metadata in 'level.dat',
I found out that when this value reaches ~2800000 or above , this issue occurs.
Pasting this value or anything higher on a brand new world will have an 100% chance to cause this issue.

migrated

The fix for this is pretty easy, so easy I hope to see it implemented soon. The Guardian entity renderer alters the texture animation and other properties using the world tick time. Converting the world tick time to a float and using fractional render ticks causes overflows eventually.

The solution is dead simple and initially done by AMereBagatelle in this PR for the Sodium mod: https://github.com/jellysquid3/sodium-fabric/pull/419

It uses the current bounded day clock tick instead of the world tick. That is all.

Thanks!

migrated

Can confirm for 21w08b

migrated

Thanks @unknown for information, you are right. 

I also attached a save where this occurs.

migrated

I just encounter this bug on my 1.17.1 server and sure enough the time is past 2800000.

muzikbike

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

migrated

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.

ampolive

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);
...
muzikbike

Relates to MC-1279 and MC-63720

migrated

This bug is back using 1.19.3

migrated

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