Fix mod not loading when magic storage isn't loaded

This commit is contained in:
JavidPack
2022-08-03 02:44:27 -06:00
parent 8c17c38585
commit 3811a86c95

View File

@@ -13,6 +13,7 @@ namespace ItemChecklist
// Here we show a few pitfalls that might cause a TypeInitializationException to be thrown.
// Remember, you have to gate all access to Types and Methods defined in the weakly referenced mod or it will crash.
// All calls to methods in this class by this mod besides Load and Unload are gated with a check to Enabled.
[JITWhenModsEnabled("MagicStorage")]
static class MagicStorageIntegration
{
// Here we store a reference to the MagicStorage Mod instance. We can use it for many things.
@@ -47,7 +48,7 @@ namespace ItemChecklist
public static void Load()
{
MagicStorage = ModLoader.GetMod("MagicStorage");
ModLoader.TryGetMod("MagicStorage", out MagicStorage);
if (Enabled)
//MagicStorageIntegrationMembers.tile = null; // Will also crash. Here even though Enabled will be false, the Type of tile will still need to be resolved when this method runs.
//members = new MagicStorageIntegrationMembers(); // Even thought the Type StorageAccess is hidden behind MagicStorageIntegrationMembers, this line will also cause MagicStorageIntegrationMembers and consequently StorageAccess to need to be resolved.