This repository was archived by the owner on Dec 8, 2025. It is now read-only.
forked from AqlaSolutions/MagicStorage
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMagicStorageExtra.cs
More file actions
100 lines (86 loc) · 2.8 KB
/
MagicStorageExtra.cs
File metadata and controls
100 lines (86 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using MagicStorageExtra.Edits;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.UI;
namespace MagicStorageExtra
{
public partial class MagicStorageExtra : Mod
{
public static MagicStorageExtra Instance;
public static Mod bluemagicMod;
public static Mod legendMod;
public static Mod MagicStorage;
public static Mod ItemChecklist;
public static string GithubUserName => "ExterminatorX99";
public static string GithubProjectName => "MagicStorageExtra";
public static ModHotKey IsItemKnownHotKey { get; private set; }
public Mod[] AllMods { get; private set; }
public override void Load()
{
//if (ModLoader.GetMod("MagicStorage") != null)
// throw new Exception("\"Magic Storage - Extra\" and \"Magic Storage\" are not compatible");
Instance = this;
InterfaceHelper.Initialize();
legendMod = ModLoader.GetMod("LegendOfTerraria3");
bluemagicMod = ModLoader.GetMod("Bluemagic");
MagicStorage = ModLoader.GetMod("MagicStorage");
ItemChecklist = ModLoader.GetMod("ItemChecklist");
AddTranslations();
AddGlobalItem("MagicStorageExtraItemSaveLoadHook", new ItemSaveLoadHook());
IsItemKnownHotKey = RegisterHotKey("Is This Item Known?", "");
RecursiveCraftIntegration.Load();
EditsLoader.Load();
}
public override void PostAddRecipes()
{
RecursiveCraftIntegration.InitRecipes();
}
public override void Unload()
{
Instance = null;
bluemagicMod = null;
legendMod = null;
MagicStorage = null;
IsItemKnownHotKey = null;
StorageGUI.Unload();
CraftingGUI.Unload();
RecursiveCraftIntegration.Unload();
EditsLoader.Unload();
}
public override void PostSetupContent()
{
Type type = Assembly.GetAssembly(typeof(Mod)).GetType("Terraria.ModLoader.Mod");
FieldInfo loadModsField = type.GetField("items", BindingFlags.Instance | BindingFlags.NonPublic);
AllMods = ModLoader.Mods.Where(x => !x.Name.EndsWith("Library", StringComparison.OrdinalIgnoreCase))
.Where(x => x.Name != "ModLoader")
.Where(x => ((IDictionary<string, ModItem>)loadModsField.GetValue(x)).Count > 0)
.ToArray();
}
public override void HandlePacket(BinaryReader reader, int whoAmI)
{
NetHelper.HandlePacket(reader, whoAmI);
}
public override bool HijackGetData(ref byte messageType, ref BinaryReader reader, int playerNumber)
{
EditsLoader.MessageTileEntitySyncing = messageType == MessageID.TileSection;
return false;
}
public override void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
{
InterfaceHelper.ModifyInterfaceLayers(layers);
}
public override void PostUpdateInput()
{
if (!Main.instance.IsActive)
return;
StorageGUI.Update(null);
CraftingGUI.Update(null);
}
}
}