mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
[Feat] AutoClicker
This commit is contained in:
1 parent
367bc74e4c
commit
86f4c0e649
2 files changed
+73
No files matched your search
@@ -2,6 +2,7 @@ package cn.xiaozhou233.orangex.module;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventKey;
|
||||
import cn.xiaozhou233.orangex.module.impl.combat.AutoClicker;
|
||||
import cn.xiaozhou233.orangex.module.impl.misc.Test;
|
||||
import cn.xiaozhou233.orangex.module.impl.render.*;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -27,6 +28,8 @@ public class ModuleManager {
|
||||
register(new HUD());
|
||||
|
||||
register(new Test());
|
||||
|
||||
register(new AutoClicker());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.combat;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.impl.EventTick;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class AutoClicker extends Module {
|
||||
|
||||
// Fixed CPS
|
||||
private final double cps = 10.0;
|
||||
|
||||
// Last click timestamp
|
||||
private long lastClickTime = 0L;
|
||||
|
||||
public AutoClicker() {
|
||||
super("AutoClicker", ModuleCategory.COMBAT, Keyboard.KEY_F);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTick(EventTick event) {
|
||||
if (!isEnabled()) {
|
||||
releaseKey();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mc.currentScreen != null) {
|
||||
releaseKey();
|
||||
return;
|
||||
}
|
||||
|
||||
// Must hold physical left mouse button
|
||||
if (!Mouse.isButtonDown(0)) {
|
||||
releaseKey();
|
||||
return;
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
long delay = (long) (1000.0 / cps);
|
||||
|
||||
if (now - lastClickTime >= delay) {
|
||||
// Simulate one left click
|
||||
KeyBinding.setKeyBindState(
|
||||
mc.gameSettings.keyBindAttack.getKeyCode(),
|
||||
true
|
||||
);
|
||||
KeyBinding.onTick(mc.gameSettings.keyBindAttack.getKeyCode());
|
||||
|
||||
lastClickTime = now;
|
||||
} else {
|
||||
// Release immediately to avoid block breaking
|
||||
releaseKey();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
releaseKey();
|
||||
}
|
||||
|
||||
private void releaseKey() {
|
||||
KeyBinding.setKeyBindState(
|
||||
mc.gameSettings.keyBindAttack.getKeyCode(),
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user