A lightweight Mixin patch that eliminates client disconnections caused by java.util.ConcurrentModificationException during NBT data serialisation. While developed to resolve a long-standing issue in the original Weather, Storms & Tornadoes (Weather2) mod, this mod applies a global, engine-level fix to protect your entire modpack.

Minecraft frequently disconnects clients when a mod attempts to encode a CompoundTag (NBT) from an asynchronous network thread (such as Netty I/O) while the main game thread is simultaneously modifying that same tag. Because Java’s standard HashMap is inherently non-thread-safe, this concurrent access triggers an immediate ConcurrentModificationException. Minecraft handles this error by instantly dropping the client connection, disrupting gameplay.
Instead of chasing individual mod updates, this patch injects directly into vanilla Minecraft's net.minecraft.nbt.CompoundTag.write() method. It intercepts the serialisation process and implements an optimised "safe snapshot" mechanism:
This mod is built to be highly versatile across modern modding ecosystems:
Q: Does this only work for Weather2?
A: No. Weather2 was the catalyst for development, but the fix operates at the vanilla engine level. Any mod executing asynchronous NBT modifications will benefit.
Q: Will this impact server or client performance?
A: No. The execution overhead is completely negligible. Testing under extreme tick-simulated environments showed zero degradation in frame rates or tick times.
Q: Do I need to configure anything?
A: No. The patch activates automatically upon initialisation. You can confirm it is running by checking your console for: [weather2patch] CompoundTag thread-safety patch is active.
Q: What happens if an upstream mod updates and fixes the bug?
A: Nothing breaks. Because this mod targets the vanilla layer, it will simply notice the thread state is already clean, bypass retries entirely, and let the vanilla code take over.
[Description Updated with the help of Gemini 3.1 Flash]