A server-side Fabric mod (Minecraft 1.21.1, Java 21, v1.5.1, group com.packetfixer) that optimizes server→client network traffic. It's a DedicatedServerModInitializer, so it only runs on the server. It does two things: prevents crashes/disconnects caused by other mods' packets, and reduces bandwidth, latency, and network CPU.
The modules
-
Anti-disconnect for broken mod packets (ClientConnectionMixin) Inserts a handler into the Netty pipeline and intercepts exceptionCaught: if the error is an EncoderException containing custom_payload (i.e. a broken packet from some mod), it logs a warning and swallows it instead of kicking the player.
-
Custom payload throttling (PacketThrottler + Config → config/packetfixer.json) Max 50 custom payloads per tick per connection; the overflow goes into a queue (max 500, oldest dropped) and is resent at the start of the next tick using batched writes + a single Netty flush. It has adaptive congestion control: as the queue grows, the "live" budget scales down (back-pressure) while the flush budget scales up. Ping-critical packets (position, velocity, block update, inventory, health, sounds) always bypass the throttle, and the cobblemon namespace is excluded by default — clearly to avoid breaking battle packets.
-
Flush consolidation Adds a Netty FlushConsolidationHandler to merge multiple flushes into fewer syscalls, with an adaptive threshold based on player count (few players = low threshold = better ping; many = higher threshold = less CPU). A tick-end "flush pulse" makes sure nothing gets stuck sitting in the buffers.
-
Packet optimizers (PacketOptimizerConfig → config/packetoptimizer.properties)
- NBT stripper (EntityNbtMixin): removes server-only tags (Paper.Origin, Bukkit.updateLevel, etc.) and empty compounds
- Chunk optimizer (ChunkDataMixin): same cleanup for block entities in chunk data
- Lazy entity loader (LazyEntityTracker): entities beyond 16 bloy, but in batches of ~10 per tick
- Entity update throttle (EntityTrackerEntryMixin): entities more than 48 blocks from all players only send position updates every 3rd tick (~66% fewer packets)
- Compression tuning: forces the Deflater to level 1 via reflection (faster, slightly larger packets)
- Packet monitor (PacketEncoderMonitorMixin): logs warnings/erroMB — useful for finding which mod is sending huge packets
A couple of things worth knowing
ClientConnectionMixin uses reflection on the compressor's Deflatgile part, and it fails silently (catch + debug log) if theNetty/MC internals change. And the swallowed exceptionCaught means that if a mod genuinely has a serialization bug, the packet vanishes without the client ever knowing — intended here, but it can mask real problems.

