Skip to content

Commit

Permalink
fix wrong max health value for iron axe
Browse files Browse the repository at this point in the history
  • Loading branch information
sp00ktober committed Jul 4, 2022
1 parent 61cae92 commit f8070a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ For support or to discuss any other modding related topic you can join our [Star

## Changelog

0.0.3:

- fix wrong durability value for iron axe

0.0.2:

- also include metal tools
Expand Down
16 changes: 3 additions & 13 deletions ShowDurability/Patches/Dynamic/Slot_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ namespace ShowDurability.Patches.Dynamic
class Slot_Patch
{
static float MAX_HEALTH_WOOD = 300f;
static float MAX_HEALTH_IRON_PICKAXE = 600f;
static float MAX_HEALTH_IRON_AXE = 540f;
static float MAX_HEALTH_IRON = 600f;

[HarmonyPostfix]
[HarmonyPatch(typeof(Slot), "Refresh")]
Expand All @@ -24,21 +23,12 @@ public static void Refresh_Postfix(Slot __instance)

__instance.Refreshed.Send(__instance);
}
else if (__instance?.CurrentItem?.Name == "METAL PICKAXE")
else if (__instance?.CurrentItem?.Name == "METAL PICKAXE" || __instance?.CurrentItem?.Name == "METAL AX")
{
DurabilityBar bar = (DurabilityBar)AccessTools.Field(typeof(Slot), "m_DurabilityBar").GetValue(__instance);
bar.SetActive(true);

bar.SetFillAmount(__instance.CurrentItem.GetPropertyValue("Durability").Float.Current / MAX_HEALTH_IRON_PICKAXE);

__instance.Refreshed.Send(__instance);
}
else if(__instance?.CurrentItem?.Name == "METAL AX")
{
DurabilityBar bar = (DurabilityBar)AccessTools.Field(typeof(Slot), "m_DurabilityBar").GetValue(__instance);
bar.SetActive(true);

bar.SetFillAmount(__instance.CurrentItem.GetPropertyValue("Durability").Float.Current / MAX_HEALTH_IRON_AXE);
bar.SetFillAmount(__instance.CurrentItem.GetPropertyValue("Durability").Float.Current / MAX_HEALTH_IRON);

__instance.Refreshed.Send(__instance);
}
Expand Down
4 changes: 2 additions & 2 deletions ShowDurability/ShowDurability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace ShowDurability
{
[BepInPlugin("com.sp00ktober.ShowDurability", "ShowDurability", "0.0.2")]
[BepInPlugin("com.sp00ktober.ShowDurability", "ShowDurability", "0.0.3")]
public class ShowDurability : BaseUnityPlugin
{
private void Awake()
Expand All @@ -20,7 +20,7 @@ private static void InitPatches()

try
{
Debug.Log("Applying patches from ShowDurability 0.0.2");
Debug.Log("Applying patches from ShowDurability 0.0.3");

Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.sp00ktober.de");

Expand Down
2 changes: 1 addition & 1 deletion ShowDurability/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ShowDurability",
"description": "BepInEx mod for Starsand to show the durability of some tools which have it normally hidden.",
"version_number": "0.0.2",
"version_number": "0.0.3",
"dependencies": [
"BepInEx-BepInExPack_Starsand-5.4.16"
],
Expand Down

0 comments on commit f8070a7

Please sign in to comment.