Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
xia-mc committed Jun 3, 2024
1 parent 73fd5fe commit a184aaa
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public class Advanced3Config {
@Config(category = ConfigCategory.ADVANCED3)
public static boolean antiBotLatency = false;
@Config(category = ConfigCategory.ADVANCED3)
public static boolean antiBotInTabList = false;
public static boolean antiBotHypixel = false;
@Config(category = ConfigCategory.ADVANCED3)
public static boolean antiBotDebug = false;
@Config(category = ConfigCategory.ADVANCED3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ public class AdvancedConfig {
@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static double aimBMinDiffPitch = 2;

@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static boolean motionBCheck = false;
@Config(category = ConfigCategory.ADVANCED, predicate = ConfigPredicate.ExperimentalMode.class)
public static int motionBAlertBuffer = 10;

public static short getNoSlowAInJumpDisableTick() {
return (short) noSlowAInJumpDisableTick;
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/top/infsky/cheatdetector/impl/checks/aim/AimB.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
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 static final Set<Integer> YAW_STEP = Set.of(90, 135, 180);
public static final Set<Integer> PITCH_STEP = Set.of(90, 135);
public AimB(@NotNull TRPlayer player) {
super("AimB", player);
}
Expand All @@ -19,24 +20,27 @@ public void _onTick() {
boolean flagPitch = false;
boolean flagYaw = false;
float stepPitch = 0, stepYaw = 0;
for (int step : STEP) {
for (int step : PITCH_STEP) {
if (Math.abs(Math.abs(player.lastRot.x - player.currentRot.x) - step) < AdvancedConfig.aimBMinDiffPitch) {
flagPitch = true;
stepPitch = player.lastRot.x - player.currentRot.x;
break;
}
}
for (int step : YAW_STEP) {
if (Math.abs(Math.abs(player.lastRot.y - player.currentRot.y) - step) < AdvancedConfig.aimBMinDiffYaw) {
flagYaw = true;
stepYaw = player.lastRot.y - player.currentRot.y;
break;
}
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));
flag("perfect yaw step aim. deltaYaw: %.1f".formatted(stepYaw));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package top.infsky.cheatdetector.impl.checks.movement;

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

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

@Override
public void _onTick() {
if (isDisabled()) return;

if (player.currentOnGround
|| MotionA.IGNORED_EFFECTS.stream().anyMatch(effect -> player.fabricPlayer.hasEffect(effect))
|| player.fabricPlayer.isPassenger()
|| player.fabricPlayer.isInWater()
|| player.fabricPlayer.isFallFlying()
|| player.fabricPlayer.onClimbable() || player.fabricPlayer.hurtTime > 0
) return;

double shouldMotion = PlayerMove.predictedMotion(player.lastMotion.y(), 1);
if (Math.abs(player.currentMotion.y() - shouldMotion) > 0.01) {
flag("invalid jump motion. motion: %.2f should: %.2f:".formatted(
player.currentMotion.y(),
shouldMotion
));
}
}

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

@Override
public boolean isDisabled() {
return !AdvancedConfig.motionBCheck;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ public void _onTick() {
}

try {
if (Advanced3Config.antiBotInTabList) {
if (Advanced3Config.antiBotHypixel) {
List<PlayerInfo> players = new LinkedList<>(player.fabricPlayer.connection.getOnlinePlayers());
LevelUtils.getClientLevel().players().forEach(p -> {
try {
if (p.isDeadOrDying()
|| p.getMaxHealth() == 0
|| p.getName().getString().isEmpty()
|| (p.getHealth() != 20 && p.getName().getString().startsWith("§c"))
) return;

PlayerInfo playerInfo = Objects.requireNonNull(player.fabricPlayer.connection.getPlayerInfo(p.getUUID()));
players.remove(playerInfo);
removeBotVisual(playerInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public CheckManager(@NotNull Map<Class<? extends Check>, Check> preChecks,
normal.put(InvalidPitch.class, new InvalidPitch(player));
normal.put(AimA.class, new AimA(player));
normal.put(ScaffoldA.class, new ScaffoldA(player));
normal.put(AimB.class, new AimB(player));
normal.put(MotionB.class, new MotionB( player));

return new CheckManager(pre, normal, post, player);
}
Expand Down Expand Up @@ -114,6 +116,7 @@ public CheckManager(@NotNull Map<Class<? extends Check>, Check> preChecks,
normal.put(AimA.class, new AimA(player));
normal.put(ScaffoldA.class, new ScaffoldA(player));
normal.put(AimB.class, new AimB(player));
normal.put(MotionB.class, new MotionB(player));

pre.put(BadPacket1.class, new BadPacket1(player));
pre.put(BadPacket2.class, new BadPacket2(player));
Expand Down

0 comments on commit a184aaa

Please sign in to comment.