10 internal static class ModifierIO
12 public const int SAVE_VERSION = 14;
14 public static Modifier NetReceive(Item item, BinaryReader reader)
16 string type = reader.ReadString();
17 string modName = reader.ReadString();
26 m.NetReceive(item, reader);
30 throw new Exception($
"Modifier _NetReceive error for {modName}");
33 public static void NetSend(
Modifier modifier, Item item, BinaryWriter writer)
35 writer.Write(modifier.GetType().
Name);
36 writer.Write(modifier.
Mod.Name);
37 ModifierPropertiesIO.NetSend(item, modifier.
Properties, writer);
38 modifier.NetSend(item, writer);
41 public static Modifier Load(Item item, TagCompound tag)
43 string modName = tag.GetString(
"ModName");
47 var saveVersion = tag.ContainsKey(
"SaveVersion") ? tag.GetInt(
"SaveVersion") : 1;
55 string modifierTypeName = tag.GetString(
"Type");
62 var p = ModifierPropertiesIO.
Load(item, tag.GetCompound(
"ModifierProperties"));
63 modifier.Properties = modifier.GetModifierProperties(item).Build();
64 modifier.Properties.Magnitude = p.Magnitude;
65 modifier.Properties.Power = p.Power;
66 modifier.Load(item, tag);
71 Loot.Logger.ErrorFormat(
"There was a load error for modifier, TC: {0}", tag);
75 public static TagCompound Save(Item item,
Modifier modifier)
77 var tag =
new TagCompound
79 {
"Type", modifier.GetType().
Name},
80 {
"ModName", modifier.
Mod.Name},
81 {
"ModifierProperties", ModifierPropertiesIO.Save(item, modifier.
Properties)},
82 {
"SaveVersion", SAVE_VERSION}
84 modifier.
Save(item, tag);
virtual void NetReceive(Item item, BinaryReader reader)
Defines a modifier, which is an unloaded GlobalItem Making it a GlobalItem gives easy access to all h...
static ModifierContent Modifier
ModifierProperties Properties
Defines the properties of a modifier
static NullModifier INSTANCE
virtual ModifierProperties.ModifierPropertiesBuilder GetModifierProperties(Item item)
Defines a "Null" modifier which represents no modifier safely Cannot be rolled normally ...
This class holds all Content holders of this mod You can use this to access content loaded into the m...
virtual void Save(Item item, TagCompound tag)
Allows modder to do custom saving here Use the given TC to put data you want to save, which can be loaded using Load(Item,TagCompound)
virtual new void Load(Item item, TagCompound tag)
Allows modder to do custom loading here Use the given TC to pull data you saved using Save(Item...
This class is responsible for loading mods into Even More Modifiers Mods can be registered and trigge...