Lethal Company
You are viewing a potentially older version of this package. View Latest Version
Install with App

Details

Date Uploaded
2 months ago
Downloads
248
Size
8.6KB

LethalLib Prefab Guard

Prevents the "ship stuck in the landing state" soft-lock caused by mods registering broken (null) items or enemies through LethalLib.

The problem

LethalLib's StartOfRound.Start hook iterates its registered-prefab list before running the game's own round-start logic. If any mod registered a null prefab (common after game updates break old asset bundles), that loop throws and the vanilla StartOfRound.Start never runs. Symptoms:

  • Ship stuck in the "landing" state forever — HUD works, nothing else does
  • Dark screen / unresponsive controls when loading in
  • Ship interior mods (e.g. wider/two-story ships) present but not applying, with flickering or white-streak textures

What this does

Right before StartOfRound.Start, this guard:

  1. Removes null entries from LethalLib's prefabsToFix list
  2. Removes null entries from StartOfRound.allItemsList
  3. Logs a CULPRIT: warning naming the mod that registered each broken item/enemy (using LethalLib's own registration metadata), so you know what to update or remove

If nothing is broken, it does nothing. Works with or without LethalLib installed.

Technical note

A Harmony prefix cannot guard against this: HarmonyX patches the original method (innermost layer) while MonoMod On. hooks wrap outside it, so LethalLib's hook throws before any prefix runs. This guard installs its own MonoMod hook after LethalLib's, making it the outer layer.

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.