promotional bannermobile promotional banner

Weather, Storms & Tornadoes - Concurrent Packet Fix

Eliminates ConcurrentModificationException disconnects by implementing thread-safe NBT serialization—a global patch that fixes Weather2 and any other mod with similar multi-threading bugs

CompoundTag Concurrent Modification Fix

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.

🔍 The Problem

bug-report

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.

🛠️ The Solution

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:

  • Lock-Free Retries: Dynamically captures the internal map state without introducing thread deadlocks.
  • Fail-Safe Cap: Enforces a strict 100-retry limit. If exceeded, it safely writes an empty tag to maintain connection stability.
  • Rapid Execution: In real-world environments, the safe snapshot successfully resolves within 1–3 attempts.

✨ Key Features

  • Universal Protection: Automatically shields any mod that improperly handles NBT data across multiple threads.
  • Zero Configuration: A true plug-and-play solution. No config files or tweaks needed.
  • Non-Invasive Architecture: Leaves individual mod source codes untouched, drastically reducing conflict risks.
  • Stress-Tested Performance: Verified at accelerated rates of 1000 TPS with negligible processing overhead.
  • Future-Proof Design: Acts as a passive fail-safe. If a mod resolves its threading bugs upstream, this patch gracefully becomes a "no-op" (no operation) to maintain vanilla behaviour.

⚙️ Supported Versions & Loaders

This mod is built to be highly versatile across modern modding ecosystems:

  • Mod Loaders: Minecraft Forge and NeoForge
  • Game Versions: Minecraft 1.20.x, 1.21.x, and any adjacent versions suffering from NBT-driven network drops (just ignore the compatibility warnings).

💬 Frequently Asked Questions

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]

The Weather, Storms & Tornadoes - Concurrent Packet Fix Team

profile avatar
  • 1
    Followers
  • 1
    Projects
  • 23.6K
    Downloads