Decompiled source of InfiniteToolDurability OMS v1.0.0

BepInEx/plugins/InfiniteToolDurability.dll

Decompiled 7 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("InfiniteToolDurability")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InfiniteToolDurability")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cb16d021-8ec0-4aaf-b58f-fc0d6fb6518a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("OldMarket.InfiniteToolDurability", "Old Market Infinite Tool Durability", "1.0.0")]
public sealed class InfiniteToolDurabilityPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(PlayerInventory), "ReduceCurrentItemAmount")]
	private static class Patch_PlayerInventory_ReduceCurrentItemAmount
	{
		private static bool Prefix(PlayerInventory __instance)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return true;
				}
				InventorySlot currentInventorySlot = __instance.GetCurrentInventorySlot();
				if (currentInventorySlot.itemId == -1)
				{
					return true;
				}
				GameManager instance = GameManager.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return true;
				}
				ItemSO itemById = instance.GetItemById(currentInventorySlot.itemId);
				if ((Object)(object)((itemById is ToolSO) ? itemById : null) != (Object)null)
				{
					return false;
				}
				return true;
			}
			catch
			{
				return true;
			}
		}
	}

	public const string PluginGuid = "OldMarket.InfiniteToolDurability";

	public const string PluginName = "Old Market Infinite Tool Durability";

	public const string PluginVersion = "1.0.0";

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("OldMarket.InfiniteToolDurability").PatchAll(typeof(Patch_PlayerInventory_ReduceCurrentItemAmount));
	}
}