diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs
index ab6ed33c..7f820222 100644
--- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs
+++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Converters/ItemCoverter.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
@@ -10,6 +11,10 @@ using StardewValley;
namespace Revitalize.Framework.Utilities.Serialization.Converters
{
+ ///
+ /// TODO:
+ /// Add support for all vanilla SDV objects in deserialization.
+ ///
public class ItemCoverter:Newtonsoft.Json.JsonConverter
{
@@ -72,7 +77,20 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
string t = jo["Type"].Value();
- if(t== typeof(StardewValley.Tools.Axe).FullName.ToString())
+
+ Assembly asm = typeof(StardewValley.Object).Assembly;
+ Type type = null;
+
+ type = asm.GetType(t);
+
+ if (type == null)
+ {
+ asm = typeof(Revitalize.ModCore).Assembly;
+ type = asm.GetType(t);
+ }
+ return JsonConvert.DeserializeObject(jo["Item"].ToString(),type, this.settings);
+ /*
+ if (t== typeof(StardewValley.Tools.Axe).FullName.ToString())
{
Revitalize.ModCore.log("DESERIALIZE AXE!!!");
//return jo["Item"].Value();
@@ -80,7 +98,7 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
}
else if (t == typeof(Revitalize.Framework.Objects.MultiTiledObject).FullName.ToString())
{
-
+
Revitalize.ModCore.log("DESERIALIZE Multi Tile Object!!!");
return JsonConvert.DeserializeObject(jo["Item"].ToString(), this.settings);
// return jo["Item"].Value();
@@ -100,6 +118,8 @@ namespace Revitalize.Framework.Utilities.Serialization.Converters
throw new NotImplementedException("CANT DESERIALIZE: " + t.ToString());
}
+ */
+
}
diff --git a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
index 6c065c69..026334a9 100644
--- a/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
+++ b/GeneralMods/Revitalize/Framework/Utilities/Serialization/Serialization.cs
@@ -66,6 +66,21 @@ namespace Revitalize.Framework.Utilities
}
}
+ public object Deserialize(string p,Type T)
+ {
+ string json = "";
+ foreach (string line in File.ReadLines(p))
+ {
+ json += line;
+ }
+ using (StreamReader sw = new StreamReader(p))
+ using (JsonReader reader = new JsonTextReader(sw))
+ {
+ object obj = this.serializer.Deserialize(reader,T);
+ return obj;
+ }
+ }
+
///
/// Serializes an object to a .json file.
///
diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs
index 3900a308..ee7f1deb 100644
--- a/GeneralMods/Revitalize/ModCore.cs
+++ b/GeneralMods/Revitalize/ModCore.cs
@@ -282,6 +282,10 @@ namespace Revitalize
}
Game1.player.addItemToInventory(customObjects["Omegasis.BigTiledTest"]);
+ StardewValley.Tools.Axe axe = new StardewValley.Tools.Axe();
+ Serializer.Serialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"), axe);
+ axe =(StardewValley.Tools.Axe)Serializer.Deserialize(Path.Combine(this.Helper.DirectoryPath, "AXE.json"),typeof(StardewValley.Tools.Axe));
+ Game1.player.addItemToInventory(axe);
}