Building a McMMOG means having a persistent and fluent gameoworld in which players can highly interact with each other. If important resources like diamonds get worthless your project is ruined and the server will die as the gameplay no longer provides any challenges.
This post talks about the need of Anti-Xray. You cannot successfully run a server with the mentioned gameplay without it.
There are some obvious things we need to fix:
- The World-Seed must stay a secret
If a user somehow knows your world-seed he can just re-generate the world locally and use world-manipulation tools to find all the important things (diamonds, spawners, structures).
- As soon as you send data to the player it is known
Normally Minecraft sends all the needed world-data to a player as soon as he is in the vicinity. It does not matter if you can or cannot see normally see specific blocks. Expect every bit of data visible to a player as soon as it delivered. Meaning: As soon as you send the ChunkData around 0-16 (most diamonds are here) in the world the player will know about it instantly. How exactly does not matter. You cannot take any influence anymore past this point in time.
- Xray is easy to install, use (and hide)
Everyone can install xray and everyone is going to if you do not punish it. With that said - even if you punish it severely a lot of people are still going to use it. Everyone thinks they can get away with it. Using simple plugins like XrayInformer can help a little bit but they have a huge drawback: Very high workload for your team (spying on your users to verify the results). And of course these tools can be tricked if you know how they work.
What is the minimal useful Anti-Xray?
To build a server with a working economy system you need at least a system that is able to:
- Hide the World-Seed
- Manipulate world-data that gets send to the players (remove ores)
- The ability to stream necessary block-updates on the fly when a player actually sees an ore/spawner/chest
- Be very performant on the Minecraft server thread
- Point 3 is generally only achievable by being multi threaded as well
- The advantage by using Xray must be at leas minimal (or better nearly neglectable)
4 and 5 are essential as Minecrafts code structure makes it nearly impossible to do any work in parallel. With 100+ players online you need every millisecond even with massive optimizations. There is nearly no room for heavy operations like world-data manipulation just for Anti-Xray.
How to implement Anti-Xray in 1.8 and earlier?
Minecraft 1.9 made some heavy changes to the way the world is saved and transmitted. I will present a good working solution in another post. To keep this short, as it is kinda obsolete now because of the 1.9 changes, this is how you would implement it:
- Hook the Netty outgoing queue of every player (or internal send-queue of mc)
- Listen to the Packets containing Chunk-Data
- Manipulate the data to either hide ores or replace common blocks with ores (see Orebfuscator for some visual examples)
- Keep a list of important structures (chests, visible ores) for every player
- regularly check the list of important structures and stream the actual block-data to the player if they are close enough
This first (and already pretty complex) solution will provide a basic protection against cheaters.