How to Optimize Minecraft: Simple Things Mojang Can Do
After 1.13, making Minecraft: Java Edition is optimized once again can seem like a daunting task. However, there are some relatively simple things Mojang can do to optimize Minecraft. In this article, we will be taking a lesson from the development of other games and seeing how we can make things a little easier for Mojang since multithreading the game can often be a daunting and difficult task with code as old as Minecraft. See how Mojang can multithread the game here (Credit: AntVenom):
If you’re working for Mojang and read this article, you’re welcome to take any of these ideas for yourself. You don’t need to pay me any royalties. I will be rewarded by my server running faster.
Step 1: Optimize Minecraft Mob AI for client when server lag occurs
So one thing that many developers of some games will do with NPCs is when the client is not getting packets from the server, the client will calculate the trajectory of mobs on its own, and that will at least make the game feel more smooth to the player and will alert them when a mob is coming towards them.
While this would do nothing to speed up server TPS (TPS stands for Ticks Per Second. Learn more here: https://apexminecrafthosting.com/what-is-minecraft-tps/), it would at least make the game seem more tolerable, and improve things a lot for players on slow network connections. It’s something to think about. When the connection is restored to the server, the server sends a packet to the client telling them the real position of the mob and at worse, the server rubber-bands the mob.
Step 2: Optimize Minecraft Latency by Sharing the Seed
While this well wouldn’t improve server TPS that much, it may improve two things: network bandwidth for the server and the client, and possibly world save files. The server shares the seed with the client when it logs in.
Once the seed is shared, the client will generate the terrain client-side, and anything that was changed from other players or whatever will be sent to the client after the seed and placed in chunks loaded by the client. This should greatly improve network bandwidth. As for saving data on the world save files, this should be optional as it may cause server-side lag, as the server would have to regenerate the chunk every time it’s loaded.
Step 3: Make Redstone not Produce Light
If you watch Mumbo Jumbo, you may notice that on Hermitcraft, he uses as many Observers as possible to replace Redstone wire. He does this because Redstone produces lighting updates, and lighting can tend to be extremely slow. How to fix that? Simple. Make Redstone not produce light anymore. It does not affect the game other than making it lag. So why not just get rid of it? Mojang can also make the Redstone lighting updates client-side only. Simple but effective.
Step 4: Update the Java Version
The Minecraft Launcher uses Java 11, and Mojang compiles Minecraft Java Edition using Java 8. While this may break some older projects, it would be a good idea to upgrade Java versions to at least Java 12. Java 11 and Java 8 are both ancient versions of Java. Java 12 includes something called the Shenandoah GC, which greatly improves garbage collecting. While it’s impossible to say for sure, just using the Shenandoah GC for me has been more effective at lag prevention than using Aikar’s complex and well-thought-out set of JVM flags for starting the server.
Well, those are just some simple things Mojang can do to optimize Minecraft: Java Edition greatly. And believe me, it really does need optimization.
Too bad Microsoft doesn’t want them to optimize Java.