Browse Source

[MoreLights] [2.0.3.8] could not register exceptions

Zariteis 4 years ago
parent
commit
39b495d544
2 changed files with 11 additions and 6 deletions
  1. 9 4
      MoreLights/ItemUtil.cs
  2. 2 2
      MoreLights/MoreLights.cs

+ 9 - 4
MoreLights/ItemUtil.cs

@@ -7,7 +7,6 @@ namespace MoreLights
   {
     public static int CreatePlacableLightItem(string tileImgPath, string itemImgPath, string name, Color color)
     {
-
       Texture2D textureTile = GadgetCoreAPI.LoadTexture2D(tileImgPath);
       Texture2D textureItem = GadgetCoreAPI.LoadTexture2D(itemImgPath);
 
@@ -21,10 +20,16 @@ namespace MoreLights
       };
 
       ItemInfo itemInfo = new ItemInfo(ItemType.GENERIC, name, "", textureItem);
-      itemInfo.Register(name);
-      new TileInfo(TileType.NONSOLID, textureTile, gameObject, itemInfo).Register(name);
+      int itemID = ItemRegistry.Singleton.Register(itemInfo, name);
+      if (itemID == -1)
+        throw new System.Exception("Could not register Item " + name);
+
+      TileInfo tileInfo = new TileInfo(TileType.NONSOLID, textureTile, gameObject, itemInfo);
+      int tileID = TileRegistry.Singleton.Register(tileInfo, name);
+      if (tileID == -1)
+        throw new System.Exception("Could not register Tile " + name);
 
-      return itemInfo.GetID();
+      return itemID;
     }
   }
 }

+ 2 - 2
MoreLights/MoreLights.cs

@@ -8,7 +8,7 @@ namespace MoreLights
   [Gadget("MoreLights", LoadAfter: new string[] { "ScrapYard" }, Dependencies: new string[] { "ScrapYard" })]
   public class MoreLights : Gadget<MoreLights>
   {
-    public const string MOD_VERSION = "1.2"; // Set this to the version of your mod.
+    public const string MOD_VERSION = "1.3"; // Set this to the version of your mod.
     public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
 
     public override IGadgetConfigMenu GetConfigMenu() { return null; }
@@ -31,7 +31,7 @@ namespace MoreLights
 
       foreach (var e in ShopPlatform.DefaultObjects.GetShopPlatformEntries())
       {
-        if(e.ItemID == 2401 || e.ItemID == 2402)
+        if (e.ItemID == 2401 || e.ItemID == 2402)
         {
           ShopPlatform.DefaultObjects.RemoveShopPlatformEntry(e);
         }