Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of KnifeSpawner v1.0.1
KnifeSpawner.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("KnifeSpawner")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("KnifeSpawner")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("82ae3210-1d5e-4c09-b9db-8ec6a562b7bd")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("com.goofytheboy.knifespawner", "KnifeSpawner", "1.0.0")] public class KnifeSpawnerMod : BaseUnityPlugin { private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) new Harmony("com.goofytheboy.knifespawner").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"KnifeSpawner by Goofytheboy loaded!"); } } public class KnifeSpawnHandler : MonoBehaviour { private Component playerComponent; private void Start() { playerComponent = ((IEnumerable<Component>)((Component)this).GetComponents<Component>()).FirstOrDefault((Func<Component, bool>)((Component c) => ((object)c).GetType().Name == "PlayerControllerB")); } private void Update() { if (!((Object)(object)playerComponent == (Object)null)) { PropertyInfo property = ((object)playerComponent).GetType().GetProperty("IsOwner", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); bool flag = false; if (property != null && property.GetValue(playerComponent) is bool flag2) { flag = flag2; } if (flag && Keyboard.current != null && ((ButtonControl)Keyboard.current.kKey).wasPressedThisFrame) { SpawnKnifeForMe(); } } } private void SpawnKnifeForMe() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) List<Item> list = StartOfRound.Instance?.allItemsList?.itemsList; if (list == null) { return; } Item val = ((IEnumerable<Item>)list).FirstOrDefault((Func<Item, bool>)((Item i) => i.itemName.ToLower().Contains("knife"))); if ((Object)(object)val == (Object)null) { Debug.Log((object)"[KnifeSpawner] Knife not found in item list!"); return; } Component obj = playerComponent; Vector3? obj2; if (obj == null) { obj2 = null; } else { Transform transform = obj.transform; obj2 = ((transform != null) ? new Vector3?(transform.position) : null); } Vector3 val2 = (Vector3)(((??)obj2) ?? ((Component)this).transform.position); GameObject val3 = Object.Instantiate<GameObject>(val.spawnPrefab, val2, Quaternion.identity); NetworkObject component = val3.GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null) { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsServer) { try { component.Spawn(false); } catch { } } } Debug.Log((object)"[KnifeSpawner] Knife spawned!"); } } [HarmonyPatch] internal class PatchPlayerStart { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("PlayerControllerB"); if (type == null) { return null; } return type.GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } private static void Postfix(object __instance) { Component val = (Component)((__instance is Component) ? __instance : null); if ((Object)(object)val != (Object)null) { val.gameObject.AddComponent<KnifeSpawnHandler>(); } } }