mojira.dev
MC-177381

Game does not count the distance properly if you locate a structure from more than 46340 blocks away

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

  1. Start a new world using the seed that is in the screenshot

  2. Teleport to something like 58000 ~ 6248

  3. Locate a Stronghold
    → ✔ It should be about maximally 37000 blocks away, the counting works correctly

  4. Teleport 46340 blocks away from the nearest stronghold
    → ✔ Still works correctly

  5. Go 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

Attachments

Comments

migrated

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

muzikbike

Confirmed for 21w06a:

[media]

COMETC2021A1

In 1.20.5.

migrated

(Unassigned)

Confirmed

Commands

1.15.2, 20w14a, 20w15a, 20w16a, 20w17a, ..., 21w41a, 21w42a, 1.19.1 Pre-release 2, 23w33a, 1.20.5

Retrieved