From 60c2c273f0c4167002c365e4aae508580b3e4fea Mon Sep 17 00:00:00 2001 From: Alvin Dimas Praditya Date: Wed, 14 Aug 2024 02:16:26 +0700 Subject: [PATCH] fix packed methods condition --- .idea/modules/lagassist.test.iml | 3 +++ .../org.alvindimas05.lagassist.lagassist.main.iml | 3 +++ .../lagassist/packets/PacketInjector.java | 12 ++++++------ .../org/alvindimas05/lagassist/utils/VersionMgr.java | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.idea/modules/lagassist.test.iml b/.idea/modules/lagassist.test.iml index ea28a0c..fc1a45f 100644 --- a/.idea/modules/lagassist.test.iml +++ b/.idea/modules/lagassist.test.iml @@ -12,4 +12,7 @@ + + \ No newline at end of file diff --git a/.idea/modules/org.alvindimas05.lagassist.lagassist.main.iml b/.idea/modules/org.alvindimas05.lagassist.lagassist.main.iml index ea28a0c..fc1a45f 100644 --- a/.idea/modules/org.alvindimas05.lagassist.lagassist.main.iml +++ b/.idea/modules/org.alvindimas05.lagassist.lagassist.main.iml @@ -12,4 +12,7 @@ + + \ No newline at end of file diff --git a/src/main/java/org/alvindimas05/lagassist/packets/PacketInjector.java b/src/main/java/org/alvindimas05/lagassist/packets/PacketInjector.java index 7ce32f7..7724bae 100644 --- a/src/main/java/org/alvindimas05/lagassist/packets/PacketInjector.java +++ b/src/main/java/org/alvindimas05/lagassist/packets/PacketInjector.java @@ -23,16 +23,16 @@ public static void Enabler() { return; } try { - PacketInjector.playerConnection = Reflection.getClass(VersionMgr.isV_17Plus() ? "{nms}.level.EntityPlayer" : "{nms}.EntityPlayer").getField(VersionMgr.isV_17Plus() ? "b" : "playerConnection"); - PacketInjector.networkManager = Reflection.getClass(VersionMgr.isV_17Plus() ? "{nms}.network.PlayerConnection" : "{nms}.PlayerConnection").getField(VersionMgr.isV_17Plus() ? "a" : "networkManager"); - - PacketInjector.channel = Reflection.getClass(VersionMgr.isV_17Plus() ? "{nm}.network.NetworkManager" : "{nms}.NetworkManager").getField(VersionMgr.isV_17Plus() ? "k" : "channel"); - - if(VersionMgr.isV_21Plus()){ + if(VersionMgr.isV_20Plus()){ PacketInjector.playerConnection = Reflection.getClass("{nms}.level.EntityPlayer").getField("c"); PacketInjector.networkManager = Reflection.getClass("{nms}.network.PlayerConnection").getField("e"); PacketInjector.channel = Reflection.getClass(VersionMgr.isV_17Plus() ? "{nm}.network.NetworkManager" : "{nms}.NetworkManager").getField("n"); + } else { + PacketInjector.playerConnection = Reflection.getClass(VersionMgr.isV_17Plus() ? "{nms}.level.EntityPlayer" : "{nms}.EntityPlayer").getField(VersionMgr.isV_17Plus() ? "b" : "playerConnection"); + PacketInjector.networkManager = Reflection.getClass(VersionMgr.isV_17Plus() ? "{nms}.network.PlayerConnection" : "{nms}.PlayerConnection").getField(VersionMgr.isV_17Plus() ? "a" : "networkManager"); + + PacketInjector.channel = Reflection.getClass(VersionMgr.isV_17Plus() ? "{nm}.network.NetworkManager" : "{nms}.NetworkManager").getField(VersionMgr.isV_17Plus() ? "k" : "channel"); } PacketInjector.refreshSessions(); diff --git a/src/main/java/org/alvindimas05/lagassist/utils/VersionMgr.java b/src/main/java/org/alvindimas05/lagassist/utils/VersionMgr.java index 2d92e86..e35dff8 100644 --- a/src/main/java/org/alvindimas05/lagassist/utils/VersionMgr.java +++ b/src/main/java/org/alvindimas05/lagassist/utils/VersionMgr.java @@ -81,8 +81,8 @@ public static boolean isV_17Plus() { return isV1_17() || isV1_18() || isV1_19() || isV1_20() || isV1_21(); } - public static boolean isV_21Plus() { - return isV1_21(); + public static boolean isV_20Plus() { + return isV1_20() || isV1_21(); } public static boolean isNewMaterials() {