Issue#33 Fixed rings bug in crafting page

master
Mohammad Shoaib Khan 2022-08-13 14:21:22 +05:30
parent 408a40121d
commit 18a7dc5d23
1 changed files with 30 additions and 29 deletions

View File

@ -773,43 +773,44 @@ namespace stardew_access.Patches
#region Health & stamina and buff items (effects like +1 walking speed) #region Health & stamina and buff items (effects like +1 walking speed)
Item producesItem = ___hoverRecipe.createItem(); Item producesItem = ___hoverRecipe.createItem();
StardewValley.Object? producesItemObject = ((StardewValley.Object)producesItem); if (producesItem is StardewValley.Object producesItemObject)
if (producesItem is StardewValley.Object && producesItemObject.Edibility != -300)
{ {
int stamina_recovery = producesItemObject.staminaRecoveredOnConsumption(); if (producesItemObject.Edibility != -300)
buffs += $"{stamina_recovery} Energy";
if (stamina_recovery >= 0)
{ {
int health_recovery = producesItemObject.healthRecoveredOnConsumption(); int stamina_recovery = producesItemObject.staminaRecoveredOnConsumption();
buffs += $"\n{health_recovery} Health"; 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)
// These variables are taken from the game's code itself (IClickableMenu.cs -> 1016 line) bool edibleItem = producesItem != null && (int)producesItemObject.Edibility != -300;
bool edibleItem = producesItem != null && producesItem is StardewValley.Object && (int)producesItemObject.Edibility != -300; string[]? buffIconsToDisplay = (producesItem != null && edibleItem && Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/').Length > 7)
string[]? buffIconsToDisplay = (producesItem != null && edibleItem && Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/').Length > 7) ? producesItem.ModifyItemBuffs(Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/')[7].Split(' '))
? producesItem.ModifyItemBuffs(Game1.objectInformation[producesItemObject.ParentSheetIndex].Split('/')[7].Split(' ')) : null;
: null;
if (buffIconsToDisplay != null) if (buffIconsToDisplay != null)
{
for (int j = 0; j < buffIconsToDisplay.Length; j++)
{ {
string buffName = ((Convert.ToInt32(buffIconsToDisplay[j]) > 0) ? "+" : "") + buffIconsToDisplay[j] + " "; for (int j = 0; j < buffIconsToDisplay.Length; j++)
if (j <= 11)
{ {
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 #endregion