Skip to content

Commit

Permalink
Release 2.9.4
Browse files Browse the repository at this point in the history
- 新 实验性检查
    - 如果启用,模组会使用实验性检查。
    - 请注意,在很长的一段时间内,这些实验性检查均不可靠,使用前请了解。
- 新检查 ReachA
    - 仅实验性检查
    - 在默认情况下,mod会硬检查并标记超过3.5格的距离。
- 新模块 Speed
    - 仅PAS模式
    - 让你稍微跑的比别人快一点,同时更灵活。
- 改进 AutoCatch
- 改进 Fly, AirStuck
- 改进 MotionA检查
- 改进 AntiBot
  • Loading branch information
xia-mc committed May 25, 2024
1 parent 7965f03 commit 47b707f
Show file tree
Hide file tree
Showing 30 changed files with 311 additions and 107 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minecraft_version=1.20.1
loader_version=0.14.23

# Mod Properties
mod_version = 2.9.3
mod_version = 2.9.4
maven_group = top.infsky
archives_base_name = CheatDetector

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class Advanced2Config {
@Numeric(minValue = -1, maxValue = 600)
@Config(category = ConfigCategory.ADVANCED2)
public static int serverFreezePostDelay = -1;
@Numeric(minValue = 0, maxValue = Integer.MAX_VALUE)
@Numeric(minValue = 0, maxValue = 30000)
@Config(category = ConfigCategory.ADVANCED2)
public static int serverFreezeMaxTicks = 20;
public static int serverFreezeMaxMs = 800;
@Config(category = ConfigCategory.ADVANCED2)
public static boolean serverFreezeAutoDisableCheck = true;
@Config(category = ConfigCategory.ADVANCED2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,15 @@ public class Advanced3Config {
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean autoCatchAlways = false;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean autoCatchExtraPost = false;
@Numeric(minValue = 1, maxValue = 49)
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static int autoCatchExtraPostDelayMs = 25;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean autoCatchAsPossible = false;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean autoCatchResetMotion = false;
@Numeric(minValue = 0, maxValue = 6)
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static double autoCatchAsPossibleTeleportDistance = 6;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import top.hendrixshen.magiclib.malilib.api.annotation.*;
import top.infsky.cheatdetector.config.utils.ConfigCategory;
import top.infsky.cheatdetector.config.utils.ConfigPredicate;

public class AdvancedConfig {
@Config(category = ConfigCategory.ADVANCED)
Expand Down Expand Up @@ -128,10 +129,21 @@ public class AdvancedConfig {
public static int motionAAlertBuffer = 10;

@Config(category = ConfigCategory.ADVANCED)
public static boolean flyCCheck = false;
public static boolean flyCCheck = true;
@Config(category = ConfigCategory.ADVANCED)
public static int flyCAlertBuffer = 10;

@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static boolean reachACheck = true;
@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static int reachAAlertBuffer = 2;
@Numeric(minValue = 0, maxValue = 6)
@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static double reachADefaultReach = 3.5;
@Numeric(minValue = 0, maxValue = 4)
@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static int reachACheckDelay = 2;

public static short getFlyAOnGroundJumpTick() {
return (short) flyAOnGroundJumpTick;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,18 @@

import org.jetbrains.annotations.NotNull;
import top.hendrixshen.magiclib.malilib.api.annotation.Config;
import top.hendrixshen.magiclib.malilib.api.annotation.Hotkey;
import top.infsky.cheatdetector.config.utils.ConfigCategory;

public class AlertConfig {
@Hotkey
@Config(category = ConfigCategory.ALERT)
public static boolean allowAlert = true;

@Hotkey
@Config(category = ConfigCategory.ALERT)
public static boolean allowAlertFixes = false;

@Hotkey
@Config(category = ConfigCategory.ALERT)
public static boolean allowAlertVLClear = false;

@Hotkey
@Config(category = ConfigCategory.ALERT)
public static boolean disableBuffer = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package top.infsky.cheatdetector.config;

import top.hendrixshen.magiclib.malilib.api.annotation.Config;
import top.hendrixshen.magiclib.malilib.api.annotation.Hotkey;
import top.hendrixshen.magiclib.malilib.api.annotation.Numeric;
import top.infsky.cheatdetector.config.utils.ConfigCategory;

public class AntiCheatConfig {
@Hotkey
@Config(category = ConfigCategory.ANTICHEAT)
public static boolean antiCheatEnabled = true;

@Hotkey
@Config(category = ConfigCategory.ANTICHEAT)
public static boolean disableSelfCheck = false;

@Hotkey
@Config(category = ConfigCategory.ANTICHEAT)
public static boolean experimentalCheck = false;

@Config(category = ConfigCategory.ANTICHEAT)
public static boolean falseFlagFix = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import top.infsky.cheatdetector.config.utils.Fixes;

public class FixesConfig {
@Hotkey
@Config(category = ConfigCategory.FIXES)
public static boolean packetFixEnabled = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import top.hendrixshen.magiclib.malilib.impl.ConfigManager;
import top.hendrixshen.magiclib.malilib.impl.ConfigOption;
import top.infsky.cheatdetector.config.Advanced3Config;
import top.infsky.cheatdetector.config.AntiCheatConfig;
import top.infsky.cheatdetector.config.DangerConfig;
import top.infsky.cheatdetector.config.ModuleConfig;

Expand All @@ -16,6 +17,13 @@ public static void onJoinWorld(String ip, @NotNull ConfigManager configManager)
configManager.setValue("aaaPASModeEnabled", PASMode.getIpAddresses().contains(ip));
}

public static class ExperimentalMode implements ConfigDependencyPredicate {
@Override
public boolean isSatisfied(ConfigOption option) {
return AntiCheatConfig.experimentalCheck;
}

}

public static class PASMode implements ConfigDependencyPredicate {
public static @NotNull @Unmodifiable List<String> getIpAddresses() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void _onTeleport() {
public void _onJump() {
List<Double> motions = MotionA.getPossibleMotions(player);

jumpTick = motions != null ? (short) motions.size() : Short.MAX_VALUE;
jumpTick = motions != null ? (short) (motions.size() + 1) : Short.MAX_VALUE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void _onTick() {
final Level level = CheatDetector.CLIENT.level;
if (level == null) return;

if (!player.currentOnGround && player.currentPos.y() % 1 == 0) { // check if it's *OnGround*
if (!player.currentOnGround && Math.floor(player.currentPos.y()) == player.currentPos.y()) { // check if it's *OnGround*
final BlockPos groundPos = player.fabricPlayer.blockPosition().below();

if (check(level, groundPos)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ private boolean check() {
disableTicks = (int) Math.ceil(player.latency / 50.0) + 3;
return false;
}
if (player.fabricPlayer.getActiveEffectsMap().keySet().stream().anyMatch(IGNORED_EFFECTS::contains)
if (IGNORED_EFFECTS.stream().anyMatch(effect -> player.fabricPlayer.hasEffect(effect))
|| player.fabricPlayer.isInWall() || player.fabricPlayer.isInWater()
|| player.fabricPlayer.isPassenger() || player.fabricPlayer.isVehicle()
|| player.fabricPlayer.isAutoSpinAttack() || player.fabricPlayer.isSwimming()
|| player.fabricPlayer.isSleeping() || player.fabricPlayer.onClimbable()
|| player.fabricPlayer.hurtTime > 0
|| player.fabricPlayer.isPassenger() || player.fabricPlayer.isAutoSpinAttack()
|| player.fabricPlayer.isSwimming() || player.fabricPlayer.isSleeping()
|| player.fabricPlayer.onClimbable() || player.fabricPlayer.hurtTime > 0
|| !BlockUtils.isFullBlock(player.fabricPlayer.getBlockStateOn())
|| IGNORED_BLOCKS.stream().anyMatch(block -> block.isInstance(player.fabricPlayer.getBlockStateOn().getBlock()))
) return false;
Expand Down
58 changes: 58 additions & 0 deletions src/main/java/top/infsky/cheatdetector/impl/checks/ReachA.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package top.infsky.cheatdetector.impl.checks;

import net.minecraft.world.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import top.infsky.cheatdetector.config.AdvancedConfig;
import top.infsky.cheatdetector.config.AntiCheatConfig;
import top.infsky.cheatdetector.impl.Check;
import top.infsky.cheatdetector.impl.utils.world.LevelUtils;
import top.infsky.cheatdetector.utils.TRPlayer;

import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;

public class ReachA extends Check {
private boolean lastSwing = false;
public ReachA(@NotNull TRPlayer player) {
super("ReachA", player);
}

@Override
public void _onTick() {
boolean currentSwing = player.fabricPlayer.swinging;

if (currentSwing && !lastSwing) { // 第1个挥手tick
onSwing();
}
lastSwing = currentSwing;
}

private void onSwing() {
if (isDisabled()) return;

player.timeTask.schedule(() -> {
try {
LivingEntity possibleTarget = LevelUtils.getEntities().stream()
.filter(entity -> !entity.is(player.fabricPlayer))
.filter(entity -> entity.hurtTime >= 10 - AdvancedConfig.reachACheckDelay)
.min((e1, e2) -> (int) ((e1.distanceTo(player.fabricPlayer) - e2.distanceTo(player.fabricPlayer)) * 100))
.orElseThrow();
double distance = possibleTarget.distanceTo(player.fabricPlayer);
if (distance < 6 && distance > AdvancedConfig.reachADefaultReach) { // 满足标记条件
flag("distance: %.2f".formatted(distance));
}
} catch (NoSuchElementException ignored) {}
}, AdvancedConfig.reachACheckDelay * 50L, TimeUnit.MILLISECONDS);

}

@Override
public int getAlertBuffer() {
return AdvancedConfig.reachAAlertBuffer;
}

@Override
public boolean isDisabled() {
return !AdvancedConfig.reachACheck || !AntiCheatConfig.experimentalCheck;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import top.infsky.cheatdetector.utils.TRSelf;

public class ServerFreeze extends Fix {
private long lastReceiveTime = -1;
private long lastReceiveTime = Long.MAX_VALUE;
private int pingRequest = 0;

public ServerFreeze(@NotNull TRSelf player) {
Expand All @@ -30,15 +30,16 @@ public void _onTick() {
return;
}

if (player.upTime - lastReceiveTime > Advanced2Config.serverFreezeMaxTicks) {
long current = System.currentTimeMillis();
if (current - lastReceiveTime > Advanced2Config.serverFreezeMaxMs) {
if (Advanced2Config.serverFreezeAutoDisableCheck)
CheatDetector.manager.getDataMap().forEach((uuid, player1) -> player1.manager.disableTick = 10);
if (Advanced2Config.serverFreezeAlert) {
TRPlayer.CLIENT.gui.setOverlayMessage(
Component.literal(Component.translatable("cheatdetector.overlay.alert.serverFreezeAlert")
.withStyle(ChatFormatting.DARK_RED)
.getString()
.formatted((player.upTime - lastReceiveTime) * 50)),
.formatted(current - lastReceiveTime)),
false);
}
}
Expand All @@ -51,12 +52,13 @@ public void _onTick() {

@Override
public boolean _onPacketReceive(@NotNull Packet<ClientGamePacketListener> basePacket, Connection connection, ChannelHandlerContext channelHandlerContext, CallbackInfo ci) {
if (player.upTime - lastReceiveTime > Advanced2Config.serverFreezeMaxTicks) {
long current = System.currentTimeMillis();
if (current - lastReceiveTime > Advanced2Config.serverFreezeMaxMs) {
customMsg(Component.translatable("cheatdetector.chat.alert.freezeDetected").getString()
+ ChatFormatting.DARK_GRAY + (player.upTime - lastReceiveTime) * 50 + "ms");
+ ChatFormatting.DARK_RED + (current - lastReceiveTime) + "ms");
}

lastReceiveTime = player.upTime;
lastReceiveTime = current;
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public void _onTick() {
if (isDisabled()) return;

double distance = Advanced3Config.aimAssistRange;
Entity target = null;
for (Entity entity : LevelUtils.getClientLevel().entitiesForRendering()) {
LivingEntity target = null;
for (LivingEntity entity : LevelUtils.getEntities()) {
if (checkTarget(entity) && distance > entity.distanceTo(player.fabricPlayer)) {
target = entity;
distance = entity.distanceTo(player.fabricPlayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public boolean _onPacketReceive(@NotNull Packet<ClientGamePacketListener> basePa
if (state == State.AFTER_FLYING
&& new Vec3(packet.getX(), packet.getY(), packet.getZ()).distanceTo(doneFlyingPos) < Advanced3Config.flyAcceptTeleportMaxDistance) {
TRPlayer.CLIENT.options.keyShift.setDown(false);
TRPlayer.CLIENT.options.keyUp.setDown(false);
state = State.NONE;
CheatDetector.CONFIG_HANDLER.configManager.setValue("flyEnabled", false);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import top.infsky.cheatdetector.config.Advanced3Config;
import top.infsky.cheatdetector.config.DangerConfig;
import top.infsky.cheatdetector.impl.Module;
import top.infsky.cheatdetector.utils.TRPlayer;
import top.infsky.cheatdetector.impl.utils.world.PlayerMove;
import top.infsky.cheatdetector.utils.TRSelf;

public class SlowMotion extends Module {
Expand Down Expand Up @@ -44,7 +44,7 @@ public void _onTick() {
}

if (Advanced3Config.slowMotionFastStop) {
if (!isMove()) {
if (!PlayerMove.isMove()) {
futureMotion = new Vec3(0, futureMotion.y(), 0);
}
}
Expand All @@ -54,13 +54,6 @@ public void _onTick() {
lastEnabled = true;
}

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

private double addToZero(double num, double offset) {
if (num < 0) {
if (num + offset >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import top.infsky.cheatdetector.CheatDetector;
import top.infsky.cheatdetector.config.Advanced3Config;
import top.infsky.cheatdetector.config.ModuleConfig;
import top.infsky.cheatdetector.impl.Module;
Expand All @@ -29,6 +30,7 @@ public class AntiBot extends Module {

@Getter
private static List<UUID> botList = new LinkedList<>();
private boolean disableCheck = true;

public AntiBot(@NotNull TRSelf player) {
super("AntiBot", player);
Expand All @@ -41,6 +43,10 @@ public void _onTick() {
if (isDisabled()) {
botList.clear();
}

if (disableCheck) {
CheatDetector.manager.getDataMap().values().forEach(trPlayer -> trPlayer.manager.disableTick = 10);
}
}

@Override
Expand Down Expand Up @@ -75,6 +81,7 @@ public boolean _onPacketReceive(@NotNull Packet<ClientGamePacketListener> basePa
});

players.forEach(this::addBotVisual);
disableCheck = false;
}
}
} catch (Exception ignored) {} // 我不知道为什么,但是bug修复了!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import top.infsky.cheatdetector.utils.TRSelf;

import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;

public class AutoCatch extends Module {
@Getter
Expand Down Expand Up @@ -75,7 +76,12 @@ private void doCatch() {

player.fabricPlayer.setSilent(false);
player.fabricPlayer.connection.send(ServerboundInteractPacket.createInteractionPacket(target, false, InteractionHand.MAIN_HAND, player.fabricPlayer.position()));
player.fabricPlayer.swing(InteractionHand.MAIN_HAND);

if (Advanced3Config.autoCatchExtraPost) {
for (int i = Advanced3Config.autoCatchExtraPostDelayMs; i < 49; i += Advanced3Config.autoCatchExtraPostDelayMs - 1) {
player.timeTask.schedule(this::doCatch, i, TimeUnit.MILLISECONDS);
}
}
} catch (NoSuchElementException | NullPointerException e) {
target = null;
}
Expand Down
Loading

0 comments on commit 47b707f

Please sign in to comment.