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 JetpackHandling v1.0.3
BepInEx/plugins/JetpackHandling.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using JetpackHandling.Patches; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("JetpackHandling")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("JetpackHandling")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7cd580c7-049b-47dd-ae19-29c989a65cf4")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace JetpackHandling { [BepInPlugin("Invertigo.JetpackHandling", "JetpackHandling", "1.0.2.0")] public class Plugin : BaseUnityPlugin { private const string ModGUID = "Invertigo.JetpackHandling"; private const string ModName = "JetpackHandling"; private const string ModVersion = "1.0.2.0"; private readonly Harmony harmony = new Harmony("Invertigo.JetpackHandling"); private static Plugin Instance; private void Awake() { ManualLogSource val = Logger.CreateLogSource("Invertigo.JetpackHandling"); val.LogInfo((object)"Plugin Invertigo.JetpackHandling is loaded!"); if ((Object)(object)Instance == (Object)null) { Instance = this; } harmony.PatchAll(typeof(PlayerControllerBPatch)); harmony.PatchAll(typeof(JetpackItemPatch)); harmony.PatchAll(typeof(PlayerControllerBPatch2)); } } } namespace JetpackHandling.Patches { [HarmonyPatch(typeof(JetpackItem), "Update")] internal class JetpackItemPatch { public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown Type typeFromHandle = typeof(PlayerControllerB); MethodInfo method = typeFromHandle.GetMethod("KillPlayer"); ManualLogSource val = new ManualLogSource("jetpackupdate"); Logger.Sources.Add((ILogSource)(object)val); List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Callvirt && CodeInstructionExtensions.Calls(list[i], method)) { val.LogInfo((object)(i + "-found opcode: " + list[i].opcode)); for (int j = 0; j < 8; j++) { list[i - j].opcode = OpCodes.Nop; } } } return list; } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch2 { [HarmonyPatch("Update")] [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Patchkillspeed(IEnumerable<CodeInstruction> instructions) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Type typeFromHandle = typeof(PlayerControllerB); MethodInfo method = typeFromHandle.GetMethod("DamagePlayer"); FieldInfo field = typeFromHandle.GetField("fallValue"); ManualLogSource val = new ManualLogSource("jetpack transpiler"); Logger.Sources.Add((ILogSource)(object)val); val.LogInfo((object)"did i get to opcode"); List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Call && CodeInstructionExtensions.Calls(list[i], method)) { val.LogInfo((object)(i + "-found opcode damage: " + list[i].opcode)); val.LogInfo((object)(i - 2 + "- previous 2 call: " + list[i - 2].opcode.ToString() + " operand: " + list[i - 2].operand.ToString())); if (list[i - 2].opcode == OpCodes.Ldc_R4 && list[i - 2].operand.ToString() == "50") { val.LogInfo((object)(i + "replacing opcode: " + list[i].opcode)); for (int j = 0; j < 15; j++) { list[i - j].opcode = OpCodes.Nop; } } } if (list[i].opcode == OpCodes.Stfld && list[i].operand.ToString() == "System.Single fallValue" && list[i - 4].opcode == OpCodes.Ldc_R4 && list[i - 4].operand.ToString() == "-150") { val.LogInfo((object)(i + "-found fall opcode: " + list[i].opcode.ToString() + "operand: " + list[i].operand.ToString())); val.LogInfo((object)(i - 4 + "- previous fall call: " + list[i - 4].opcode.ToString() + list[i - 4].operand.ToString())); for (int k = 0; k < 12; k++) { list[i - k].opcode = OpCodes.Nop; } } if (list[i].opcode == OpCodes.Stfld && list[i].operand.ToString() == "System.Single fallValue" && list[i - 4].opcode == OpCodes.Ldc_R4 && list[i - 4].operand.ToString() == "7") { val.LogInfo((object)(i + "-found fall2 opcode: " + list[i].opcode.ToString() + "operand: " + list[i].operand.ToString())); val.LogInfo((object)(i - 4 + "- previous fall2 call: " + list[i - 4].opcode.ToString() + list[i - 4].operand.ToString())); for (int l = 0; l < 9; l++) { list[i - l].opcode = OpCodes.Nop; } } if (list[i].opcode == OpCodes.Stfld && list[i].operand.ToString() == "System.Single fallValue" && list[i - 1].opcode == OpCodes.Ldc_R4 && list[i - 1].operand.ToString() == "-7") { val.LogInfo((object)(i + "-found fall3 opcode: " + list[i].opcode.ToString() + "operand: " + list[i].operand.ToString())); val.LogInfo((object)(i - 1 + "- previous fall3 call: " + list[i - 1].opcode.ToString() + list[i - 1].operand.ToString())); for (int m = 0; m < 3; m++) { list[i - m].opcode = OpCodes.Nop; } } } return list; } } [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void JetpackHandlingPatch(PlayerControllerB __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) ManualLogSource val = new ManualLogSource("jetpackhandlingsource"); Logger.Sources.Add((ILogSource)(object)val); float num = 0f; bool flag = false; bool flag2 = true; bool flag3 = false; if ((!__instance.inSpecialInteractAnimation || __instance.inShockingMinigame) && (Object)(object)__instance.currentlyHeldObjectServer != (Object)null && __instance.currentlyHeldObjectServer.itemProperties.itemName == "Jetpack") { if (__instance.jetpackControls && !__instance.disablingJetpackControls) { flag3 = true; flag2 = false; } else { flag = true; flag2 = false; } } __instance.takingFallDamage = false; if (flag) { num = ((!(__instance.fallValue > 2f)) ? 1f : (__instance.fallValue * 0.5f)); __instance.fallValue = Mathf.MoveTowards(__instance.fallValue, -12f, 7f * Time.deltaTime * num); __instance.fallValueUncapped = 0f; } else if (flag2) { if ((double)__instance.health > 25.0 && __instance.fallValue < -30f && __instance.thisController.isGrounded) { val.LogInfo((object)"taking damage from fall"); val.LogInfo((object)("fallValue = " + __instance.fallValue)); val.LogInfo((object)("fallValueUncapped = " + __instance.fallValueUncapped)); val.LogInfo((object)("__instance.inSpecialInteractAnimation = " + __instance.inSpecialInteractAnimation)); val.LogInfo((object)("isJumping = " + __instance.isJumping)); val.LogInfo((object)("isFallingFromJump = " + __instance.isFallingFromJump)); __instance.DamagePlayer(Mathf.Clamp((int)__instance.fallValue, 20, 100), true, true, (CauseOfDeath)2, 0, true, Vector3.ClampMagnitude(__instance.velocityLastFrame, 50f)); } __instance.fallValue = Mathf.Clamp(__instance.fallValue - 38f * Time.deltaTime, -150f, __instance.jumpForce); __instance.fallValueUncapped -= 38f * Time.deltaTime; if (__instance.thisController.isGrounded || __instance.isClimbingLadder) { __instance.fallValue = -7f; __instance.fallValueUncapped = -7f; } } else if (flag3) { __instance.fallValue = Mathf.MoveTowards(__instance.fallValue, -1f, 7f * Time.deltaTime + num); __instance.fallValueUncapped = 0f; } } } }