diff --git a/GeneralMods/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs
index 512ad4a1..f00de02b 100644
--- a/GeneralMods/StardustCore/Animations/AnimationManager.cs
+++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs
@@ -27,6 +27,16 @@ namespace StardustCore.Animations
public string animationDataString;
+
+ ///
+ /// Empty constructor.
+ ///
+ public AnimationManager()
+ {
+
+ }
+
+
///
/// Constructor for Animation Manager class.
///
diff --git a/GeneralMods/StardustCore/ModCore.cs b/GeneralMods/StardustCore/ModCore.cs
index 7f567191..c0200497 100644
--- a/GeneralMods/StardustCore/ModCore.cs
+++ b/GeneralMods/StardustCore/ModCore.cs
@@ -6,6 +6,7 @@ using StardewValley.Menus;
using StardewValley.Network;
using StardustCore.Menus;
using StardustCore.ModInfo;
+using StardustCore.NetCode;
using StardustCore.Objects;
using StardustCore.Objects.Tools;
using StardustCore.Serialization;
@@ -61,6 +62,9 @@ namespace StardustCore
StardewModdingAPI.Events.MenuEvents.MenuChanged += MenuEvents_MenuChanged;
StardewModdingAPI.Events.MenuEvents.MenuClosed += MenuEvents_MenuClosed;
+ ModHelper.Events.Multiplayer.PeerContextReceived += Multiplayer_PeerContextReceived;
+ ModHelper.Events.Multiplayer.ModMessageReceived += Multiplayer_ModMessageReceived;
+
IlluminateFramework.Colors.initializeColors();
ContentDirectory = "Content";
if (!Directory.Exists(ContentDirectory)) Directory.CreateDirectory(Path.Combine(ModHelper.DirectoryPath, "Content"));
@@ -82,6 +86,31 @@ namespace StardustCore
}
+ private void Multiplayer_ModMessageReceived(object sender, StardewModdingAPI.Events.ModMessageReceivedEventArgs e)
+ {
+ if (e.FromModID == this.ModManifest.UniqueID)
+ {
+ if (e.Type == MultiplayerSupport.CleanUpModObjects)
+ {
+ SerializationManager.cleanUpInventory();
+ SerializationManager.cleanUpWorld();
+ SerializationManager.cleanUpStorageContainers();
+ }
+ else if (e.Type == MultiplayerSupport.RestoreModObjects)
+ {
+ SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
+ }
+ }
+ }
+
+ private void Multiplayer_PeerContextReceived(object sender, StardewModdingAPI.Events.PeerContextReceivedEventArgs e)
+ {
+ //ModMonitor.Log("TRY TO CLEAN UP THE MESS!!!!");
+ SerializationManager.cleanUpInventory();
+ SerializationManager.cleanUpWorld();
+ SerializationManager.cleanUpStorageContainers();
+ }
+
private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e)
{
if (Game1.IsMasterGame == false && config.enableMultiplayerHack)
@@ -171,6 +200,8 @@ namespace StardustCore
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
+ ModHelper.Multiplayer.SendMessage(MultiplayerSupport.RestoreModObjects, MultiplayerSupport.RestoreModObjects,new string[] { ModManifest.UniqueID }, null);
+
/*
List> objs = new List>();
diff --git a/GeneralMods/StardustCore/NetCode/MultiplayerSupport.cs b/GeneralMods/StardustCore/NetCode/MultiplayerSupport.cs
new file mode 100644
index 00000000..d6c1c464
--- /dev/null
+++ b/GeneralMods/StardustCore/NetCode/MultiplayerSupport.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StardustCore.NetCode
+{
+ public class MultiplayerSupport
+ {
+ public static string CleanUpModObjects = "Omegasis.StardustCore.MultiplayerSupport.CleanUpModObjects";
+ public static string RestoreModObjects = "Omegasis.StardustCore.MultiplayerSupport.RestoreModObjects";
+
+ }
+}
diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj
index 7c591de9..2b4a22c0 100644
--- a/GeneralMods/StardustCore/StardustCore.csproj
+++ b/GeneralMods/StardustCore/StardustCore.csproj
@@ -99,6 +99,7 @@
+