Skip to content

Commit

Permalink
Release 2.10.3
Browse files Browse the repository at this point in the history
- 新检查 AimA
    - 简单的检查玩家瞄准
- 新检查 InvalidPitch
    - 检查玩家的头部旋转是否正确
- 新检查 *TimerA*
    - 简单的检查过快的游戏速度(数据包层面)
- 新模块 Surround 方块包围
    - 用方块把别人包起来!
- 改进 AntiBot Latency模式
- 改进 ServerFreeze
    - 如果你安装了Minihud,那么ServerFreeze会额外增加低TPS关闭检查的选项
- 改进 StrafeA
- 修复一些误判
  • Loading branch information
xia-mc committed May 31, 2024
1 parent 17a3d16 commit e98d320
Show file tree
Hide file tree
Showing 31 changed files with 518 additions and 116 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies {
exclude(group: "carpet", module: "fabric-carpet")
}
modImplementation("maven.modrinth:replaymod:${project.minecraft_version}-${project.replaymod_version}")
modImplementation("curse.maven:minihud-244260:${project.minihud_fileId}") // minihud-fabric-1.20.1-0.27.0

// modApi "com.terraformersmc:modmenu:${project.modmenu_version}"

Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ minecraft_version=1.20.1
loader_version=0.14.23

# Mod Properties
mod_version = 2.10.2
mod_version = 2.10.3
maven_group = top.infsky
archives_base_name = CheatDetector

# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.91.0+1.20.1
magiclib_version=0.7.398
replaymod_version=2.6.15
replaymod_version=2.6.15
minihud_fileId=4593082
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package top.infsky.cheatdetector.compat;

import fi.dy.masa.minihud.util.DataStorage;

public class MinihudHelper {
public static double getServerTPS() {
return DataStorage.getInstance().getServerTPS();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import top.hendrixshen.magiclib.malilib.api.annotation.Config;
import top.hendrixshen.magiclib.malilib.api.annotation.Numeric;
import top.infsky.cheatdetector.config.utils.ConfigCategory;
import top.infsky.cheatdetector.config.utils.ConfigPredicate;

public class Advanced2Config {
@Config(category = ConfigCategory.ADVANCED2)
Expand Down Expand Up @@ -33,6 +34,11 @@ public class Advanced2Config {
@Numeric(minValue = 0, maxValue = 30000)
@Config(category = ConfigCategory.ADVANCED2)
public static int serverFreezeMaxMs = 800;
@Numeric(minValue = 0, maxValue = 20)
@Config(category = ConfigCategory.ADVANCED2, predicate = ConfigPredicate.MiniHudLoaded.class)
public static double serverFreezeMinTPS = 18.0;
@Config(category = ConfigCategory.ADVANCED2, predicate = ConfigPredicate.MiniHudLoaded.class)
public static boolean serverFreezeAlertTPS = true;
@Config(category = ConfigCategory.ADVANCED2)
public static boolean serverFreezeAutoDisableCheck = true;
@Config(category = ConfigCategory.ADVANCED2)
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/top/infsky/cheatdetector/config/Advanced3Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,28 @@ public class Advanced3Config {
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean noStopBreakSilent = false;

@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static String surroundName = "";
@Numeric(minValue = 0, maxValue = 8)
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static double surroundDistance = 8;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean surroundAutoSwitch = true;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean surroundAutoSwitchBack = true;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean surroundDoRotation = false;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean surroundSilentRotation = true;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean surroundSwing = false;
@Numeric(minValue = 0, maxValue = 20)
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static int surroundPlaceDelay = 0;

@Config(category = ConfigCategory.ADVANCED3)
public static double debugDouble = 0.0;

public static NotebotUtils.NotebotMode getNoteBotMode() {
if (noteBotMode.equals("AnyInstrument")) {
return NotebotUtils.NotebotMode.AnyInstrument;
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/top/infsky/cheatdetector/config/AdvancedConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,39 @@ public class AdvancedConfig {
@Config(category = ConfigCategory.ADVANCED)
public static double strafeAMaxDiffToFlag = 0.005;

@Config(category = ConfigCategory.ADVANCED)
public static boolean timerACheck = true;
@Config(category = ConfigCategory.ADVANCED)
public static int timerAAlertBuffer = 20;
@Config(category = ConfigCategory.ADVANCED)
public static int timerADefaultBalance = -300;
@Config(category = ConfigCategory.ADVANCED)
public static int timerAFlagBalance = 100;

@Config(category = ConfigCategory.ADVANCED)
public static boolean invalidPitchCheck = true;
@Config(category = ConfigCategory.ADVANCED)
public static int invalidPitchAlertBuffer = 1;

@Config(category = ConfigCategory.ADVANCED)
public static boolean aimACheck = true;
@Config(category = ConfigCategory.ADVANCED)
public static int aimAAlertBuffer = 30;
@Config(category = ConfigCategory.ADVANCED)
public static boolean aimAOnlyOnSwing = true;
@Config(category = ConfigCategory.ADVANCED)
public static boolean aimAOnlyPlayer = false;
@Config(category = ConfigCategory.ADVANCED)
public static double aimAMinDiffYaw = 2;
@Config(category = ConfigCategory.ADVANCED)
public static double aimAMinDeltaYaw = 2;
@Config(category = ConfigCategory.ADVANCED)
public static double aimAMinDiffPitch = 2;
@Config(category = ConfigCategory.ADVANCED)
public static double aimAMinDeltaPitch = 2;
@Config(category = ConfigCategory.ADVANCED)
public static double aimAMaxDistance = 6;

public static short getNoSlowAInJumpDisableTick() {
return (short) noSlowAInJumpDisableTick;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,8 @@ public class ModuleConfig {
@Hotkey
@Config(category = ConfigCategory.MODULES)
public static boolean noStopBreakEnabled = false;

@Hotkey
@Config(category = ConfigCategory.MODULES, predicate = ConfigPredicate.PASMode.class)
public static boolean surroundEnabled = false;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package top.infsky.cheatdetector.config.utils;

import net.fabricmc.loader.api.FabricLoader;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import top.hendrixshen.magiclib.dependency.api.ConfigDependencyPredicate;
Expand All @@ -17,6 +18,14 @@ public static void onJoinWorld(String ip, @NotNull ConfigManager configManager)
configManager.setValue("aaaPASModeEnabled", PASMode.getIpAddresses().contains(ip));
}

public static class MiniHudLoaded implements ConfigDependencyPredicate {
@Override
public boolean isSatisfied(ConfigOption option) {
return FabricLoader.getInstance().isModLoaded("minihud");
}

}

public static class ExperimentalMode implements ConfigDependencyPredicate {
@Override
public boolean isSatisfied(ConfigOption option) {
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/top/infsky/cheatdetector/impl/checks/aim/AimA.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package top.infsky.cheatdetector.impl.checks.aim;

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

public class AimA extends Check {
public AimA(@NotNull TRPlayer player) {
super("AimA", player);
}

@Override
public void _onTick() {
if (player.currentRot.equals(player.lastRot)) return;
if (AdvancedConfig.aimAOnlyOnSwing && !(!player.lastSwing && player.currentSwing)) return;

float deltaYaw = player.currentRot.y - player.lastRot.y;
float deltaPitch = player.currentRot.x - player.lastRot.x;

if (deltaYaw < AdvancedConfig.aimAMinDeltaYaw || deltaPitch < AdvancedConfig.aimAMinDeltaPitch) return;

double diffYaw = 0;
double diffPitch = 0;
boolean flagYaw = false;
boolean flagPitch = false;
LivingEntity flagTarget = null;
for (LivingEntity entity : LevelUtils.getEntities().stream().filter(entity -> entity.distanceTo(player.fabricPlayer) <= AdvancedConfig.aimAMaxDistance).toList()) {
if (AdvancedConfig.aimAOnlyPlayer && entity instanceof Player) continue;
if (entity.equals(player.fabricPlayer)) continue;

diffYaw = Math.abs(PlayerRotation.getYaw(entity.getEyePosition()) - entity.getYRot());
diffPitch = Math.abs(PlayerRotation.getPitch(entity.getEyePosition()) - entity.getXRot());

flagYaw = diffYaw < AdvancedConfig.aimAMinDiffYaw;
flagPitch = diffPitch < AdvancedConfig.aimAMinDiffPitch;

if (flagPitch || flagYaw) {
flagTarget = entity;
break;
}
}

if (flagYaw && flagPitch) {
flag("Too small deviation. target: %s diff: %.2f,%.2f delta: %.2f,%.2f".formatted(
flagTarget.getName().getString(), diffYaw, diffPitch, deltaYaw, deltaPitch)
);
} else if (flagYaw) {
flag("Too small yaw deviation. target: %s diff: %.2f delta: %.2f".formatted(
flagTarget.getName().getString(), diffYaw, deltaYaw)
);
} else if (flagPitch) {
flag("Too small pitch deviation. target: %s diff: %.2f delta: %.2f".formatted(
flagTarget.getName().getString(), diffPitch, deltaPitch)
);
}
}

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

@Override
public boolean isDisabled() {
return !AdvancedConfig.aimACheck;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package top.infsky.cheatdetector.impl.checks.aim;

import org.jetbrains.annotations.NotNull;
import top.infsky.cheatdetector.config.AdvancedConfig;
import top.infsky.cheatdetector.impl.Check;
import top.infsky.cheatdetector.utils.TRPlayer;

public class InvalidPitch extends Check {
public InvalidPitch(@NotNull TRPlayer player) {
super("InvalidPitch", player);
}

@Override
public void _onTick() {
if (player.currentRot.x > 90 || player.currentRot.x < -90) {
flag();
}
}

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

@Override
public boolean isDisabled() {
return !AdvancedConfig.invalidPitchCheck;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@
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
if (player.currentSwing && !player.lastSwing) { // 第1个挥手tick
onSwing();
}
lastSwing = currentSwing;
}

private void onSwing() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package top.infsky.cheatdetector.impl.checks.exploits;

import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import top.infsky.cheatdetector.config.AdvancedConfig;
import top.infsky.cheatdetector.impl.Check;
import top.infsky.cheatdetector.impl.utils.world.LevelUtils;
import top.infsky.cheatdetector.utils.TRPlayer;

import java.util.Objects;

public class TimerA extends Check {
private long balance;
public TimerA(@NotNull TRPlayer player) {
super("*TimerA*", player);
balance = AdvancedConfig.timerADefaultBalance;
}

@Override
public void _onTick() {
balance -= 50;
}

@Override
public boolean _onPacketReceive(@NotNull Packet<ClientGamePacketListener> basePacket, Connection connection, ChannelHandlerContext channelHandlerContext, CallbackInfo ci) {
if (basePacket instanceof ClientboundMoveEntityPacket packet) {
try {
if (!Objects.requireNonNull(packet.getEntity(LevelUtils.getClientLevel())).is(player.fabricPlayer)) return false;
} catch (NullPointerException e) {
return false;
}

balance += 50;

if (balance >= AdvancedConfig.timerAFlagBalance) {
flag();
balance -= 50; // 标记后应该忽略这个违规包
}
}
return false;
}

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

@Override
public boolean isDisabled() {
return !AdvancedConfig.timerACheck;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.List;

public class FlyC extends Check {
public static final List<Block> IGNORED_BLOCKS = List.of(Blocks.COBWEB, Blocks.WATER, Blocks.LAVA, Blocks.POWDER_SNOW);
public static final List<Block> IGNORED_BLOCKS = List.of(Blocks.COBWEB, Blocks.WATER, Blocks.LAVA, Blocks.POWDER_SNOW, Blocks.SLIME_BLOCK, Blocks.SOUL_SAND);
public FlyC(@NotNull TRPlayer player) {
super("FlyC", player);
}
Expand Down
Loading

0 comments on commit e98d320

Please sign in to comment.