Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
ItemLagFix
Client-side prediction for picking up, dropping and placing items, plus network and frame-time fixes. Only you need it.
| Last updated | 35 minutes ago |
| Total downloads | 8 |
| Total rating | 0 |
| Categories | BepInEx Client-side Tweaks & Quality Of Life AI Generated |
| Dependency string | Jackman_super-ItemLagFix-1.0.0 |
| Dependants | 0 other packages depend on this package |
This mod requires the following mods to function
BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2100README
ItemLagFix
A BepInEx 5 plugin for Lethal Company (v73). It makes picking up, dropping, placing and using items feel instant when you play in someone else's lobby. It also removes some per-frame CPU waste the game has.
It sends no new network messages. Only the person who wants the improvement needs it installed. It works in lobbies where nobody else has it, including the host.
Why items feel laggy
The way items work in vanilla on a client (anyone who isn't the host):
| Action | What vanilla does | What you notice |
|---|---|---|
| Pick up | Asks the host, waits for its answer, and only then puts the item in your slot. It then waits for the rest of the grab animation. | Every pick-up takes one full ping plus the animation. Use, drop and interact presses made in that time are silently ignored. |
| Drop / throw | Moves the item locally, then waits for the host to echo the drop back. | Until the echo arrives you can't pick anything up, because Interact is blocked while throwingObject is true. You also can't drop another item. |
| Place on ship furniture | Asks the host whether you may place it. After the yes, it starts the normal placement, which waits for a second echo. | Two full round trips. |
| Key or other consumed item | Destroys the item, then waits for the echo. | Your hands stay locked for one ping. |
| Use (left click) | Already runs locally first. | Use was never lagged on its own. It was blocked by the pick-up and drop waits above. |
What the plugin does
Prediction (clients only; the host already has zero latency)
Drops, throws and placements finish immediately. The host always echoes these and never refuses them. The plugin applies the echo's effects right away and swallows the real echo when it arrives. A late echo would otherwise act on whatever you hold by then.
Pick-ups go into your inventory immediately. The plugin runs the "yes" branch of the host's answer as soon as you press E, and the animation timer starts at the same time. Only the step that needs the host to hand you ownership of the item waits for the host. That step enables the item's own functions and control tips, and the plugin runs it the moment ownership arrives.
If the host says no, the pick-up is undone exactly, and your previous item is re-equipped. The host says no when someone else grabbed the item first. The undo puts the item back exactly where it was and also reverses your carry weight and the scrap stats.
Ownership-dependent items are not predicted. Some items run code on pick-up that needs ownership of the item. The plugin finds these by scanning each item type's EquipItem code for ownership checks and RPCs, and those items use the vanilla pick-up. Ordinary scrap, which is most pick-ups, is predicted.
Ship furniture placement skips the extra "may I?" round trip. Whether the furniture exists is checked locally, which is the only check the host does.
Keys and other consumed items free your hands instantly.
Input buffer: presses of use, drop or interact made while a pick-up is still finishing are remembered. They run the moment it finishes, if they are at most 0.5 s old. They run through untouched copies of the vanilla input handlers.
Network
Nagle disabled. The Steam transport sends reliable messages with Nagle's algorithm on, so each message can be held back a few milliseconds in case another one can be bundled with it. Netcode already bundles everything once per frame, so that delay is pure added latency on every RPC, in both directions. This helps hosts too.
CPU / frame time
Whole-scene searches are cached. Some game code calls FindObjectOfType every frame for objects that usually don't exist, so the whole scene is searched every frame:
- Every spray can, every shower, every clipboard and the Kidnapper Fox.
- Every drop, three searches each time.
- Dead bodies at the Company.
These lookups are now cached, and a missing object is looked for at most twice a second.
Log spam is removed. The plugin strips Debug.Log from 48 per-frame and item-path methods; warnings and errors are kept. One example is PumaAI.Update, which has 20 log calls.
Info logs are cheaper. Unity no longer captures a stack trace for ordinary info log lines from any mod or the game, and that capture is the expensive part of logging.
What cannot be fixed client-side
- Other players' actions still reach you one ping late, because you see them when the host relays them. Only the host could change that.
- Spawned results, such as opening a gift box, still appear when the host spawns them.
- Scrap-to-ship credit and selling are decided by the host.
Config
The config file is BepInEx/config/lcmods.ItemLagFix.cfg. Every feature can be switched off on its own.
| Section | Key | Default | |
|---|---|---|---|
| Prediction | PredictDrops |
true | Drops, throws and placements finish instantly. |
| Prediction | PredictGrabs |
true | Instant pick-up with exact undo. |
| Prediction | PredictFurniturePlacement |
true | Skips the extra furniture round trip. |
| Prediction | PredictKeyDespawn |
true | Consumed items free your hands instantly. |
| Prediction | BufferInputsDuringGrab |
true | Turns the input buffer on or off. |
| Prediction | BufferWindowSeconds |
0.5 | The oldest a press may be and still be replayed. |
| Prediction | GrabPredictionBlocklist |
(empty) | Comma-separated item names that always use the vanilla pick-up. |
| Network | DisableNagle |
true | |
| Performance | CacheFindObjectOfType |
true | |
| Performance | StripLogSpam |
true | |
| Performance | CheapInfoLogs |
true | |
| Debug | SimulatedLatencyMs |
0 | Testing only: adds this much delay to everything you send. |
| Debug | VerboseLogging |
false | Logs every prediction, confirmation and undo. |
Testing it
- Join a friend's lobby, so you are a client and not the host.
- Set
SimulatedLatencyMs = 200. You can do this mid-game with a config-editor mod, or set it before starting. This adds 200 ms to your ping and makes vanilla's lag obvious. - Pick up, drop and re-grab items quickly, and put items in the cupboard. Then toggle
PredictGrabsandPredictDropsoff to compare. - Undo test: you and a friend press E on the same item at the same moment. The loser's copy should go back where it was.
- Set
SimulatedLatencyMsback to 0.
To see what it's doing, turn on VerboseLogging and read BepInEx/LogOutput.log.
Building
Run build.sh from Git Bash. It needs:
- The Roslyn compiler from Visual Studio 2022 Build Tools.
- The game's
Managedfolder. - BepInEx core from an r2modman profile.
The output is bin/ItemLagFix.dll. Install it as BepInEx/plugins/ItemLagFix/ItemLagFix.dll.
Note for High Quota runs
VLog reports every loaded mod, and ItemLagFix will appear in that report. Treat it as an unapproved mod for runs that only allow approved mods.