The bug
I was locating a structure and it is for example, a million blocks away. So, I was about 2977739 blocks away, however, the game said it is about 46000 blocks away. But I came one more block away from it, it said it is 0 blocks away. This firstly happens when the distance from the closest structure exceeds 46340 blocks.
How to reproduce
Start a new world using the seed that is in the screenshot
Teleport to something like 58000 ~ 6248
Locate a Stronghold
→ ✔ It should be about maximally 37000 blocks away, the counting works correctlyTeleport 46340 blocks away from the nearest stronghold
→ ✔ Still works correctlyGo one more block away from it
→❌ It says it is 0 blocks away
Plus, it doesn't always say it is 0 blocks away. Try teleporting different distances and if you are lucky, it might not say it is 0 blocks away. Look in the screenshots.
Linked issues
is duplicated by
Attachments
Comments


Confirmed for 21w06a:
[media]

In 1.20.5.
Can reproduce.
I'm guessing its an issue with using 32 bit ints and pythagorean theorem (46341^2 is bigger than the 32 bit integer limit)
also duplicate of MC-174659 but this one is more specific