diff --git a/gradle.properties b/gradle.properties index 3cb2742..b6abbdf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ minecraft_version=1.20.1 loader_version=0.14.23 # Mod Properties -mod_version = 2.9.2 +mod_version = 2.9.3 maven_group = top.infsky archives_base_name = CheatDetector diff --git a/src/main/java/top/infsky/cheatdetector/config/Advanced3Config.java b/src/main/java/top/infsky/cheatdetector/config/Advanced3Config.java index b6e11ff..c953b84 100644 --- a/src/main/java/top/infsky/cheatdetector/config/Advanced3Config.java +++ b/src/main/java/top/infsky/cheatdetector/config/Advanced3Config.java @@ -294,7 +294,7 @@ public class Advanced3Config { @Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class) public static String autoCatchName = ""; - @Numeric(minValue = 0, maxValue = 100) + @Numeric(minValue = 0, maxValue = 6) @Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class) public static double autoCatchDistance = 6; @Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class) @@ -304,7 +304,9 @@ public class Advanced3Config { @Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class) public static boolean autoCatchAsPossible = false; @Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class) - public static double autoCatchAsPossibleTeleportDistance = 10; + public static boolean autoCatchResetMotion = false; + @Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class) + public static double autoCatchAsPossibleTeleportDistance = 6; @Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class) public static boolean autoCatchRotate = false; @Config(category = ConfigCategory.ADVANCED3, predicate = ConfigPredicate.PASMode.class) diff --git a/src/main/java/top/infsky/cheatdetector/config/AdvancedConfig.java b/src/main/java/top/infsky/cheatdetector/config/AdvancedConfig.java index 222ea78..2e933b8 100644 --- a/src/main/java/top/infsky/cheatdetector/config/AdvancedConfig.java +++ b/src/main/java/top/infsky/cheatdetector/config/AdvancedConfig.java @@ -13,7 +13,7 @@ public class AdvancedConfig { @Config(category = ConfigCategory.ADVANCED) - public static boolean flyACheck = false; + public static boolean flyACheck = true; @Config(category = ConfigCategory.ADVANCED) public static int flyAlertBuffer = 20; @Config(category = ConfigCategory.ADVANCED) @@ -26,9 +26,6 @@ public class AdvancedConfig { public static double flyAFromWaterYDistance = 0.5; @Config(category = ConfigCategory.ADVANCED) public static int flyAOnTeleportDisableTick = 2; - @Config(category = ConfigCategory.ADVANCED) - public static int flyAOnJumpJumpTick = 24; - @Config(category = ConfigCategory.ADVANCED) public static boolean flyBCheck = true; @@ -43,7 +40,7 @@ public class AdvancedConfig { @Config(category = ConfigCategory.ADVANCED) - public static boolean highJumpACheck = true; + public static boolean highJumpACheck = false; @Config(category = ConfigCategory.ADVANCED) public static int highJumpAAlertBuffer = 5; @Config(category = ConfigCategory.ADVANCED) @@ -109,6 +106,7 @@ public class AdvancedConfig { public static boolean groundSpoofACheck = true; @Config(category = ConfigCategory.ADVANCED) public static int groundSpoofAAlertBuffer = 6; + @Config(category = ConfigCategory.ADVANCED) public static boolean groundSpoofBCheck = true; @Config(category = ConfigCategory.ADVANCED) @@ -125,7 +123,7 @@ public class AdvancedConfig { public static int speedCAlertBuffer = 10; @Config(category = ConfigCategory.ADVANCED) - public static boolean motionACheck = false; + public static boolean motionACheck = true; @Config(category = ConfigCategory.ADVANCED) public static int motionAAlertBuffer = 10; @@ -150,10 +148,6 @@ public static short getFlyAOnTeleportDisableTick() { return (short) flyAOnTeleportDisableTick; } - public static short getFlyAOnJumpJumpTick() { - return (short) flyAOnJumpJumpTick; - } - public static short getNoSlowAInJumpDisableTick() { return (short) noSlowAInJumpDisableTick; } diff --git a/src/main/java/top/infsky/cheatdetector/config/ModuleConfig.java b/src/main/java/top/infsky/cheatdetector/config/ModuleConfig.java index c61ac58..1d772f8 100644 --- a/src/main/java/top/infsky/cheatdetector/config/ModuleConfig.java +++ b/src/main/java/top/infsky/cheatdetector/config/ModuleConfig.java @@ -90,7 +90,7 @@ public class ModuleConfig { @Hotkey @Config(category = ConfigCategory.MODULES) - public static boolean rotationEnabled = false; + public static boolean rotationEnabled = true; @Hotkey @Config(category = ConfigCategory.MODULES) diff --git a/src/main/java/top/infsky/cheatdetector/impl/checks/FlyA.java b/src/main/java/top/infsky/cheatdetector/impl/checks/FlyA.java index 979a281..71727b7 100644 --- a/src/main/java/top/infsky/cheatdetector/impl/checks/FlyA.java +++ b/src/main/java/top/infsky/cheatdetector/impl/checks/FlyA.java @@ -8,6 +8,8 @@ import top.infsky.cheatdetector.config.AdvancedConfig; import top.infsky.cheatdetector.config.AntiCheatConfig; +import java.util.List; + public class FlyA extends Check { public short jumpTick = 0; public short liquidTick = 0; @@ -20,8 +22,8 @@ public FlyA(@NotNull TRPlayer player) { @Override public void _onTick() { if (isDisabled()) return; - if (player.fabricPlayer.getMainHandItem().getItem() instanceof TridentItem - || player.fabricPlayer.getOffhandItem().getItem() instanceof TridentItem) return; + if ((player.fabricPlayer.getMainHandItem().getItem() instanceof TridentItem + || player.fabricPlayer.getOffhandItem().getItem() instanceof TridentItem) && player.fabricPlayer.isUsingItem()) return; if (player.fabricPlayer.isPassenger()) return; if (player.fabricPlayer.isFallFlying()) { jumpTick = Short.MAX_VALUE; @@ -78,8 +80,9 @@ public void _onTeleport() { @Override public void _onJump() { - // fix jump - jumpTick = AdvancedConfig.getFlyAOnJumpJumpTick(); + List motions = MotionA.getPossibleMotions(player); + + jumpTick = motions != null ? (short) motions.size() : Short.MAX_VALUE; } @Override diff --git a/src/main/java/top/infsky/cheatdetector/impl/checks/MotionA.java b/src/main/java/top/infsky/cheatdetector/impl/checks/MotionA.java index 5dc554b..ff21b95 100644 --- a/src/main/java/top/infsky/cheatdetector/impl/checks/MotionA.java +++ b/src/main/java/top/infsky/cheatdetector/impl/checks/MotionA.java @@ -61,7 +61,7 @@ public void _onTick() { } else if (jumpFromY != null) { if (jumpFromY == player.currentPos.y()) { // 满足判断条件 try { - List possibleMotion = Objects.requireNonNull(getPossibleMotions()); + List possibleMotion = Objects.requireNonNull(getPossibleMotions(player)); check: try { @@ -102,7 +102,7 @@ private boolean check() { return !player.fabricPlayer.getAbilities().flying; } - private @Nullable List getPossibleMotions() { + public static @Nullable List getPossibleMotions(@NotNull TRPlayer player) { List result; Map activeEffectsMap = player.fabricPlayer.getActiveEffectsMap(); if (!activeEffectsMap.containsKey(MobEffects.JUMP)) { diff --git a/src/main/java/top/infsky/cheatdetector/impl/fixes/ServerFreeze.java b/src/main/java/top/infsky/cheatdetector/impl/fixes/ServerFreeze.java index 665de21..79d54b0 100644 --- a/src/main/java/top/infsky/cheatdetector/impl/fixes/ServerFreeze.java +++ b/src/main/java/top/infsky/cheatdetector/impl/fixes/ServerFreeze.java @@ -51,6 +51,11 @@ public void _onTick() { @Override public boolean _onPacketReceive(@NotNull Packet basePacket, Connection connection, ChannelHandlerContext channelHandlerContext, CallbackInfo ci) { + if (player.upTime - lastReceiveTime > Advanced2Config.serverFreezeMaxTicks) { + customMsg(Component.translatable("cheatdetector.chat.alert.freezeDetected").getString() + + ChatFormatting.DARK_GRAY + (player.upTime - lastReceiveTime) * 50 + "ms"); + } + lastReceiveTime = player.upTime; return false; } diff --git a/src/main/java/top/infsky/cheatdetector/impl/modules/pas/AntiBot.java b/src/main/java/top/infsky/cheatdetector/impl/modules/pas/AntiBot.java index cf9cfc8..322d278 100644 --- a/src/main/java/top/infsky/cheatdetector/impl/modules/pas/AntiBot.java +++ b/src/main/java/top/infsky/cheatdetector/impl/modules/pas/AntiBot.java @@ -32,7 +32,7 @@ public class AntiBot extends Module { public AntiBot(@NotNull TRSelf player) { super("AntiBot", player); - botList = new LinkedList<>(); + botList.clear(); instance = this; } diff --git a/src/main/java/top/infsky/cheatdetector/impl/modules/pas/AutoCatch.java b/src/main/java/top/infsky/cheatdetector/impl/modules/pas/AutoCatch.java index 0d64ebd..72c7d68 100644 --- a/src/main/java/top/infsky/cheatdetector/impl/modules/pas/AutoCatch.java +++ b/src/main/java/top/infsky/cheatdetector/impl/modules/pas/AutoCatch.java @@ -4,6 +4,7 @@ import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.network.protocol.game.ServerboundInteractPacket; import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.Entity; import net.minecraft.world.item.AirItem; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; @@ -23,6 +24,8 @@ public class AutoCatch extends Module { @Getter @Nullable private static Module instance = null; + @Nullable + private AbstractClientPlayer target; public AutoCatch(@NotNull TRSelf player) { super("AutoCatch", player); instance = this; @@ -30,7 +33,10 @@ public AutoCatch(@NotNull TRSelf player) { @Override public void _onTick() { - if (isDisabled()) return; + if (isDisabled()) { + target = null; + return; + } if (!Advanced3Config.autoCatchAlways && player.fabricPlayer.isPassenger()) return; doCatch(); @@ -38,10 +44,10 @@ public void _onTick() { private void doCatch() { try { - AbstractClientPlayer target = LevelUtils.getClientLevel().players().stream() - .filter(p -> p.getGameProfile().getName().equals(Advanced3Config.autoCatchName)) - .findFirst() - .orElseThrow(); + target = LevelUtils.getClientLevel().players().stream() + .filter(p -> p.getName().getString().endsWith(Advanced3Config.autoCatchName)) + .findAny() + .orElseThrow(); double distance = target.distanceTo(player.fabricPlayer); if (distance > Advanced3Config.autoCatchDistance && !Advanced3Config.autoCatchAsPossible) return; @@ -52,7 +58,9 @@ private void doCatch() { return; } } - player.fabricPlayer.setDeltaMovement(0, 0, 0); + if (Advanced3Config.autoCatchResetMotion) { + player.fabricPlayer.setDeltaMovement(0, 0, 0); + } player.fabricPlayer.getInventory().selected = ContainerUtils.findItem(player.fabricPlayer.getInventory(), AirItem.class, ContainerUtils.SlotType.HOTBAR); if (Advanced3Config.autoCatchRotate) { @@ -68,7 +76,8 @@ 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); - } catch (NoSuchElementException ignored) { + } catch (NoSuchElementException | NullPointerException e) { + target = null; } } @@ -92,11 +101,13 @@ private static double add(double current, double step, double target) { } } - public void onStopRiding() { + public void onStopRiding(Entity entity) { if (isDisabled()) return; if (!Advanced3Config.autoCatchFast) return; - doCatch(); + if (target != null && entity.is(target)) { + doCatch(); + } } @Override diff --git a/src/main/java/top/infsky/cheatdetector/impl/utils/world/LevelUtils.java b/src/main/java/top/infsky/cheatdetector/impl/utils/world/LevelUtils.java index 820f9fc..8e0efea 100644 --- a/src/main/java/top/infsky/cheatdetector/impl/utils/world/LevelUtils.java +++ b/src/main/java/top/infsky/cheatdetector/impl/utils/world/LevelUtils.java @@ -1,15 +1,15 @@ package top.infsky.cheatdetector.impl.utils.world; import net.minecraft.client.multiplayer.ClientLevel; -import top.infsky.cheatdetector.utils.TRPlayer; +import top.infsky.cheatdetector.CheatDetector; -import java.io.IOException; +import java.util.Objects; public class LevelUtils { public static ClientLevel getClientLevel() { - try (ClientLevel level = TRPlayer.CLIENT.level) { - return level; - } catch (IOException e) { + try (ClientLevel level = CheatDetector.CLIENT.level) { + return Objects.requireNonNull(level); + } catch (Exception e) { throw new RuntimeException(e); } } diff --git a/src/main/java/top/infsky/cheatdetector/impl/utils/world/VelocityUtils.java b/src/main/java/top/infsky/cheatdetector/impl/utils/world/VelocityUtils.java index c95786d..6b50af2 100644 --- a/src/main/java/top/infsky/cheatdetector/impl/utils/world/VelocityUtils.java +++ b/src/main/java/top/infsky/cheatdetector/impl/utils/world/VelocityUtils.java @@ -6,13 +6,11 @@ import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.MagmaBlock; +import net.minecraft.world.level.block.Blocks; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import top.infsky.cheatdetector.CheatDetector; import top.infsky.cheatdetector.utils.TRPlayer; -import java.io.IOException; import java.util.List; import java.util.Set; @@ -21,7 +19,7 @@ public class VelocityUtils { Direction.EAST, Direction.WEST, Direction.NORTH, Direction.SOUTH ); public static final List HURT_EFFECTS = List.of( - MobEffects.WITHER, MobEffects.POISON + MobEffects.WITHER, MobEffects.POISON, MobEffects.HARM ); public enum VelocityDirection { @@ -37,12 +35,6 @@ public static boolean shouldCheck(@NotNull TRPlayer player, @Nullable VelocityDi if (player.fabricPlayer.isPassenger()) return false; -// // 下界合金套 -// for (ItemStack itemStack : player.fabricPlayer.getInventory().armor) { -// if (NETHERITE_KITS.contains(itemStack.getItem())) -// return false; -// } - // fire if ((player.fabricPlayer.isOnFire() || player.fabricPlayer.isInLava()) && !hasEffects.contains(MobEffects.FIRE_RESISTANCE)) return false; @@ -61,43 +53,38 @@ public static boolean shouldCheck(@NotNull TRPlayer player, @Nullable VelocityDi return false; } - try (Level level = CheatDetector.CLIENT.level) { - if (level == null) return false; - - // hunger - if (player.fabricPlayer.getFoodData().getFoodLevel() == 0 && level.getDifficulty() == Difficulty.HARD) - return false; + // MagmaBlock + if (player.fabricPlayer.getBlockStateOn().is(Blocks.MAGMA_BLOCK)) + return false; - // MagmaBlock - if (level.getBlockState(player.fabricPlayer.blockPosition().below()).getBlock() instanceof MagmaBlock) - return false; + Level level = LevelUtils.getClientLevel(); + // hunger + if (player.fabricPlayer.getFoodData().getFoodLevel() == 0 && level.getDifficulty() == Difficulty.HARD) + return false; - // has block - if (velocityDirection != null) { - final BlockPos feetBlock = player.fabricPlayer.blockPosition(); - switch (velocityDirection) { - case ALL: { - } - case HORIZON: { - for (Direction direction : HORIZON_DIRECTION) { - if (!level.getBlockState(feetBlock.relative(direction)).isAir()) - return false; - } - if (velocityDirection == VelocityDirection.HORIZON) break; - } - case VERTICAL: { - if (!level.getBlockState(feetBlock.above()).isAir() - || !level.getBlockState(feetBlock).isAir() - || !level.getBlockState(feetBlock.above()).isAir()) { + // has block + if (velocityDirection != null) { + final BlockPos feetBlock = player.fabricPlayer.blockPosition(); + switch (velocityDirection) { + case ALL: { + } + case HORIZON: { + for (Direction direction : HORIZON_DIRECTION) { + if (!level.getBlockState(feetBlock.relative(direction)).isAir()) return false; - } - break; } + if (velocityDirection == VelocityDirection.HORIZON) break; + } + case VERTICAL: { + if (!level.getBlockState(feetBlock.above()).isAir() + || !level.getBlockState(feetBlock).isAir() + || !level.getBlockState(feetBlock.above()).isAir()) { + return false; + } + break; } } - } catch (IOException e) { - throw new RuntimeException(e); } // as default diff --git a/src/main/java/top/infsky/cheatdetector/mixins/MixinEntity.java b/src/main/java/top/infsky/cheatdetector/mixins/MixinEntity.java index b9a6652..bd44b0e 100644 --- a/src/main/java/top/infsky/cheatdetector/mixins/MixinEntity.java +++ b/src/main/java/top/infsky/cheatdetector/mixins/MixinEntity.java @@ -15,7 +15,7 @@ public void stopRiding(CallbackInfo ci) { AutoCatch autoCatch = (AutoCatch) AutoCatch.getInstance(); if (autoCatch != null) { - autoCatch.onStopRiding(); + autoCatch.onStopRiding((Entity) (Object) this); } } } diff --git a/src/main/resources/assets/cheatdetector/lang/en_us.json b/src/main/resources/assets/cheatdetector/lang/en_us.json index 68903ed..bea7aaf 100644 --- a/src/main/resources/assets/cheatdetector/lang/en_us.json +++ b/src/main/resources/assets/cheatdetector/lang/en_us.json @@ -6,6 +6,7 @@ "cheatdetector.chat.alert.creativeFlyWithoutDisabler": "CreativeFly must use with Movement Disabler!", "cheatdetector.chat.alert.fail": "failed", "cheatdetector.chat.alert.flagDetected": "Flag detected: ", + "cheatdetector.chat.alert.freezeDetected": "Freeze detected: ", "cheatdetector.chat.alert.nukerSetBlock": "Set Block Type is %s.", "cheatdetector.chat.alert.startVanish": "%s started vanishing!", "cheatdetector.chat.alert.stopVanish": "%s stopped vanishing.", @@ -157,6 +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.gui.button.tab.advanced": "Advanced AntiCheat", "cheatdetector.gui.button.tab.advanced2": "Advanced Fixes", "cheatdetector.gui.button.tab.advanced3": "Advanced Modules", diff --git a/src/main/resources/assets/cheatdetector/lang/zh_cn.json b/src/main/resources/assets/cheatdetector/lang/zh_cn.json index 1ac5d4b..78490ec 100644 --- a/src/main/resources/assets/cheatdetector/lang/zh_cn.json +++ b/src/main/resources/assets/cheatdetector/lang/zh_cn.json @@ -6,6 +6,7 @@ "cheatdetector.chat.alert.creativeFlyWithoutDisabler": "创造模式飞行必须与移动禁用器一起使用!", "cheatdetector.chat.alert.fail": "触发了", "cheatdetector.chat.alert.flagDetected": "检测到标记: ", + "cheatdetector.chat.alert.freezeDetected": "检测到冻结: ", "cheatdetector.chat.alert.nukerSetBlock": "设置方块种类为 %s 。", "cheatdetector.chat.alert.startVanish": "%s 进入隐身状态!", "cheatdetector.chat.alert.stopVanish": "%s 停止了隐身。", @@ -106,6 +107,9 @@ "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": "假延迟",