
CobblemonOptimizer
CobbleOptimizer is a server-side Fabric mod that reduces lag caused by Cobblemon's Pokemon entities.
Список изменений
The bug was caused by calling entity.discard() directly inside the ENTITY_LOAD / EntityJoinLevelEvent handler — the moment a chunk loads an entity into the
world.
At that point, the entity tracker hasn't finished registering the entity yet. It hasn't determined which players are in range, and hasn't sent spawn or
destroy packets to anyone. Discarding the entity in this transitional state could cause the tracker to partially register an already-removed entity — some
clients would receive a spawn packet but never get the matching destroy packet, leaving a ghost entity stuck on their screen that other players can't see.
Fix: Instead of discarding immediately during chunk load, entities are now added to a pendingChunkLoadDiscards list. This list is drained at END_SERVER_TICK, after the entity tracker has had a full tick to sync with all clients. At that point, discard() goes through the normal removal flow and every client gets the destroy packet properly.