0

As far as I know, you can walk for 30 million meters in either direction in Minecraft to reach the end of the world.
My question is, how does Minecraft handle loss of precision when dealing with player position (especially in multiplayer)?

And how could I implement it?

Macho Onion
  • 189
  • 8
Moons
  • 103
  • 3
  • 3
    Minecraft, somewhat infamously, does not deal with floating point precision especially well, with the gameplay becoming jittery past about 500 000 blocks from the origin and getting progressively worse at each power of two, poor performance, and level generation glitches and failures. If you want to handle large worlds in your game, you can find much better models to follow than Minecraft. Consider editing your question to describe your own game development problem that you need help with, and we can help you solve it. – DMGregory Jan 02 '22 at 23:30
  • 1
    Minecraft deals with it by expecting that you won’t go that far, and most people don’t go that far, so problem solved. This is, as you may tell, a bad approach. And it wouldn’t work for games which deal with larger distances more often. – Topcode Jan 02 '22 at 23:51
  • @DMGregory Thank you for the link. This question is not about a problem in my own development. The question came to my mind when I was learning about Minecraft's 2b2t server where players build bases at questionable coordinates (for example at 3mil, 0, 3mil) and I was wondering how is that possible/playable. – Moons Jan 03 '22 at 09:15
  • 1
    For future reference, this StackExchange is specifically for Q&A about making new original games and game mods, not for curiosity about existing games. We will not always be able to answer questions about how a particular game implemented some feature, but we can offer ways that you can implement a similar feature. If you'd like to continue using this site, please frame future questions in this lens to keep them on-topic. – DMGregory Jan 03 '22 at 11:48

1 Answers1

4

By nature of floating point precision, Minecraft starts to have issues as close as 33.5 million blocks in any direction, where the lighting engine stops working, and at over 1 billion blocks, where villages stop generating correctly. Problems like these led to Minecraft's developers to make the hard limit of 30 million, though this limit was only finalized in 1.8, with early implemenations existing as far as Infdev version 20100313 This isn't any raw technical limit, just an arbitrary one. The actual technical limit is the signed 32-bit integer in Java (±2,147,483,647). Basically, Minecraft's way of reducing errors caused by floating-point precision loss is just making it impossible to go to areas it affects.

  • Thank you for the answer. Shouldn't Minecraft have issues with loss of precision A LOT closer than the hardcoded 30 million? – Moons Jan 03 '22 at 09:18
  • 1
    @MdNarimani if you check the link I gave you above, it does have issues a lot closer. Noticeable snapping/jitter starts to creep in around 500 k blocks from.the origin. If you check the precision table in this answer, you can see that's where the precision error first exceeds 3% of one unit. Minecraft isn't doing anything particularly savvy, it just doesn't have gameplay or naturalistic animation that needs precision to the third or fourth decimal place to look correct, so the errors in the shallow end aren't bothersome to many players. – DMGregory Jan 03 '22 at 11:40
  • That link is from a very outdated version of the game and issues like that have mostly been fixed. – Elijah Ciali Jan 04 '22 at 02:19