How to Fix java.lang.NullPointerException Crash in Minecraft
Fix NullPointerException crashes in Minecraft clients and servers. Covers corrupt data, plugin bugs, mod conflicts, and world repair for Java Edition 1.21+.
How to Fix java.lang.NullPointerException Crash in Minecraft
The Error
java.lang.NullPointerException: Cannot invoke method because object is null
at net.minecraft.world.level.chunk.LevelChunk.getBlockState(LevelChunk.java:...)
at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:...)
---- Minecraft Crash Report ----
Description: Ticking world
A NullPointerException (NPE) means the game tried to use an object that does not exist. This is a programming error, either in Minecraft itself, in a mod, or in a plugin. The crash report tells you exactly where the null reference occurred.
Quick Fix
Read the crash report's stack trace. If a plugin or mod name appears in the trace, update or remove that plugin/mod. If only vanilla Minecraft classes appear, the issue is likely corrupt world data. Restore from a backup or use MCA Selector to delete the affected chunks.
Step-by-Step Diagnosis
- Open the crash report. On the client:
.minecraft/crash-reports/. On a server:crash-reports/in the server directory. The file name includes the date and time. - Read the stack trace. The first line after "java.lang.NullPointerException" shows the class and method where the error occurred. If it mentions a plugin package (like
com.example.myplugin), that plugin is the cause. - Check if the NPE is in vanilla code. If the stack trace only shows
net.minecraftclasses, the issue is corrupt data, usually a chunk or entity with missing NBT tags. - Update the offending plugin/mod. Check the plugin/mod page for updates. Developers frequently fix NPE bugs in patch releases.
- If it is a world issue, identify the chunk. The crash report often includes coordinates. Convert them to chunk coordinates by dividing by 16. Use MCA Selector to inspect and delete the corrupt chunk.
- Test with a fresh world. Rename your world folder and start the server. If it runs without crashing, the original world contains corrupt data.
Common Causes
- Plugin bugs. Plugins that do not check for null players, null items, or null locations before using them are the most frequent source of NPEs on servers.
- Corrupt entity data. An entity with missing or invalid NBT data causes an NPE when the server tries to tick it. This can happen after a server crash during save.
- Mod API changes. When Minecraft updates, mod APIs sometimes change method signatures. A mod compiled against 1.20 may throw NPEs on 1.21 because a method that used to return a value now returns null.
- Corrupt player data. If a player's
.datfile inworld/playerdata/is corrupted, the server crashes when that player logs in. Delete the player's.datfile (they will respawn at world spawn and lose inventory). - Race conditions. In rare cases, async operations in plugins cause NPEs because an object was removed between the null check and its use. This is a plugin bug that the developer must fix.
Preventing NPE Crashes
- Keep regular backups of your world, player data, and plugin configs.
- Update plugins and mods promptly when patches are released.
- Do not use plugins or mods marked as alpha or experimental on production servers.
- Use Paper or Purpur, which include additional null safety checks compared to Spigot.
FAQ
Does a NullPointerException corrupt my world?
The NPE itself does not corrupt anything. However, the crash might interrupt a save operation, which can corrupt chunks. Always use a backup strategy.
Can I fix a NullPointerException without removing the mod?
If the mod developer has released a fix, update to the latest version. If not, you can report the bug with the crash report. There is no way to fix the bug yourself without modifying the mod's code.
Why does the NPE only happen with certain players?
The likely cause is corrupt player data. Delete that player's .dat file from world/playerdata/. The player will respawn at spawn with an empty inventory.
Is NullPointerException the same as a ticking entity crash?
Not always. Ticking entity crashes can be caused by NPEs, but also by other exceptions. The crash report specifies the exact exception type.
Need a server that handles all this? Astroworld Hosting, NVMe SSDs, Pterodactyl panel, DDoS protection on every plan.