diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java index 48ad6bacdd..bf2376b30d 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientAccessor.java @@ -41,6 +41,12 @@ static int getFps() { @Accessor("resourceReloadLogger") ResourceReloadLogger getResourceReloadLogger(); + @Accessor("attackCooldown") + int getAttackCooldown(); + + @Accessor("attackCooldown") + void setAttackCooldown(int attackCooldown); + @Invoker("doAttack") boolean leftClick(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoClicker.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoClicker.java index 63f9c8aefd..8ab9a34069 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoClicker.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoClicker.java @@ -6,10 +6,7 @@ package meteordevelopment.meteorclient.systems.modules.player; import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.settings.EnumSetting; -import meteordevelopment.meteorclient.settings.IntSetting; -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.Utils; @@ -18,6 +15,13 @@ public class AutoClicker extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final Setting inScreens = sgGeneral.add(new BoolSetting.Builder() + .name("while-in-screens") + .description("Whether to click while a screen is open.") + .defaultValue(true) + .build() + ); + private final Setting leftClickMode = sgGeneral.add(new EnumSetting.Builder() .name("mode-left") .description("The method of clicking for left clicks.") @@ -74,6 +78,8 @@ public void onDeactivate() { @EventHandler private void onTick(TickEvent.Post event) { + if (!inScreens.get() && mc.currentScreen != null) return; + switch (leftClickMode.get()) { case Disabled -> {} case Hold -> mc.options.attackKey.setPressed(true); @@ -85,6 +91,7 @@ private void onTick(TickEvent.Post event) { } } } + switch (rightClickMode.get()) { case Disabled -> {} case Hold -> mc.options.useKey.setPressed(true); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java index a0d2b70d67..fe6501a789 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java @@ -513,6 +513,14 @@ public static double random(double min, double max) { } public static void leftClick() { + // check if a screen is open + // see net.minecraft.client.Mouse.lockCursor + // see net.minecraft.client.MinecraftClient.tick + int attackCooldown = ((MinecraftClientAccessor) mc).getAttackCooldown(); + if (attackCooldown == 10000) { + ((MinecraftClientAccessor) mc).setAttackCooldown(0); + } + mc.options.attackKey.setPressed(true); ((MinecraftClientAccessor) mc).leftClick(); mc.options.attackKey.setPressed(false);