Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auto clicker not working while windows are open #5066

Merged
merged 5 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,6 +15,13 @@
public class AutoClicker extends Module {
private final SettingGroup sgGeneral = settings.getDefaultGroup();

private final Setting<Boolean> 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<Mode> leftClickMode = sgGeneral.add(new EnumSetting.Builder<Mode>()
.name("mode-left")
.description("The method of clicking for left clicks.")
Expand Down Expand Up @@ -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);
Expand All @@ -85,6 +91,7 @@ private void onTick(TickEvent.Post event) {
}
}
}

switch (rightClickMode.get()) {
case Disabled -> {}
case Hold -> mc.options.useKey.setPressed(true);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/meteordevelopment/meteorclient/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,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);
Expand Down
Loading