コード例 #1
0
 public static bool AddEnchantment_Prefix(Tool __instance, BaseEnchantment enchantment, ref bool __result)
 {
     try
     {
         if (enchantment == null)
         {
             return(true);
         }
         if (!enchantment.IsForge() && !enchantment.IsSecondaryEnchantment())
         {
             // Enchantment is a primary enchantment.
             __instance.enchantments.Add(enchantment);
             enchantment.ApplyTo(__instance, __instance.getLastFarmerToUse());
             __result = true;
             return(false);  // don't run original logic
         }
         if (__instance is MeleeWeapon && enchantment.IsForge())
         {
             if (enchantment is DiamondEnchantment)
             {
                 // Skip adding diamond enchantments, they should result in 3 other enchantments getting added in Forge.
                 __result = true;
                 return(false);  // don't run original logic
             }
             // Enchantment is a Weapon forging or Galaxy Soul enchantment
         }
         return(true);  // run original logic
     }
     catch (Exception ex)
     {
         ModMonitor.Log($"Failed in {nameof(AddEnchantment_Prefix)}:\n{ex}", LogLevel.Error);
         return(true);  // run original logic
     }
 }
コード例 #2
0
 public static void GetEnchantmentFromItem_Postfix(ref BaseEnchantment __result, Item base_item, Item item)
 {
     if (base_item != null && base_item is Slingshot sling && sling.CurrentParentTileIndex == 34 && Utility.IsNormalObjectAtParentSheetIndex(item, 896))
     {
         __result = new GalaxySoulEnchantment();
     }
 }
コード例 #3
0
 public BaseEnchantment GetEnchantment(Item item, BaseEnchantment ench)
 {
     if (item is Tool tool)
     {
         return(tool.enchantments.FirstOrDefault(e => e.GetName() == ench.GetName()));
     }
     return(null);
 }
コード例 #4
0
ファイル: Mod.cs プロジェクト: spacechase0/MoreEnchantments
        public override void Entry(IModHelper helper)
        {
            instance    = this;
            Log.Monitor = Monitor;

            BaseEnchantment.GetAvailableEnchantments().Add(new MoreLuresEnchantment());

            var harmony = HarmonyInstance.Create(ModManifest.UniqueID);

            harmony.PatchAll();
        }
コード例 #5
0
ファイル: Mod.cs プロジェクト: Pathoschild/smapi-mod-dump
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;
            Log.Monitor  = this.Monitor;

            BaseEnchantment.GetAvailableEnchantments().Add(new MoreLuresEnchantment());

            HarmonyPatcher.Apply(this,
                                 new FishingRodPatcher()
                                 );
        }
コード例 #6
0
        public override void receiveLeftClick(int x, int y, bool playSound)
        {
            Item item = Game1.player.items.Count > selected ? Game1.player.items[selected] : null;

            for (int i = 0; i < buttons.Length; i++)
            {
                if (buttons[i].Contains(x, y))
                {
                    if (item is Tool tool)
                    {
                        Game1.playSound("smallSelect");
                        BaseEnchantment ench = GetEnchantment(tool, enchantments[i + offset]);
                        if (ench != null)
                        {
                            tool.enchantments.Remove(ench);
                        }
                        else
                        {
                            tool.enchantments.Add(enchantments[i + offset]);
                        }
                    }
                    return;
                }
            }
            if (upArrow.containsPoint(x, y) && ScrollUp())
            {
                Game1.playSound("shwip");
                upArrow.scale = upArrow.baseScale;
                return;
            }
            if (downArrow.containsPoint(x, y) && ScrollDown())
            {
                Game1.playSound("shwip");
                downArrow.scale = upArrow.baseScale;
                return;
            }
            if (scrollBarTrack.Contains(x, y))
            {
                scrolling = true;
                return;
            }
            for (int i = 0; i < 36; i++)
            {
                if (inventory.inventory[i].containsPoint(x, y))
                {
                    Game1.playSound("stoneStep");
                    selected = i;
                    UpdateSelected();
                    return;
                }
            }
        }
コード例 #7
0
        public static bool _OnDealDamage_Prefix(BaseEnchantment __instance, string ____displayName, Monster monster, GameLocation location, Farmer who, ref int amount)
        {
            if (!(__instance is BaseWeaponEnchantment) || ____displayName == null || ____displayName == "" || !ModEntry.advancedEnchantments.ContainsKey(____displayName) || (ModEntry.EnchantmentTriggers.ContainsKey(who.uniqueMultiplayerID + ____displayName) && ModEntry.EnchantmentTriggers[who.uniqueMultiplayerID + ____displayName] == Game1.ticks))
            {
                return(true);
            }
            AdvancedEnchantmentData enchantment = ModEntry.advancedEnchantments[____displayName];

            if (enchantment?.parameters?.ContainsKey("trigger") != true)
            {
                return(true);
            }

            if (enchantment.parameters["trigger"] == "damage" || (enchantment.parameters["trigger"] == "crit" && amount > (who.CurrentTool as MeleeWeapon).maxDamage) && !Environment.StackTrace.Contains("OnCalculateDamage"))
            {
                context.Monitor.Log($"Triggered enchantment {enchantment.name} on {enchantment.parameters["trigger"]} {amount} {(who.CurrentTool as MeleeWeapon).enchantments.Count}");
                ModEntry.EnchantmentTriggers[who.uniqueMultiplayerID + ____displayName] = Game1.ticks;
                if (enchantment.type == "heal")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        int heal = Math.Max(1, (int)(amount * float.Parse(enchantment.parameters["amountMult"])));
                        who.health = Math.Min(who.maxHealth, Game1.player.health + heal);
                        location.debris.Add(new Debris(heal, new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY()), Color.Lime, 1f, who));
                        if (enchantment.parameters.ContainsKey("sound"))
                        {
                            Game1.playSound(enchantment.parameters["sound"]);
                        }
                    }
                }
                else if (enchantment.type == "coins")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        float mult  = float.Parse(enchantment.parameters["amountMult"]);
                        int   coins = (int)Math.Round(mult * amount);
                        who.Money += coins;
                        if (enchantment.parameters.ContainsKey("sound"))
                        {
                            Game1.playSound(enchantment.parameters["sound"]);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #8
0
 /// <summary>
 /// Function that substitutes in an enchantment.
 /// </summary>
 /// <param name="base_item">Tool.</param>
 /// <param name="item">Thing to enchant with.</param>
 /// <returns>Enchanment to substitute in.</returns>
 public static BaseEnchantment SubstituteEnchantment(Item base_item, Item item)
 {
     try
     {
         if (Utility.IsNormalObjectAtParentSheetIndex(item, 74) && ForgeMenuPatches.CurrentSelection is not null)
         {
             BaseEnchantment output = ForgeMenuPatches.CurrentSelection;
             ForgeMenuPatches.TrashMenu();
             return(output);
         }
     }
     catch (Exception ex)
     {
         ModEntry.ModMonitor.Log($"Failed in forcing selection of enchantment.\n\n{ex}", LogLevel.Error);
     }
     return(BaseEnchantment.GetEnchantmentFromItem(base_item, item));
 }
コード例 #9
0
        public EnchantMenu() : base(
                (Game1.uiViewport.Width - 800) / 2,
                (Game1.uiViewport.Height - 600) / 2,
                800,
                600,
                true
                )
        {
            enchantments = BaseEnchantment.GetAvailableEnchantments().ToArray();
            incompatible = new bool[enchantments.Length];
            inventory    = new InventoryMenu(0, 0, false);
            int buttonHeight = (height - 32 - inventory.height) / buttons.Length;

            for (int i = 0; i < buttons.Length; i++)
            {
                buttons[i] = new Rectangle(0, 0, width - 32, buttonHeight);
            }
            maxOffset = enchantments.Length - buttons.Length;
            upArrow   = new ClickableTextureComponent(
                new Rectangle(0, 0, 44, 48),
                Game1.mouseCursors,
                new Rectangle(421, 459, 11, 12),
                4f
                );
            downArrow = new ClickableTextureComponent(
                new Rectangle(0, 0, 44, 48),
                Game1.mouseCursors,
                new Rectangle(421, 472, 11, 12),
                4f
                );
            scrollBar = new ClickableTextureComponent(
                new Rectangle(0, 0, 24, 40),
                Game1.mouseCursors,
                new Rectangle(435, 463, 6, 10),
                4f
                );
            scrollBarTrack = new Rectangle(
                0,
                0,
                scrollBar.bounds.Width,
                height - inventory.height - 140
                );
            UpdateSelected();
            PlaceWidgets();
        }
コード例 #10
0
 public static bool IsEnchantedOrEnchantable(Item item)
 {
     if (item != null && item is Tool)
     {
         foreach (BaseEnchantment enchantment in (item as Tool).enchantments)
         {
             if (!enchantment.IsForge() && !enchantment.IsSecondaryEnchantment())
             {
                 return(true);
             }
         }
         if (BaseEnchantment.GetAvailableEnchantmentsForItem(item as Tool).Count > 0)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #11
0
        // Lists the next several enchantments to be applied to the given tool,
        // up to the given limit.
        public static List <Prediction> ListForTool(Tool tool, uint limit,
                                                    bool cumulative = false)
        {
            Utilities.CheckWorldReady();
            if (!IsAvailable)
            {
                throw new UnavailableException("enchantments");
            }

            List <Prediction> predictions = new ();
            Tool fakeTool = tool.getOne() as Tool;

            // Start from the next enchantment and continue to the limit.
            uint fromNumber = Game1.stats.getStat("timesEnchanted");

            for (uint number = fromNumber; number < fromNumber + limit; ++number)
            {
                // Select a random available enchantment per the base game rules.
                Random rng         = new ((int)number + (int)Game1.uniqueIDForThisGame);
                var    candidates  = BaseEnchantment.GetAvailableEnchantmentsForItem(fakeTool);
                var    enchantment = Utility.GetRandom(candidates, rng);

                predictions.Add(new ()
                {
                    number      = number,
                    enchantment = enchantment,
                });

                // If the enchantments are cumulative on the tool itself,
                // simulate applying this enchantment to be ready for the next.
                if (cumulative && enchantment != null)
                {
                    fakeTool.AddEnchantment(enchantment);
                    fakeTool.previousEnchantments.Insert(0, enchantment.GetName());
                    while (fakeTool.previousEnchantments.Count > 2)
                    {
                        fakeTool.previousEnchantments.RemoveAt(fakeTool.previousEnchantments.Count - 1);
                    }
                }
            }

            return(predictions);
        }
コード例 #12
0
ファイル: Patcher.cs プロジェクト: Pathoschild/smapi-mod-dump
        public static void Forge_Post(MeleeWeapon __instance, Item item, bool count_towards_stats, ref bool __result)
        {
            try
            {
                if (!mod.Config.EnchantableScythes || !__instance.isScythe(-1))
                {
                    return;
                }

                if (item is MeleeWeapon other_weapon && other_weapon.type == __instance.type)
                {
                    __instance.appearance.Value = (__instance.IndexOfMenuItemView = other_weapon.getDrawnItemIndex());
                    __result = true;
                    return;
                }

                BaseEnchantment enchantment = BaseEnchantment.GetEnchantmentFromItem(__instance, item);
                if (enchantment != null && __instance.AddEnchantment(enchantment))
                {
                    // deleted diamond case

                    if (count_towards_stats && !enchantment.IsForge())
                    {
                        __instance.previousEnchantments.Insert(0, enchantment.GetName());
                        while (__instance.previousEnchantments.Count > 2)
                        {
                            __instance.previousEnchantments.RemoveAt(__instance.previousEnchantments.Count - 1);
                        }
                        Game1.stats.incrementStat("timesEnchanted", 1);
                    }

                    __result = true;
                    return;
                }

                __result = false;
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }
コード例 #13
0
 public static bool CanAddEnchantment_Prefix(Tool __instance, BaseEnchantment enchantment, ref bool __result)
 {
     try
     {
         if (enchantment == null)
         {
             return(true); // run original logic
         }
         if (__instance is MeleeWeapon && enchantment.IsForge())
         {
             if (enchantment is DiamondEnchantment && GetValidForgeEnchantmentsForTool(__instance).Count <= 0)
             {
                 // No more forge enchantments can be added.
                 __result = false;
                 return(false);
             }
             // Enchantment is a normal forge enchantment, check the existing level if there is one
             foreach (BaseEnchantment exisiting_enchantment in __instance.enchantments)
             {
                 if (enchantment.GetType() == exisiting_enchantment.GetType())
                 {
                     if (exisiting_enchantment.GetLevel() >= 3)
                     {
                         __result = false;
                         return(false);
                     }
                     break;
                 }
             }
             __result = true;
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         ModMonitor.Log($"Failed in {nameof(CanAddEnchantment_Prefix)}:\n{ex}", LogLevel.Error);
         return(true); // run original logic
     }
 }
コード例 #14
0
        public static void Forge_Postfix(Tool __instance, ref bool __result, Item item, bool count_towards_stats = false)
        {
            BaseEnchantment enchantment = BaseEnchantment.GetEnchantmentFromItem(__instance, item);

            if (__instance is Slingshot && enchantment != null)
            {
                if (enchantment is GalaxySoulEnchantment && __instance is Slingshot sling && sling.CurrentParentTileIndex == 34 && sling.GetEnchantmentLevel <GalaxySoulEnchantment>() >= 3)
                {
                    __instance.CurrentParentTileIndex = ModEntry.Instance.config.InfinitySlingshotId;
                    __instance.InitialParentTileIndex = ModEntry.Instance.config.InfinitySlingshotId;
                    __instance.IndexOfMenuItemView    = ModEntry.Instance.config.InfinitySlingshotId;
                    string[] slingData = Game1.content.Load <Dictionary <int, string> >("Data\\weapons")[__instance.InitialParentTileIndex].Split('/');
                    __instance.BaseName    = slingData[0];
                    __instance.description = slingData[1];

                    GalaxySoulEnchantment enchant = __instance.GetEnchantmentOfType <GalaxySoulEnchantment>();
                    if (enchant != null)
                    {
                        __instance.RemoveEnchantment(enchant);
                    }
                }
                if (count_towards_stats && !enchantment.IsForge())
                {
                    __instance.previousEnchantments.Insert(0, enchantment.GetName());
                    while (__instance.previousEnchantments.Count > 2)
                    {
                        __instance.previousEnchantments.RemoveAt(__instance.previousEnchantments.Count - 1);
                    }
                    Game1.stats.incrementStat("timesEnchanted", 1);
                }
                __result = true;
                return;
            }
            __result = false;
            return;
        }
コード例 #15
0
        public static bool _OnMonsterSlay_Prefix(BaseEnchantment __instance, string ____displayName, Monster m, GameLocation location, Farmer who)
        {
            if (!(__instance is BaseWeaponEnchantment) || ____displayName == null || !ModEntry.advancedEnchantments.ContainsKey(____displayName) || (ModEntry.EnchantmentTriggers.ContainsKey(who.uniqueMultiplayerID + ____displayName) && ModEntry.EnchantmentTriggers[who.uniqueMultiplayerID + ____displayName] == Game1.ticks))
            {
                return(true);
            }
            AdvancedEnchantmentData enchantment = ModEntry.advancedEnchantments[____displayName];

            if (enchantment.parameters["trigger"] == "slay")
            {
                context.Monitor.Log($"Triggered enchantment {enchantment.name} on slay");
                ModEntry.EnchantmentTriggers[who.uniqueMultiplayerID + ____displayName] = Game1.ticks;
                if (enchantment.type == "heal")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        int heal = Math.Max(1, (int)(m.Health * float.Parse(enchantment.parameters["amountMult"])));
                        who.health = Math.Min(who.maxHealth, Game1.player.health + heal);
                        location.debris.Add(new Debris(heal, new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY()), Color.Lime, 1f, who));
                        if (enchantment.parameters.ContainsKey("sound"))
                        {
                            Game1.playSound(enchantment.parameters["sound"]);
                        }
                    }
                }
                else if (enchantment.type == "loot")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        if (enchantment.parameters.ContainsKey("extraDropChecks"))
                        {
                            int extraChecks = Math.Max(1, int.Parse(enchantment.parameters["extraDropChecks"]));
                            for (int i = 0; i < extraChecks; i++)
                            {
                                location.monsterDrop(m, m.GetBoundingBox().Center.X, m.GetBoundingBox().Center.Y, who);
                            }
                        }
                        else if (enchantment.parameters.ContainsKey("extraDropItems"))
                        {
                            string[] items = enchantment.parameters["extraDropItems"].Split(',');
                            foreach (string item in items)
                            {
                                string[] ic = item.Split('_');
                                if (ic.Length == 1)
                                {
                                    Game1.createItemDebris(new Object(int.Parse(item), 1, false, -1, 0), m.Position, Game1.random.Next(4), m.currentLocation, -1);
                                }
                                else if (ic.Length == 2)
                                {
                                    float chance = int.Parse(ic[1]) / 100f;
                                    if (Game1.random.NextDouble() < chance)
                                    {
                                        Game1.createItemDebris(new Object(int.Parse(ic[0]), 1, false, -1, 0), m.Position, Game1.random.Next(4), m.currentLocation, -1);
                                    }
                                }
                                else if (ic.Length == 4)
                                {
                                    float chance = int.Parse(ic[3]) / 100f;
                                    if (Game1.random.NextDouble() < chance)
                                    {
                                        Game1.createItemDebris(new Object(int.Parse(ic[0]), Game1.random.Next(int.Parse(ic[1]), int.Parse(ic[2]))), m.Position, Game1.random.Next(4), m.currentLocation, -1);
                                    }
                                }
                            }
                        }
                        if (enchantment.parameters.ContainsKey("sound"))
                        {
                            Game1.playSound(enchantment.parameters["sound"]);
                        }
                    }
                }
                else if (enchantment.type == "coins")
                {
                    if (Game1.random.NextDouble() < float.Parse(enchantment.parameters["chance"]) / 100f)
                    {
                        float mult   = float.Parse(enchantment.parameters["amountMult"]);
                        int   amount = (int)Math.Round(mult * m.maxHealth);
                        who.Money += amount;
                        if (enchantment.parameters.ContainsKey("sound"))
                        {
                            Game1.playSound(enchantment.parameters["sound"]);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #16
0
        public static bool Forge_Prefix(Tool __instance, Item item, ref bool __result)
        {
            try
            {
                BaseEnchantment enchantment = BaseEnchantment.GetEnchantmentFromItem(__instance, item);
                // This gets displayed twice because the game does it once to display the "Result" item in the menu.
                ModMonitor.Log($"Adding {(enchantment != null ? (enchantment.IsForge() ? "forge enchantment" : enchantment.GetDisplayName()) : "null enchantment")} from item {(item != null ? item.Name : "null")} to tool {__instance.Name}", LogLevel.Debug);
                if (enchantment != null && enchantment is DiamondEnchantment)
                {
                    // Diamond Enchantment is now replaced with up to 3 other random enchantments. Still get a slight discount on the cost.
                    if (GetValidForgeEnchantmentsForTool(__instance).Count <= 0)
                    {
                        __result = false;
                        return(false);
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        // Try to add 3 new enchantments.
                        List <int> valid_forges = GetValidForgeEnchantmentsForTool(__instance);
                        if (valid_forges.Count <= 0)
                        {
                            // Can't add enchantments
                            break;
                        }
                        int index          = Game1.random.Next(valid_forges.Count);
                        int random_enchant = valid_forges[index];
                        switch (random_enchant)
                        {
                        case 0:
                            ModMonitor.Log($"Adding Emerald Enchantment as part of Diamond Enchantment process", LogLevel.Trace);
                            __instance.AddEnchantment(new EmeraldEnchantment());
                            break;

                        case 1:
                            ModMonitor.Log($"Adding Emerald Aquamarine as part of Diamond Enchantment process", LogLevel.Trace);
                            __instance.AddEnchantment(new AquamarineEnchantment());
                            break;

                        case 2:
                            ModMonitor.Log($"Adding Ruby Enchantment as part of Diamond Enchantment process", LogLevel.Trace);
                            __instance.AddEnchantment(new RubyEnchantment());
                            break;

                        case 3:
                            ModMonitor.Log($"Adding Amethyst Enchantment as part of Diamond Enchantment process", LogLevel.Trace);
                            __instance.AddEnchantment(new AmethystEnchantment());
                            break;

                        case 4:
                            ModMonitor.Log($"Adding Topaz Enchantment as part of Diamond Enchantment process", LogLevel.Trace);
                            __instance.AddEnchantment(new TopazEnchantment());
                            break;

                        case 5:
                            ModMonitor.Log($"Adding Jade Enchantment as part of Diamond Enchantment process", LogLevel.Trace);
                            __instance.AddEnchantment(new JadeEnchantment());
                            break;
                        }
                    }
                    __result = true;
                    return(false); // don't run original logic
                }
                return(true);      // run original logic
            }
            catch (Exception ex)
            {
                ModMonitor.Log($"Failed in {nameof(Forge_Prefix)}:\n{ex}", LogLevel.Error);
                return(true); // run original logic
            }
        }
コード例 #17
0
 public BaseEnchantmentWrapper(BaseEnchantment item) => GetBaseType = item;
コード例 #18
0
 public override bool CanAddEnchantment(BaseEnchantment enchantment)
 {
     return(false);
 }
コード例 #19
0
        public static void AddEnchantment_Postfix(Tool __instance, ref bool __result, BaseEnchantment enchantment)
        {
            if (enchantment != null && __instance is Slingshot && enchantment.IsSecondaryEnchantment())
            {
                var lastUser = AccessTools.FieldRefAccess <Tool, Farmer>("lastUser");

                //__instance.RemoveEnchantment(enchantment);
                __instance.enchantments.Remove(enchantment);
                enchantment.UnapplyTo(__instance, lastUser(__instance));

                foreach (BaseEnchantment existing_enchantment in __instance.enchantments)
                {
                    if (enchantment.GetType() == existing_enchantment.GetType())
                    {
                        if (existing_enchantment.GetMaximumLevel() < 0 || existing_enchantment.GetLevel() < existing_enchantment.GetMaximumLevel())
                        {
                            existing_enchantment.SetLevel(__instance, existing_enchantment.GetLevel() + 1);
                            __result = true;
                            return;
                        }
                        __result = false;
                        return;
                    }
                }
                __instance.enchantments.Add(enchantment);
                enchantment.ApplyTo(__instance, lastUser(__instance));
                __result = true;
                return;
            }
        }
コード例 #20
0
ファイル: Patcher.cs プロジェクト: Pathoschild/smapi-mod-dump
        public static void GetEnchantmentFromItem_Post(Item base_item, Item item, ref BaseEnchantment __result)
        {
            try
            {
                if (!mod.Config.EnchantableScythes)
                {
                    return;
                }

                if (base_item is MeleeWeapon weapon && weapon.isScythe(-1))
                {
                    // actual enchantments
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 74))
                    {
                        var enchantmentRandom = new Random((int)(Game1.stats.getStat("timesEnchanted") + (uint)((int)Game1.uniqueIDForThisGame)));
                        __result = Utility.GetRandom(BaseEnchantment.GetAvailableEnchantmentsForItem(base_item as Tool), enchantmentRandom);
                        return;
                    }

                    // weapon forging
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 60))
                    {
                        __result = new EmeraldEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 62))
                    {
                        __result = new AquamarineEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 64))
                    {
                        __result = new RubyEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 66))
                    {
                        __result = new AmethystEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 68))
                    {
                        __result = new TopazEnchantment();
                        return;
                    }
                    if (Utility.IsNormalObjectAtParentSheetIndex(item, 70))
                    {
                        __result = new JadeEnchantment();
                        return;
                    }

                    // deleted diamond case

                    __result = null;
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }