mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
Merge pull request #7 from xiaozhou233/feat/fastplace
[Feat] Add FastPlace
This commit is contained in:
commit
88006b8fcd
4 files changed
+85
No files matched your search
@@ -3,6 +3,7 @@ package cn.xiaozhou233.orangex.module;
|
||||
public enum ModuleCategory {
|
||||
RENDER,
|
||||
COMBAT,
|
||||
WORLD,
|
||||
MISC,
|
||||
MOVEMENT,
|
||||
PLAYER,
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.xiaozhou233.orangex.module.impl.fun.Derp;
|
||||
import cn.xiaozhou233.orangex.module.impl.misc.Test;
|
||||
import cn.xiaozhou233.orangex.module.impl.movement.NoJumpDelay;
|
||||
import cn.xiaozhou233.orangex.module.impl.render.*;
|
||||
import cn.xiaozhou233.orangex.module.impl.world.FastPlace;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -37,6 +38,8 @@ public class ModuleManager {
|
||||
register(new NoJumpDelay());
|
||||
|
||||
register(new AutoClicker());
|
||||
|
||||
register(new FastPlace());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.world;
|
||||
|
||||
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.NumberValue;
|
||||
import cn.xiaozhou233.orangex.utils.ReflectionUtil;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class FastPlace extends Module {
|
||||
|
||||
// Level 1~5
|
||||
private final NumberValue level =
|
||||
new NumberValue("Level", "FastPlace level", 1d, 1d, 5d, 1d);
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
public FastPlace() {
|
||||
super("FastPlace", ModuleCategory.WORLD);
|
||||
addValue(level);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTick(EventTick event) {
|
||||
if (mc.thePlayer == null || mc.theWorld == null) return;
|
||||
|
||||
ItemStack stack = mc.thePlayer.getHeldItem();
|
||||
if (stack == null || !(stack.getItem() instanceof ItemBlock)) return;
|
||||
|
||||
try {
|
||||
int lvl = level.getValue().intValue();
|
||||
|
||||
// Level -> min/max ms
|
||||
int minMs = (lvl - 1) * 50;
|
||||
int maxMs = lvl * 50;
|
||||
|
||||
// Random ms within level range
|
||||
int delayMs = minMs + random.nextInt(maxMs - minMs + 1);
|
||||
|
||||
int targetTick = (int) Math.ceil(delayMs / 50.0);
|
||||
int current = ReflectionUtil.getRightClickDelay();
|
||||
|
||||
if (current > targetTick) {
|
||||
ReflectionUtil.setRightClickDelay(targetTick);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.xiaozhou233.orangex.utils;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ReflectionUtil {
|
||||
|
||||
private static Field rightClickDelayField;
|
||||
|
||||
static {
|
||||
try {
|
||||
rightClickDelayField = Minecraft.class.getDeclaredField("rightClickDelayTimer");
|
||||
rightClickDelayField.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
System.out.println("[ReflectionUtil] Failed to get rightClickDelayTimer field");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getRightClickDelay() throws IllegalAccessException {
|
||||
return rightClickDelayField.getInt(Minecraft.getMinecraft());
|
||||
}
|
||||
|
||||
public static void setRightClickDelay(int value) throws IllegalAccessException {
|
||||
rightClickDelayField.setInt(Minecraft.getMinecraft(), value);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user