Skip to content

Commit

Permalink
Release 2.9.3
Browse files Browse the repository at this point in the history
- 改进AutoCatch
- 改进ServerFreeze
- 修复VelocityA的一个误判
- 改进FlyA
  • Loading branch information
xia-mc committed May 24, 2024
1 parent 3cfa8ae commit e2e9cd9
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 76 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.2
mod_version = 2.9.3
maven_group = top.infsky
archives_base_name = CheatDetector

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
14 changes: 4 additions & 10 deletions src/main/java/top/infsky/cheatdetector/config/AdvancedConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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;

Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/top/infsky/cheatdetector/impl/checks/FlyA.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -78,8 +80,9 @@ public void _onTeleport() {

@Override
public void _onJump() {
// fix jump
jumpTick = AdvancedConfig.getFlyAOnJumpJumpTick();
List<Double> motions = MotionA.getPossibleMotions(player);

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void _onTick() {
} else if (jumpFromY != null) {
if (jumpFromY == player.currentPos.y()) { // 满足判断条件
try {
List<Double> possibleMotion = Objects.requireNonNull(getPossibleMotions());
List<Double> possibleMotion = Objects.requireNonNull(getPossibleMotions(player));

check:
try {
Expand Down Expand Up @@ -102,7 +102,7 @@ private boolean check() {
return !player.fabricPlayer.getAbilities().flying;
}

private @Nullable List<Double> getPossibleMotions() {
public static @Nullable List<Double> getPossibleMotions(@NotNull TRPlayer player) {
List<Double> result;
Map<MobEffect, MobEffectInstance> activeEffectsMap = player.fabricPlayer.getActiveEffectsMap();
if (!activeEffectsMap.containsKey(MobEffects.JUMP)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public void _onTick() {

@Override
public boolean _onPacketReceive(@NotNull Packet<ClientGamePacketListener> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AntiBot extends Module {

public AntiBot(@NotNull TRSelf player) {
super("AntiBot", player);
botList = new LinkedList<>();
botList.clear();
instance = this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,25 +24,30 @@ 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;
}

@Override
public void _onTick() {
if (isDisabled()) return;
if (isDisabled()) {
target = null;
return;
}
if (!Advanced3Config.autoCatchAlways && player.fabricPlayer.isPassenger()) return;

doCatch();
}

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;
Expand All @@ -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) {
Expand All @@ -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;
}
}

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -21,7 +19,7 @@ public class VelocityUtils {
Direction.EAST, Direction.WEST, Direction.NORTH, Direction.SOUTH
);
public static final List<MobEffect> HURT_EFFECTS = List.of(
MobEffects.WITHER, MobEffects.POISON
MobEffects.WITHER, MobEffects.POISON, MobEffects.HARM
);

public enum VelocityDirection {
Expand All @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void stopRiding(CallbackInfo ci) {
AutoCatch autoCatch = (AutoCatch) AutoCatch.getInstance();

if (autoCatch != null) {
autoCatch.onStopRiding();
autoCatch.onStopRiding((Entity) (Object) this);
}
}
}
4 changes: 4 additions & 0 deletions src/main/resources/assets/cheatdetector/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit e2e9cd9

Please sign in to comment.