diff --git a/Source/Client/Syncing/Handler/SyncAction.cs b/Source/Client/Syncing/Handler/SyncAction.cs index 21ad38bf..2c084502 100644 --- a/Source/Client/Syncing/Handler/SyncAction.cs +++ b/Source/Client/Syncing/Handler/SyncAction.cs @@ -113,8 +113,18 @@ public void PatchAll(string methodName) postfix.priority = MpPriority.MpLast; - Multiplayer.harmony.PatchMeasure(method, prefix, postfix); - SyncActions.syncActions[method] = this; + // Types with StaticConstructorOnStartup may be loading resources, which causes issues with + // modded types. I assume that vanilla types end up loading their resources at some point earlier. + if (method.DeclaringType?.Assembly != typeof(Game).Assembly && method.DeclaringType.HasAttribute()) + LongEventHandler.ExecuteWhenFinished(Patch); + else + Patch(); + + void Patch() + { + Multiplayer.harmony.PatchMeasure(method, prefix, postfix); + SyncActions.syncActions[method] = this; + } } } }