Skip to content

Commit

Permalink
添加Speed模块
Browse files Browse the repository at this point in the history
  • Loading branch information
xia-mc committed May 24, 2024
1 parent e2e9cd9 commit 7965f03
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ public class Advanced3Config {
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean autoCatchSilentRotate = false;

@Numeric(minValue = 0, maxValue = 4)
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static int speedBoost = 2;

public static NotebotUtils.NotebotMode getNoteBotMode() {
if (noteBotMode.equals("AnyInstrument")) {
return NotebotUtils.NotebotMode.AnyInstrument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,8 @@ public class ModuleConfig {
@Hotkey
@Config(category = ConfigCategory.MODULES, predicate = ConfigPredicate.PASMode.class)
public static boolean autoCatchEnabled = false;

@Hotkey
@Config(category = ConfigCategory.MODULES, predicate = ConfigPredicate.PASMode.class)
public static boolean speedEnabled = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public void _onTick() {
private void doCatch() {
try {
target = LevelUtils.getClientLevel().players().stream()
.filter(p -> p.getName().getString().endsWith(Advanced3Config.autoCatchName))
.findAny()
.orElseThrow();
.filter(p -> p.getName().getString().endsWith(Advanced3Config.autoCatchName))
.min((p1, p2) -> (int) (p1.distanceTo(player.fabricPlayer) - p2.distanceTo(player.fabricPlayer)))
.orElseThrow();

double distance = target.distanceTo(player.fabricPlayer);
if (distance > Advanced3Config.autoCatchDistance && !Advanced3Config.autoCatchAsPossible) return;
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/top/infsky/cheatdetector/impl/modules/pas/Speed.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package top.infsky.cheatdetector.impl.modules.pas;

import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import top.infsky.cheatdetector.config.Advanced3Config;
import top.infsky.cheatdetector.config.ModuleConfig;
import top.infsky.cheatdetector.impl.Module;
import top.infsky.cheatdetector.impl.utils.world.PlayerMove;
import top.infsky.cheatdetector.utils.TRPlayer;
import top.infsky.cheatdetector.utils.TRSelf;

public class Speed extends Module {
private short offGroundTicks = 0;

public Speed(@NotNull TRSelf player) {
super("Speed", player);
}

@Override
public void _onTick() {
if (isDisabled()) {
offGroundTicks = 0;
return;
}

if (player.currentOnGround) {
offGroundTicks = 0;
} else {
offGroundTicks++;
}

switch (offGroundTicks) {
case 0 -> {
if (!TRPlayer.CLIENT.options.keyJump.isDown() && PlayerMove.isMove())
player.fabricPlayer.jumpFromGround();
}
case 5 -> {
Vec3 currentMotion = player.fabricPlayer.getDeltaMovement();
player.fabricPlayer.setDeltaMovement(currentMotion.x(), PlayerMove.predictedMotion(currentMotion.y(), Advanced3Config.speedBoost), currentMotion.z());
}
}
}

@Override
public boolean isDisabled() {
return !ModuleConfig.speedEnabled || !ModuleConfig.aaaPASModeEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import top.infsky.cheatdetector.utils.TRPlayer;

import java.util.Objects;

Expand Down Expand Up @@ -36,4 +37,27 @@ public static double getJumpDistance(@NotNull AbstractClientPlayer player) {
return 1.252203340253729;
}
}

public static boolean isMove() {
return TRPlayer.CLIENT.options.keyUp.isDown()
|| TRPlayer.CLIENT.options.keyDown.isDown()
|| TRPlayer.CLIENT.options.keyLeft.isDown()
|| TRPlayer.CLIENT.options.keyRight.isDown();
}

/**
* Gets the players predicted jump motion the specified amount of ticks ahead
*
* @return predicted jump motion
*/
public static double predictedMotion(final double motion, final int ticks) {
if (ticks == 0) return motion;
double predicted = motion;

for (int i = 0; i < ticks; i++) {
predicted = (predicted - 0.08) * 0.98F;
}

return predicted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public CheckManager(@NotNull Map<Class<? extends Check>, Check> preChecks,
post.put(Sprint.class, new Sprint(player));
post.put(SlowMotion.class, new SlowMotion(player));
post.put(AutoCatch.class, new AutoCatch(player));
post.put(Speed.class, new Speed(player));

return new CheckManager(pre, normal, post, player);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/assets/cheatdetector/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@
"cheatdetector.config.modules.autoCatchEnabled.comment": "auto catch a player.",
"cheatdetector.config.modules.autoCatchEnabled.name": "Enable AutoCatch",
"cheatdetector.config.modules.autoCatchEnabled.pretty_name": "AutoCatch",
"cheatdetector.config.modules.espEnabled.comment": "render the outline of players.",
"cheatdetector.config.modules.espEnabled.name": "Enable ESP",
"cheatdetector.config.modules.espEnabled.pretty_name": "ESP",
"cheatdetector.config.modules.speedEnabled.comment": "speed up!",
"cheatdetector.config.modules.speedEnabled.name": "Enable Speed",
"cheatdetector.config.modules.speedEnabled.pretty_name": "Speed",
"cheatdetector.gui.button.tab.advanced": "Advanced AntiCheat",
"cheatdetector.gui.button.tab.advanced2": "Advanced Fixes",
"cheatdetector.gui.button.tab.advanced3": "Advanced Modules",
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/assets/cheatdetector/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@
"cheatdetector.config.modules.debugEnabled.comment": "如果启用,我们会显示一些调试信息。",
"cheatdetector.config.modules.debugEnabled.name": "启用 调试",
"cheatdetector.config.modules.debugEnabled.pretty_name": "调试",
"cheatdetector.config.modules.espEnabled.comment": "为玩家渲染一个高亮的边框。",
"cheatdetector.config.modules.espEnabled.name": "启用 玩家高亮",
"cheatdetector.config.modules.espEnabled.pretty_name": "玩家高亮",
"cheatdetector.config.modules.fakelagEnabled.comment": "如果启用,我们会制造一些滞后。",
"cheatdetector.config.modules.fakelagEnabled.name": "启用 假延迟",
"cheatdetector.config.modules.fakelagEnabled.pretty_name": "假延迟",
Expand Down Expand Up @@ -149,6 +146,9 @@
"cheatdetector.config.modules.scaffoldEnabled.comment": "如果启用,我们会像脚手架一样放方块。",
"cheatdetector.config.modules.scaffoldEnabled.name": "启用 脚手架",
"cheatdetector.config.modules.scaffoldEnabled.pretty_name": "脚手架",
"cheatdetector.config.modules.speedEnabled.comment": "加速!使你跑的比别人更快。\n感谢 @§nAlan34§r 。",
"cheatdetector.config.modules.speedEnabled.name": "启用 速度",
"cheatdetector.config.modules.speedEnabled.pretty_name": "速度",
"cheatdetector.config.modules.spinEnabled.comment": "如果启用,你将像大陀螺一样旋转",
"cheatdetector.config.modules.spinEnabled.name": "启用 自旋",
"cheatdetector.config.modules.spinEnabled.pretty_name": "自旋",
Expand Down

0 comments on commit 7965f03

Please sign in to comment.