//sets up the basic structure of either transmute event, since they have some common ground private static void HandleEitherTransmuteEvent(string keyPressed) { // save is loaded if (Context.IsWorldReady) { //per the advice of Ento, abort if the player is in an event if (Game1.CurrentEvent != null) { return; } //something may have gone wrong if this is null, maybe there's no save data? if (Game1.player != null) { //get the player's current item Item heldItem = Game1.player.CurrentItem; //player is holding item if (heldItem != null) { //get the item's ID int heldItemID = heldItem.parentSheetIndex; //abort any transmutation event for blacklisted items or items that for whatever reason can't exist in world. if (blackListedItemIDs.Contains(heldItemID) || !heldItem.canBeDropped()) { return; } //get the transmutation value, it's based on what it's worth to the player, including profession bonuses. This affects both cost and value. int actualValue = ((StardewValley.Object)heldItem).sellToStorePrice(); //try to transmute [copy] the item if (keyPressed.ToString() == instance.Config.TransmuteKey) { Alchemy.HandleTransmuteEvent(heldItem, actualValue); } //try to liquidate the item [sell for gold] if (keyPressed.ToString() == instance.Config.LiquidateKey) { Alchemy.HandleLiquidateEvent(heldItem, actualValue); } //try to normalize the item [make all items of a different quality one quality and exchange any remainder for gold] if (keyPressed.ToString() == instance.Config.NormalizeKey) { Alchemy.HandleNormalizeEvent(heldItem, actualValue); } } } } }