using HarmonyLib; using PluginLoader.Data; using Sandbox.Definitions; using VRage.Game; namespace PluginLoader.Patch; [HarmonyPatch(typeof(MyDefinitionManager), "LoadData")] public static class Patch_MyDefinitionManager { public static void Prefix(ref List mods) { try { var currentMods = new HashSet(mods.Select(x => x.PublishedFileId)); var newMods = new List(mods); var list = Main.Instance.List; foreach (var id in Main.Instance.Config.EnabledPlugins) { var data = list[id]; if (data is ModPlugin mod && !currentMods.Contains(mod.WorkshopId) && mod.Exists) { LogFile.WriteLine("Loading client mod definitions for " + mod.WorkshopId); newMods.Add(mod.GetModItem()); } } mods = newMods; } catch (Exception e) { LogFile.WriteLine("An error occured while loading client mods: " + e); throw; } } }