Skip to content

Commit

Permalink
Release 2.10.4
Browse files Browse the repository at this point in the history
- 新检查 AimB
    - 检查阶段性的瞄准
- 新检查 ScaffoldA
    - 检查搭路时的挥手
- 新指令 /ctr surround <name>
- 新模块 Surround 方块包围
    - 用方块把别人包起来!
- 修复一些误判
xia-mc committed Jun 2, 2024
1 parent e98d320 commit 10b10cf
Showing 28 changed files with 274 additions and 69 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ minecraft_version=1.20.1
loader_version=0.14.23

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

Original file line number Diff line number Diff line change
@@ -47,6 +47,11 @@ public static void register(@NotNull CommandDispatcher<FabricClientCommandSource
.then(argument("name", StringArgumentType.string())
.executes(DebugCommand::execute))
)
.then(literal("surround")
.executes(SurroundCommand::execute)
.then(argument("name", StringArgumentType.string())
.executes(SurroundCommand::execute))
)
);
}
}
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
import top.infsky.cheatdetector.CheatDetector;
import top.infsky.cheatdetector.impl.utils.ListUtils;

import java.util.NoSuchElementException;

@@ -14,13 +13,14 @@ public static int execute(@NotNull CommandContext<FabricClientCommandSource> con
String name = context.getArgument("name", String.class);

try {
context.getSource().sendFeedback(Component.literal(ListUtils.getSpilt(
context.getSource().sendFeedback(Component.literal("slot: %s".formatted(
CheatDetector.manager.getDataMap().values()
.stream()
.filter(trPlayer -> trPlayer.fabricPlayer.getName().getString().endsWith(name))
.findAny()
.orElseThrow()
.motionHistory)));
.stream()
.filter(trPlayer -> trPlayer.fabricPlayer.getName().getString().endsWith(name))
.findAny()
.orElseThrow()
.fabricPlayer.getInventory().selected))
);
return 1;
} catch (NoSuchElementException e) {
return 0;
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ public class HelpCommand {
§r/ctr clientspoof <brand> §f- §7设置客户端伪装名§r
§r/ctr writer <part> §f- §7写一本书。§r
§r/ctr catch <name> §f- §7设置自动骑上一名玩家。§r
§r/ctr surround <name> §f- §7设置自动用方块自动包围一名玩家。§r
""";

public static int execute(@NotNull CommandContext<FabricClientCommandSource> context) {
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package top.infsky.cheatdetector.commands;

import com.mojang.brigadier.context.CommandContext;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.ChatFormatting;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.NotNull;
import top.infsky.cheatdetector.CheatDetector;
import top.infsky.cheatdetector.config.Advanced3Config;
import top.infsky.cheatdetector.utils.LogUtils;
import top.infsky.cheatdetector.utils.TRPlayer;

public class SurroundCommand {
public static int execute(@NotNull CommandContext<FabricClientCommandSource> context) {
String name;

try {
name = context.getArgument("name", String.class);
} catch (IllegalArgumentException e) {
if (TRPlayer.CLIENT.crosshairPickEntity instanceof Player target) {
name = target.getName().getString();
} else {
name = Advanced3Config.surroundName;
}
}

if (CheatDetector.CONFIG_HANDLER.configManager.setValue("surroundName", name)) {
LogUtils.custom(ChatFormatting.GREEN + "已设置: " + ChatFormatting.WHITE + name);
return 1;
} else {
return -1;
}
}
}
Original file line number Diff line number Diff line change
@@ -359,6 +359,8 @@ public class Advanced3Config {
@Numeric(minValue = 0, maxValue = 20)
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static int surroundPlaceDelay = 0;
@Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class)
public static boolean surroundSmartPlaceDelay = true;

@Config(category = ConfigCategory.ADVANCED3)
public static double debugDouble = 0.0;
54 changes: 27 additions & 27 deletions src/main/java/top/infsky/cheatdetector/config/AdvancedConfig.java
Original file line number Diff line number Diff line change
@@ -31,22 +31,6 @@ public class AdvancedConfig {
@Config(category = ConfigCategory.ADVANCED)
public static int noSlowAAlertBuffer = 20;
@Config(category = ConfigCategory.ADVANCED)
public static double noSlowASpeedTick1 = 2.56;
@Config(category = ConfigCategory.ADVANCED)
public static double noSlowASpeedTick2 = 1.92;
@Config(category = ConfigCategory.ADVANCED)
public static double noSlowASpeedTick3 = 1.6;
@Config(category = ConfigCategory.ADVANCED)
public static double noSlowASpeedTick4 = 1.4;
@Config(category = ConfigCategory.ADVANCED)
public static double noSlowASpeedTick5 = 1.36;
@Config(category = ConfigCategory.ADVANCED)
public static double noSlowASpeedTick6 = 1.26;
@Config(category = ConfigCategory.ADVANCED)
public static double noSlowASpeedTick7 = 1.18;
@Config(category = ConfigCategory.ADVANCED)
public static double noSlowASpeedTick8 = 1.16;
@Config(category = ConfigCategory.ADVANCED)
public static int noSlowAInJumpDisableTick = 4;


@@ -143,7 +127,7 @@ public class AdvancedConfig {
public static int autoClickerAMinDiffMs = 5;

@Config(category = ConfigCategory.ADVANCED)
public static boolean flyCCheck = false;
public static boolean flyCCheck = true;
@Config(category = ConfigCategory.ADVANCED)
public static int flyCAlertBuffer = 30;
@Config(category = ConfigCategory.ADVANCED)
@@ -175,25 +159,41 @@ public class AdvancedConfig {
@Config(category = ConfigCategory.ADVANCED)
public static int invalidPitchAlertBuffer = 1;

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

@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static boolean scaffoldACheck = false;
@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static int scaffoldAAlertBuffer = 30;

@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static boolean aimBCheck = true;
@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static int aimBAlertBuffer = 10;
@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static double aimBMinDiffYaw = 2;
@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static double aimBMinDiffPitch = 2;

public static short getNoSlowAInJumpDisableTick() {
return (short) noSlowAInJumpDisableTick;
}
6 changes: 4 additions & 2 deletions src/main/java/top/infsky/cheatdetector/impl/Check.java
Original file line number Diff line number Diff line change
@@ -3,11 +3,13 @@
import io.netty.channel.ChannelHandlerContext;
import lombok.Getter;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.Connection;
import net.minecraft.network.PacketSendListener;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ServerGamePacketListener;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -70,6 +72,6 @@ public void _onGameTypeChange() {}
public boolean _handleStopDestroyBlock(CallbackInfo ci) { return false; }
public boolean _onPacketSend(@NotNull Packet<ServerGamePacketListener> basePacket, Connection connection, PacketSendListener listener, CallbackInfo ci) { return false; }
public boolean _onPacketReceive(@NotNull Packet<ClientGamePacketListener> basePacket, Connection connection, ChannelHandlerContext channelHandlerContext, CallbackInfo ci) { return false; }
public void _handleAttack(Entity entity) {
}
public void _handleAttack(Entity entity) {}
public void _onPlaceBlock(InteractionHand hand, BlockPos blockPos) {}
}
18 changes: 13 additions & 5 deletions src/main/java/top/infsky/cheatdetector/impl/checks/aim/AimA.java
Original file line number Diff line number Diff line change
@@ -4,11 +4,15 @@
import net.minecraft.world.entity.player.Player;
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.impl.utils.world.PlayerMove;
import top.infsky.cheatdetector.impl.utils.world.PlayerRotation;
import top.infsky.cheatdetector.utils.TRPlayer;

import java.util.List;

public class AimA extends Check {
public AimA(@NotNull TRPlayer player) {
super("AimA", player);
@@ -24,15 +28,19 @@ public void _onTick() {

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

List<LivingEntity> possibleTargets = LevelUtils.getEntities().stream()
.filter(entity -> !AdvancedConfig.aimAOnlyPlayer || entity instanceof Player)
.filter(entity -> !entity.is(player.fabricPlayer))
.filter(entity -> !AdvancedConfig.aimAOnlyIfTargetIsMoving || !PlayerMove.isNoMove(entity.getDeltaMovement()))
.filter(entity -> entity.distanceTo(player.fabricPlayer) <= AdvancedConfig.aimAMaxDistance)
.toList();

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;

for (LivingEntity entity : possibleTargets) {
diffYaw = Math.abs(PlayerRotation.getYaw(entity.getEyePosition()) - entity.getYRot());
diffPitch = Math.abs(PlayerRotation.getPitch(entity.getEyePosition()) - entity.getXRot());

@@ -67,6 +75,6 @@ public int getAlertBuffer() {

@Override
public boolean isDisabled() {
return !AdvancedConfig.aimACheck;
return !AdvancedConfig.aimACheck || !AntiCheatConfig.experimentalCheck;
}
}
52 changes: 52 additions & 0 deletions src/main/java/top/infsky/cheatdetector/impl/checks/aim/AimB.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package top.infsky.cheatdetector.impl.checks.aim;

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.utils.TRPlayer;

import java.util.Set;

public class AimB extends Check {
public static final Set<Integer> STEP = Set.of(25, 40, 45, 60, 90, 120, 135, 180);
public AimB(@NotNull TRPlayer player) {
super("AimB", player);
}

@Override
public void _onTick() {
boolean flagPitch = false;
boolean flagYaw = false;
float stepPitch = 0, stepYaw = 0;
for (int step : STEP) {
if (Math.abs(player.lastRot.x - player.currentRot.x) - step < AdvancedConfig.aimBMinDiffPitch) {
flagPitch = true;
stepPitch = player.lastRot.x - player.currentRot.x;
}
if (Math.abs(player.lastRot.y - player.currentRot.y) - step < AdvancedConfig.aimBMinDiffYaw) {
flagYaw = true;
stepYaw = player.lastRot.y - player.currentRot.y;
}
if (flagPitch && flagYaw) break;
}

if (flagPitch && flagYaw) {
flag("perfect step aim. deltaYaw: %.1f deltaPitch: %.1f".formatted(stepYaw, stepPitch));
} else if (flagPitch) {
flag("perfect pitch step aim. deltaPitch: %.1f".formatted(stepPitch));
} else if (flagYaw) {
flag("perfect pitch step aim. deltaYaw: %.1f".formatted(stepYaw));
}
}

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

@Override
public boolean isDisabled() {
return !AdvancedConfig.aimBCheck || !AntiCheatConfig.experimentalCheck;
}
}
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ public InvalidPitch(@NotNull TRPlayer player) {
@Override
public void _onTick() {
if (player.currentRot.x > 90 || player.currentRot.x < -90) {
flag();
flag("pitch: %.2f".formatted(player.currentRot.x));
}
}

Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
import top.infsky.cheatdetector.impl.Check;
import top.infsky.cheatdetector.impl.utils.world.BlockUtils;
import top.infsky.cheatdetector.impl.utils.world.LevelUtils;
import top.infsky.cheatdetector.impl.utils.world.RayCastUtils;
import top.infsky.cheatdetector.utils.TRPlayer;

import java.util.NoSuchElementException;
@@ -45,12 +46,10 @@ private void onSwing() {
.orElseThrow();

// 此时至少有任何一个可能的目标被命中,那么检查是否击中墙壁
HitResult hitResult = player.fabricPlayer.pick(player.fabricPlayer.distanceTo(target), 0, false);
BlockHitResult hitResult = RayCastUtils.blockRayCast(player.fabricPlayer, LevelUtils.getClientLevel(), player.fabricPlayer.distanceTo(target));

if (hitResult instanceof BlockHitResult blockHitResult) {
if (blockHitResult.getType() != HitResult.Type.MISS && BlockUtils.isFullBlock(level.getBlockState(blockHitResult.getBlockPos()))) {
flag("Impossible hit.");
}
if (hitResult.getType() != HitResult.Type.MISS && BlockUtils.isFullBlock(LevelUtils.getClientLevel().getBlockState(hitResult.getBlockPos()))) {
flag("Impossible hit.");
}
} catch (NoSuchElementException ignored) {}
}, AdvancedConfig.hitBoxACheckDelay * 50L, TimeUnit.MILLISECONDS);
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ public void _onTick() {
return;
}

if (player.currentVehicleMotion.y() >= 0) {
if (player.currentVehicleMotion.y() >= 0.01) {
flag("Invalid boat Y-motion: %s inWater=%s onGround=%s".formatted(player.currentVehicleMotion.y(), boat.isInWater(), boat.onGround()));
}
}
Original file line number Diff line number Diff line change
@@ -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, Blocks.SLIME_BLOCK, Blocks.SOUL_SAND);
public static final List<Block> IGNORED_BLOCKS = List.of(Blocks.COBWEB, Blocks.WATER, Blocks.LAVA, Blocks.POWDER_SNOW, Blocks.SLIME_BLOCK, Blocks.SOUL_SAND, Blocks.SCAFFOLDING);
public FlyC(@NotNull TRPlayer player) {
super("FlyC", player);
}
Original file line number Diff line number Diff line change
@@ -13,14 +13,14 @@

public class NoSlowA extends Check {
public static final List<Double> SLOW_SPEED = List.of(
AdvancedConfig.noSlowASpeedTick1,
AdvancedConfig.noSlowASpeedTick2,
AdvancedConfig.noSlowASpeedTick3,
AdvancedConfig.noSlowASpeedTick4,
AdvancedConfig.noSlowASpeedTick5,
AdvancedConfig.noSlowASpeedTick6,
AdvancedConfig.noSlowASpeedTick7,
AdvancedConfig.noSlowASpeedTick8
2.56,
1.92,
1.6,
1.4,
1.36,
1.26,
1.18,
1.16
);
public short itemUseTick = 0;
public short disableTick = 0; // 跳跃弱检测
Original file line number Diff line number Diff line change
@@ -20,7 +20,8 @@ public StrafeA(@NotNull TRPlayer player) {

@Override
public void _onTick() {
if (player.currentOnGround || PlayerMove.isNoMove(player.currentMotion) || Math.abs(player.lastRot.y - player.currentRot.y) < 5 || player.fabricPlayer.isFallFlying()) {
if (player.currentOnGround || PlayerMove.isNoMove(player.currentMotion) || Math.abs(player.lastRot.y - player.currentRot.y) < 5
|| player.fabricPlayer.isFallFlying() || player.fabricPlayer.isPassenger()) {
futureMotion = null;
return;
}
Loading

0 comments on commit 10b10cf

Please sign in to comment.