From 6745b011c535aff54cfd077f9de073daa2d5b1e0 Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Tue, 5 Nov 2024 14:55:51 +0100 Subject: [PATCH] HitReg --- .../Patches/Fixes/JailbirdHitRegFix.cs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 EXILED/Exiled.Events/Patches/Fixes/JailbirdHitRegFix.cs diff --git a/EXILED/Exiled.Events/Patches/Fixes/JailbirdHitRegFix.cs b/EXILED/Exiled.Events/Patches/Fixes/JailbirdHitRegFix.cs new file mode 100644 index 0000000000..fa848d09f5 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Fixes/JailbirdHitRegFix.cs @@ -0,0 +1,61 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Fixes +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Pools; + + using HarmonyLib; + using InventorySystem.Items.Jailbird; + using Mirror; + using Utils.Networking; + + using static HarmonyLib.AccessTools; + + /// + /// Patches . + /// + [HarmonyPatch(typeof(JailbirdHitreg), nameof(JailbirdHitreg.ServerAttack))] + internal static class JailbirdHitRegFix + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + int index = newInstructions.FindIndex(i => i.Calls(Method(typeof(ReferenceHubReaderWriter), nameof(ReferenceHubReaderWriter.TryReadReferenceHub)))) - 2; + + int breakIndex = newInstructions.FindIndex(i => i.Calls(Method(typeof(JailbirdHitreg), nameof(JailbirdHitreg.DetectDestructibles)))) - 1; + Label breakLabel = generator.DefineLabel(); + newInstructions[breakIndex].WithLabels(breakLabel); + + List