From 18a7dc5d23d8cd324010c279faf25ae531a7aba9 Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Sat, 13 Aug 2022 14:21:22 +0530 Subject: [PATCH] Issue#33 Fixed rings bug in crafting page --- stardew-access/Patches/GameMenuPatches.cs | 59 ++++++++++++----------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/stardew-access/Patches/GameMenuPatches.cs b/stardew-access/Patches/GameMenuPatches.cs index 228dded..97ce43a 100644 --- a/stardew-access/Patches/GameMenuPatches.cs +++ b/stardew-access/Patches/GameMenuPatches.cs @@ -773,43 +773,44 @@ namespace stardew_access.Patches #region Health & stamina and buff items (effects like +1 walking speed) Item producesItem = ___hoverRecipe.createItem(); - StardewValley.Object? producesItemObject = ((StardewValley.Object)producesItem); - - if (producesItem is StardewValley.Object && producesItemObject.Edibility != -300) + if (producesItem is StardewValley.Object producesItemObject) { - int stamina_recovery = producesItemObject.staminaRecoveredOnConsumption(); - buffs += $"{stamina_recovery} Energy"; - if (stamina_recovery >= 0) + if (producesItemObject.Edibility != -300) { - int health_recovery = producesItemObject.healthRecoveredOnConsumption(); - buffs += $"\n{health_recovery} Health"; + int stamina_recovery = producesItemObject.staminaRecoveredOnConsumption(); + buffs += $"{stamina_recovery} Energy"; + if (stamina_recovery >= 0) + { + int health_recovery = producesItemObject.healthRecoveredOnConsumption(); + buffs += $"\n{health_recovery} Health"; + } } - } - // These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line) - bool edibleItem = producesItem != null && producesItem is StardewValley.Object && (int)producesItemObject.Edibility != -300; - string[]? buffIconsToDisplay = (producesItem != null && edibleItem && Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/').Length > 7) - ? producesItem.ModifyItemBuffs(Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/')[7].Split(' ')) - : null; + // These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line) + bool edibleItem = producesItem != null && (int)producesItemObject.Edibility != -300; + string[]? buffIconsToDisplay = (producesItem != null && edibleItem && Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/').Length > 7) + ? producesItem.ModifyItemBuffs(Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/')[7].Split(' ')) + : null; - if (buffIconsToDisplay != null) - { - for (int j = 0; j < buffIconsToDisplay.Length; j++) + if (buffIconsToDisplay != null) { - string buffName = ((Convert.ToInt32(buffIconsToDisplay[j]) > 0) ? "+" : "") + buffIconsToDisplay[j] + " "; - if (j <= 11) + for (int j = 0; j < buffIconsToDisplay.Length; j++) { - buffName = Game1.content.LoadString("Strings\\UI:ItemHover_Buff" + j, buffName); + string buffName = ((Convert.ToInt32(buffIconsToDisplay[j]) > 0) ? "+" : "") + buffIconsToDisplay[j] + " "; + if (j <= 11) + { + buffName = Game1.content.LoadString("Strings\\UI:ItemHover_Buff" + j, buffName); + } + try + { + int count = int.Parse(buffName.Substring(0, buffName.IndexOf(' '))); + if (count != 0) + buffs += $"{buffName}\n"; + } + catch (Exception) { } } - try - { - int count = int.Parse(buffName.Substring(0, buffName.IndexOf(' '))); - if (count != 0) - buffs += $"{buffName}\n"; - } - catch (Exception) { } - } - buffs = $"Buffs and boosts:\n {buffs}"; + buffs = $"Buffs and boosts:\n {buffs}"; + } } #endregion