From 2ed3b9af0e7a7445a9dc7106ef23e1826e0dc1dd Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 31 Dec 2023 17:43:34 +0600 Subject: [PATCH] Reach Detection --- .../java/net/silentclient/client/Client.java | 5 +++ .../client/mods/hud/ReachDisplayMod.java | 6 +-- .../client/skillissue/SkillIssue.java | 21 ++++++++++ .../skillissue/detections/Detection.java | 41 +++++++++++++++++++ .../client/skillissue/detections/Reach.java | 29 +++++++++++++ 5 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 src/main/java/net/silentclient/client/skillissue/SkillIssue.java create mode 100644 src/main/java/net/silentclient/client/skillissue/detections/Detection.java create mode 100644 src/main/java/net/silentclient/client/skillissue/detections/Reach.java diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index 4f8f9c1..bc460bc 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -36,6 +36,7 @@ import net.silentclient.client.mods.util.Server; import net.silentclient.client.mods.util.Utils; import net.silentclient.client.premium.PremiumCosmeticsGui; import net.silentclient.client.premium.PremiumUtils; +import net.silentclient.client.skillissue.SkillIssue; import net.silentclient.client.utils.*; import net.silentclient.client.utils.animations.AnimationHandler; import net.silentclient.client.utils.animations.SneakHandler; @@ -97,6 +98,7 @@ public class Client { private AccountManager accountManager; public ServerData lastServerData; public TextUtils textUtils; + private SkillIssue skillIssue; public static void memoryDebug(String paramString) { LogManager.getLogger().info("-- Start Memory Debug -- " + paramString); @@ -352,6 +354,9 @@ public class Client { } Client.logger.info("STARTING > text-utils"); this.textUtils = new TextUtils(Minecraft.getMinecraft().fontRendererObj); + + logger.info("STARTING > skillissue"); + this.skillIssue = new SkillIssue(); logger.info("-------------------------------------------------"); memoryDebug("CLIENT_POST_INIT"); } diff --git a/src/main/java/net/silentclient/client/mods/hud/ReachDisplayMod.java b/src/main/java/net/silentclient/client/mods/hud/ReachDisplayMod.java index 5f3ff08..760257a 100644 --- a/src/main/java/net/silentclient/client/mods/hud/ReachDisplayMod.java +++ b/src/main/java/net/silentclient/client/mods/hud/ReachDisplayMod.java @@ -1,15 +1,15 @@ package net.silentclient.client.mods.hud; -import java.text.DecimalFormat; - import net.silentclient.client.event.EventTarget; import net.silentclient.client.event.impl.EntityAttackEvent; import net.silentclient.client.mods.HudMod; import net.silentclient.client.mods.ModCategory; +import java.text.DecimalFormat; + public class ReachDisplayMod extends HudMod { - private static final DecimalFormat FORMAT = new DecimalFormat("0.##"); + public static final DecimalFormat FORMAT = new DecimalFormat("0.##"); private double distance = 0; private long hitTime = -1; diff --git a/src/main/java/net/silentclient/client/skillissue/SkillIssue.java b/src/main/java/net/silentclient/client/skillissue/SkillIssue.java new file mode 100644 index 0000000..d840324 --- /dev/null +++ b/src/main/java/net/silentclient/client/skillissue/SkillIssue.java @@ -0,0 +1,21 @@ +package net.silentclient.client.skillissue; + +import net.silentclient.client.Client; +import net.silentclient.client.skillissue.detections.Detection; +import net.silentclient.client.skillissue.detections.Reach; + +import java.util.ArrayList; + +public class SkillIssue { + public static final String VERSION = "1.0.0-beta.1"; + private final ArrayList detections = new ArrayList<>(); + + public SkillIssue() { + Client.logger.info(String.format("[SkillIssue]: Initialising (v%s)", VERSION)); + detections.add(new Reach(this)); + } + + public ArrayList getDetections() { + return detections; + } +} diff --git a/src/main/java/net/silentclient/client/skillissue/detections/Detection.java b/src/main/java/net/silentclient/client/skillissue/detections/Detection.java new file mode 100644 index 0000000..e3f07f7 --- /dev/null +++ b/src/main/java/net/silentclient/client/skillissue/detections/Detection.java @@ -0,0 +1,41 @@ +package net.silentclient.client.skillissue.detections; + +import net.minecraft.client.Minecraft; +import net.silentclient.client.Client; +import net.silentclient.client.event.EventManager; +import net.silentclient.client.event.EventTarget; +import net.silentclient.client.event.impl.ClientTickEvent; +import net.silentclient.client.skillissue.SkillIssue; + +public class Detection { + protected Minecraft mc = Minecraft.getMinecraft(); + protected SkillIssue skillIssue; + protected int detections = 0; + protected long lastDetection = 0; + private final String name; + + public Detection(SkillIssue skillIssue, String name) { + this.skillIssue = skillIssue; + this.name = name; + EventManager.register(this); + } + + public void detect(String data) { + this.detections += 1; + this.lastDetection = System.currentTimeMillis(); + Client.logger.warn(String.format("[SkillIssue]: %s Detection: %s (vl: %s)", name, data, detections)); + } + + @EventTarget + public void updateDetection(ClientTickEvent event) { + if(lastDetection != 0) { + if(System.currentTimeMillis() - lastDetection >= 600000) { + lastDetection = 0; + } + } + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/net/silentclient/client/skillissue/detections/Reach.java b/src/main/java/net/silentclient/client/skillissue/detections/Reach.java new file mode 100644 index 0000000..c95e5d3 --- /dev/null +++ b/src/main/java/net/silentclient/client/skillissue/detections/Reach.java @@ -0,0 +1,29 @@ +package net.silentclient.client.skillissue.detections; + +import net.silentclient.client.event.EventTarget; +import net.silentclient.client.event.impl.EntityAttackEvent; +import net.silentclient.client.mods.hud.ReachDisplayMod; +import net.silentclient.client.skillissue.SkillIssue; +import net.silentclient.client.utils.PlayerUtils; + +public class Reach extends Detection { + private long lastHit = 0; + + public Reach(SkillIssue skillIssue) { + super(skillIssue, "Reach"); + } + + @EventTarget + public void totallyNoReachHax(EntityAttackEvent event) { + if(System.currentTimeMillis() - lastHit < 500 || !PlayerUtils.isSurvival()) { + return; + } + if(mc.objectMouseOver != null && mc.objectMouseOver.hitVec != null) { + this.lastHit = System.currentTimeMillis(); + double distance = mc.objectMouseOver.hitVec.distanceTo(mc.thePlayer.getPositionEyes(1.0F)); + if(distance > 3) { + this.detect("distance: " + ReachDisplayMod.FORMAT.format(distance)); + } + } + } +}