mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
[Delete] AutoClicker
This commit is contained in:
1 parent
ee3b3fee41
commit
828e6bc8c2
2 files changed
-123
No files matched your search
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -29,7 +28,6 @@ public class ModuleManager {
|
||||
|
||||
register(new Test());
|
||||
|
||||
register(new AutoClicker());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
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 cn.xiaozhou233.orangex.module.value.BooleanValue;
|
||||
import cn.xiaozhou233.orangex.module.value.KeybindValue;
|
||||
import cn.xiaozhou233.orangex.module.value.NumberValue;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class AutoClicker extends Module {
|
||||
|
||||
private final NumberValue cps =
|
||||
new NumberValue("CPS", "Clicks per second", 12.0, 1, 30, 1);
|
||||
|
||||
// jitter range (±)
|
||||
private final NumberValue jitter =
|
||||
new NumberValue("Jitter", "CPS random offset", 1.0, 0.0, 3.0, 0.1);
|
||||
|
||||
// ignore block (deprecated now, but kept for compatibility)
|
||||
private final BooleanValue ignoreBlock =
|
||||
new BooleanValue("IgnoreBlock", "Ignore block click", false);
|
||||
|
||||
private int tickCounter = 0;
|
||||
private boolean clicking = false;
|
||||
private double currentTicksPerClick = 0.0;
|
||||
|
||||
public AutoClicker() {
|
||||
super("AutoClicker", ModuleCategory.COMBAT);
|
||||
addValue(cps);
|
||||
addValue(jitter);
|
||||
addValue(ignoreBlock);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTick(EventTick event) {
|
||||
|
||||
if (!isEnabled() || mc.currentScreen != null || !Mouse.isButtonDown(0)) {
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
MovingObjectPosition target = mc.objectMouseOver;
|
||||
|
||||
// Target is a block
|
||||
if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindAttack.getKeyCode(), true);
|
||||
KeyBinding.onTick(mc.gameSettings.keyBindAttack.getKeyCode());
|
||||
|
||||
tickCounter = 0;
|
||||
clicking = false;
|
||||
currentTicksPerClick = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// If ignoreBlock enabled and looking at block -> skip clicking (optional)
|
||||
if (ignoreBlock.getValue() && target != null &&
|
||||
target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentTicksPerClick <= 0) {
|
||||
recalcDelay();
|
||||
}
|
||||
|
||||
tickCounter++;
|
||||
|
||||
if (tickCounter >= currentTicksPerClick) {
|
||||
// press
|
||||
KeyBinding.setKeyBindState(
|
||||
mc.gameSettings.keyBindAttack.getKeyCode(), true);
|
||||
KeyBinding.onTick(mc.gameSettings.keyBindAttack.getKeyCode());
|
||||
|
||||
clicking = true;
|
||||
tickCounter = 0;
|
||||
|
||||
// next click uses new random cps
|
||||
recalcDelay();
|
||||
} else if (clicking) {
|
||||
// release next tick
|
||||
releaseKey();
|
||||
clicking = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void recalcDelay() {
|
||||
double base = cps.getValue();
|
||||
double range = jitter.getValue();
|
||||
|
||||
double randomCps = base + ThreadLocalRandom.current().nextDouble(-range, range);
|
||||
|
||||
// clamp
|
||||
randomCps = Math.max(1.0, Math.min(20.0, randomCps));
|
||||
|
||||
currentTicksPerClick = 20.0 / randomCps;
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
releaseKey();
|
||||
tickCounter = 0;
|
||||
clicking = false;
|
||||
currentTicksPerClick = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
reset();
|
||||
}
|
||||
|
||||
private void releaseKey() {
|
||||
KeyBinding.setKeyBindState(
|
||||
mc.gameSettings.keyBindAttack.getKeyCode(), false);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user