Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TileEntityBannerRenderer no smooth flag waving animation when worldTime is large #419

Closed
2 tasks done
Natsukiw opened this issue Feb 5, 2024 · 11 comments
Closed
2 tasks done
Assignees

Comments

@Natsukiw
Copy link

Natsukiw commented Feb 5, 2024

Initial Questions

  • I have searched this issue tracker and there is nothing similar already, and this is not on the list of known issues. Posting on a closed issue saying the bug still exists will prompt us to investigate and reopen it once we confirm your report.
  • I have verified that this issue occurs in a SUPPORTED environment, meaning I can reproduce this WITHOUT OptiFine, and without Bukkit+Forge server software like KCauldron, Thermos, Crucible, Mohist etc

Mod Version

2.6.0

Describe the Issue

It usually appears in the server and the value of worldtime is too large.
I tried a repair and it worked.

At methd renderTileEntityAt()
long worldTime = (banner.getWorldObj() != null ? banner.getWorldObj().getTotalWorldTime() : 0) % 1000;

Conflicting Mods

No response

Crash Report

No response

Other Details

No response

@Roadhog360
Copy link
Owner

long worldTime = (banner.getWorldObj() != null ? banner.getWorldObj().getTotalWorldTime() : 0) % 1000; Are you sure this wouldn't cause a jump in the banner's animation every 1000 ticks?

@Roadhog360
Copy link
Owner

Roadhog360 commented Feb 12, 2024

Issue could not be reproduced after setting the in-game time to 2 billion ticks, even after relogging. I also got a similar report for beacons, and once again was completely unable to reproduce the issue.

Please provide a world where the issue occurs. It can be with mods but if you can, I prefer a world that's just EFR.

@Roadhog360 Roadhog360 added the Cannot Reproduce When an issue cannot be replicated by its asignee label Feb 12, 2024
@makamys
Copy link
Collaborator

makamys commented Feb 12, 2024

Day time (DayTime in level.dat, which is what /time set sets) is not the same thing as the world time (Time, which increments by 1 each tick). If I change Time to a high value, I can reproduce the issue. At around 3280000 (~45.5 hours) the flag abruptly stops waving.

Apparently above 205885.8515625f, MathHelper.cos always returns the same value: -9.58738E-5.

@Roadhog360 Roadhog360 removed the Cannot Reproduce When an issue cannot be replicated by its asignee label Feb 12, 2024
@Roadhog360
Copy link
Owner

Roadhog360 commented Feb 12, 2024

Hm... I suspect mod 1000 would cause abrupt jumps in the animation, I feel as if we need to find a more specific value to wrap around the time by.

@Roadhog360
Copy link
Owner

What if we used Math.cos? What exactly is the difference anyways?

@makamys
Copy link
Collaborator

makamys commented Feb 12, 2024

I should also note that the issue also happens in a freshly created world if you go farther than X=467000, since the banner's coordinates are piped into the equation.

@makamys
Copy link
Collaborator

makamys commented Feb 12, 2024

What if we used Math.cos? What exactly is the difference anyways?

We should just avoid using large float values entirely, with Math.cos the corruption just becomes different. (The banner animation becomes choppy rather than stopping entirely.)

@Roadhog360
Copy link
Owner

Hm, I think for the coords I could probably mod it to not go past thst value, just loop back around. What should I mod the world time by? Maybe 3280000 or something so the skip in animation is rare?

@makamys
Copy link
Collaborator

makamys commented Feb 12, 2024

I think I figured it out, I replaced it with equivalent math that avoids large values.
7e8d829
Also derp, I tagged the wrong issue in the commit (#149)

@Roadhog360
Copy link
Owner

Roadhog360 commented Feb 12, 2024

Does this not skip the animations at all? I would think modding the animation by a unspecific value would cause skipping?

@makamys
Copy link
Collaborator

makamys commented Feb 12, 2024

Nope, it's smooth. The idea is that cos is periodic with a period of 2*PI, so x*2*PI is the same thing as (x%1)*2*PI. You can see that I split it apart like that in the code: MathHelper.cos(f3 * 0.01F * 2F * (float) Math.PI). And since f3 is modulo'd by 100, that means f3 * 0.01F is modulo'd by 1. So that checks out.

And adding in the extra modulos in animationProgress100's equation doesn't change anything either.
(x+y)%100==((x%100+y%100)%100), and (x*y)%100==((x%100)*y)%100. Proving this is left as an exercise to the reader ™️

Actually Wikipedia has my back: https://en.wikipedia.org/wiki/Modular_arithmetic#Basic_properties

In particular:

If a1 ≡ b1 (mod m) and a2 ≡ b2 (mod m), or if a ≡ b (mod m), then:

  • a1 + a2 ≡ b1 + b2 (mod m) (compatibility with addition)
  • k a ≡ k b (mod m) for any integer k (compatibility with scaling)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants