From 3f3dfde79592612120e9fb3c49cc4f03805bf536 Mon Sep 17 00:00:00 2001 From: Tryfle Date: Sun, 3 Dec 2023 18:02:18 -0500 Subject: [PATCH] :heartbeat: Fix ClickAssist ++ WTAP (buggyish) --- .../stormy/client/module/ModuleManager.java | 1 + .../module/modules/combat/ClickAssist.java | 105 +++++++++++------- .../client/module/modules/combat/WTap.java | 65 +++++++++++ 3 files changed, 133 insertions(+), 38 deletions(-) create mode 100644 src/main/java/dev/stormy/client/module/modules/combat/WTap.java diff --git a/src/main/java/dev/stormy/client/module/ModuleManager.java b/src/main/java/dev/stormy/client/module/ModuleManager.java index c58ae24..c2ccfab 100644 --- a/src/main/java/dev/stormy/client/module/ModuleManager.java +++ b/src/main/java/dev/stormy/client/module/ModuleManager.java @@ -60,6 +60,7 @@ public ModuleManager() { addModule(new Criticals()); addModule(new Stealer()); addModule(new Manager()); + addModule(new WTap()); initialized = true; } diff --git a/src/main/java/dev/stormy/client/module/modules/combat/ClickAssist.java b/src/main/java/dev/stormy/client/module/modules/combat/ClickAssist.java index 5dc04f6..6b5fdf6 100644 --- a/src/main/java/dev/stormy/client/module/modules/combat/ClickAssist.java +++ b/src/main/java/dev/stormy/client/module/modules/combat/ClickAssist.java @@ -1,82 +1,111 @@ package dev.stormy.client.module.modules.combat; import dev.stormy.client.module.Module; -import dev.stormy.client.module.setting.impl.DescriptionSetting; -import dev.stormy.client.module.setting.impl.SliderSetting; -import dev.stormy.client.module.setting.impl.TickSetting; -import dev.stormy.client.utils.game.MouseManager; +import dev.stormy.client.module.setting.impl.*; +import dev.stormy.client.utils.math.MathUtils; +import dev.stormy.client.utils.math.TimerUtils; import dev.stormy.client.utils.player.PlayerUtils; +import me.tryfle.stormy.events.UpdateEvent; import net.minecraft.util.ChatComponentText; import net.weavemc.loader.api.event.SubscribeEvent; import net.weavemc.loader.api.event.MouseEvent; import java.awt.*; -//note to self: make this work +@SuppressWarnings("unused") public class ClickAssist extends Module { + + TimerUtils timer = new TimerUtils(); public static SliderSetting chance; public static TickSetting cpsCheck; + public static DoubleSliderSetting cd; + public static ComboSetting mode; private boolean allowClick = false; public Robot robot; + private int cps; public ClickAssist() { super("ClickAssist", ModuleCategory.Combat, 0); this.registerSetting(new DescriptionSetting("Chance to double click.")); - this.registerSetting(new DescriptionSetting("locked at 100%, don't use.")); this.registerSetting(chance = new SliderSetting("Chance", 50.0D, 0.0D, 100.0D, 1.0D)); + this.registerSetting(cd = new DoubleSliderSetting("Delay", 40, 100, 0, 300, 1)); this.registerSetting(cpsCheck = new TickSetting("Only if above 5 CPS", true)); + this.registerSetting(mode = new ComboSetting<>("Mode", modes.LMB)); } public void onEnable() { try { this.robot = new Robot(); - } catch (AWTException awtexc) { - mc.thePlayer.addChatMessage(new ChatComponentText("An error has occurred and ClickAssist had to be disabled. Stacktrace printed to console.")); - awtexc.printStackTrace(); + } catch (AWTException ex) { + mc.thePlayer.addChatMessage(new ChatComponentText("An error has occurred: Stacktrace printed to console.")); + ex.printStackTrace(); this.disable(); } } - @SuppressWarnings("unused") + public int getButton() { + if (mode.getMode() == modes.LMB) { + return 16; + } else { + return 4; + } + } + public int getButton2() { + if (mode.getMode() == modes.LMB) { + return 0; + } else { + return 1; + } + } + @SubscribeEvent - public void whyClick(MouseEvent e) { - if (PlayerUtils.isPlayerInGame()) { - if (cpsCheck.isToggled()) { - if (e.getButtonState() && e.getButton() == 0 && chance.getInput() == 100.0D && MouseManager.getLeftClickCounter() >= 5) { - logic(); - } - if (e.getButtonState() && e.getButton() == 0 && chance.getInput() != 100.0D) { - double ch = Math.random(); - if (ch >= chance.getInput() / 100.0D) { - logic(); - } - } - } else { - if (e.getButtonState() && e.getButton() == 0 && chance.getInput() == 100.0D) { - logic(); - } - if (e.getButtonState() && e.getButton() == 0 && chance.getInput() != 100.0D) { - double ch = Math.random(); - if (ch >= chance.getInput() / 100.0D) { - logic(); - } + public void onClick(MouseEvent e) { + if (!PlayerUtils.isPlayerInGame()) return; + if (e.getButton() == getButton2()) { + cps++; + if (allowClick) { + double ch = Math.random() * 100; + if (ch >= chance.getInput()) { + return; } } + if (cpsCheck.isToggled() && cps < 5) { + return; + } + int d = MathUtils.randomInt(cd.getInputMin(), cd.getInputMax()); + if (timer.hasReached(d)) { + logic(); + timer.reset(); + } } } + @SubscribeEvent + public void onUpdate(UpdateEvent e) { + if (timer.hasReached(1000) && cps > 0) { + cps = 0; + timer.reset(); + } + } + public void logic() { if (allowClick) { - this.robot.mouseRelease(16); - this.robot.mousePress(16); - this.robot.mouseRelease(16); + this.robot.mouseRelease(getButton()); + this.robot.mousePress(getButton()); + this.robot.mouseRelease(getButton()); allowClick = false; } else { allowClick = true; } } - public void onDisable() { - this.robot = null; - } - } \ No newline at end of file + + public void onDisable() { + cps = 0; + this.robot = null; + } + + public enum modes { + LMB, RMB + } +} \ No newline at end of file diff --git a/src/main/java/dev/stormy/client/module/modules/combat/WTap.java b/src/main/java/dev/stormy/client/module/modules/combat/WTap.java new file mode 100644 index 0000000..d791251 --- /dev/null +++ b/src/main/java/dev/stormy/client/module/modules/combat/WTap.java @@ -0,0 +1,65 @@ +package dev.stormy.client.module.modules.combat; + +import dev.stormy.client.module.Module; +import dev.stormy.client.module.setting.impl.DescriptionSetting; +import dev.stormy.client.module.setting.impl.DoubleSliderSetting; +import dev.stormy.client.module.setting.impl.SliderSetting; +import dev.stormy.client.utils.math.MathUtils; +import dev.stormy.client.utils.math.TimerUtils; +import dev.stormy.client.utils.player.PlayerUtils; +import me.tryfle.stormy.events.UpdateEvent; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MovingObjectPosition; +import net.weavemc.loader.api.event.SubscribeEvent; +import org.lwjgl.input.Mouse; + +@SuppressWarnings("unused") +public class WTap extends Module { + public static SliderSetting range, chance; + public static DoubleSliderSetting delay; + TimerUtils timer = new TimerUtils(); + + public WTap() { + super("WTap", Module.ModuleCategory.Combat, 0); + this.registerSetting(new DescriptionSetting("Sprint resets automatically.")); + this.registerSetting(range = new SliderSetting("Range", 4.0D, 0.0D, 6.0D, 0.1D)); + this.registerSetting(chance = new SliderSetting("Chance", 50.0D, 0.0D, 100.0D, 1.0D)); + this.registerSetting(delay = new DoubleSliderSetting("Delay", 50.0D, 100.0D, 0.0D, 300.0D, 5.0D)); + } + + int wkey = mc.gameSettings.keyBindForward.getKeyCode(); + + public boolean isLookingAtPlayer() { + MovingObjectPosition result = mc.objectMouseOver; + if (result != null && result.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && result.entityHit instanceof EntityPlayer targetPlayer) { + return PlayerUtils.lookingAtPlayer(mc.thePlayer, targetPlayer, range.getInput()); + } + return false; + } + + @SubscribeEvent + public void onUpdate(UpdateEvent e) { + if (PlayerUtils.isPlayerInGame() && isLookingAtPlayer() && Mouse.isButtonDown(0) && mc.thePlayer.moveForward > 0 && mc.currentScreen == null) { + if (chance.getInput() != 100.0D) { + double ch = Math.random() * 100; + if (ch >= chance.getInput()) { + return; + } + } + int d = MathUtils.randomInt(delay.getInputMin(), delay.getInputMax()); + if (timer.hasReached(d)) { + KeyBinding.setKeyBindState(wkey, false); + KeyBinding.onTick(wkey); + rePress(); + } + } + } + + public void rePress() { + if (mc.thePlayer.moveForward > 0) { + KeyBinding.setKeyBindState(wkey, true); + KeyBinding.onTick(wkey); + } + } +} \ No newline at end of file