Skip to content

Commit 179200d

Browse files
committed
fix bug
1 parent a4250d3 commit 179200d

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

src/main/java/top/infsky/cheatdetector/config/AdvancedConfig.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,11 @@ public class AdvancedConfig {
143143
public static int autoClickerAMinDiffMs = 5;
144144

145145
@Config(category = ConfigCategory.ADVANCED)
146-
public static boolean flyCCheck = true;
146+
public static boolean flyCCheck = false;
147147
@Config(category = ConfigCategory.ADVANCED)
148148
public static int flyCAlertBuffer = 30;
149149
@Config(category = ConfigCategory.ADVANCED)
150-
public static double flyCMinDiffYMotion = 0.1;
151-
@Config(category = ConfigCategory.ADVANCED)
152-
public static int flyCMinRepeatTicks = 5;
150+
public static int flyCMinRepeatTicks = 10;
153151

154152
@Config(category = ConfigCategory.ADVANCED)
155153
public static boolean boatFlyACheck = true;

src/main/java/top/infsky/cheatdetector/impl/checks/movement/FlyA.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public FlyA(@NotNull TRPlayer player) {
1313

1414
@Override
1515
public void _onTick() {
16-
if (player.fabricPlayer.isPassenger() || !PlayerMove.isMove(player.currentMotion)) return;
16+
if (player.fabricPlayer.isPassenger() || !PlayerMove.isMove(player.currentMotion) || (player.currentOnGround && player.fabricPlayer.isFallFlying())) return;
1717

1818
if (player.lastMotion.y() == 0 && player.currentMotion.y() == 0) {
19-
flag("Invalid Y-motion. onGround=%s".formatted(player.currentOnGround));
19+
flag("Invalid Y-motion: %.2f onGround=%s".formatted(player.currentMotion.y() , player.currentOnGround));
2020
}
2121
}
2222

src/main/java/top/infsky/cheatdetector/impl/checks/movement/FlyC.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.minecraft.world.level.block.Block;
44
import net.minecraft.world.level.block.Blocks;
5+
import net.minecraft.world.phys.Vec3;
56
import org.jetbrains.annotations.NotNull;
67
import top.infsky.cheatdetector.config.AdvancedConfig;
78
import top.infsky.cheatdetector.impl.Check;
@@ -22,16 +23,16 @@ public void _onTick() {
2223
|| IGNORED_BLOCKS.stream().anyMatch(block -> player.fabricPlayer.getFeetBlockState().is(block))) return;
2324

2425
int repeatFromTick = 0;
25-
for (int i = 0; i < player.motionHistory.size(); i++) {
26-
if (Math.abs(player.motionHistory.get(i).y() - player.currentMotion.y()) >= AdvancedConfig.flyCMinDiffYMotion) {
26+
for (Vec3 motion : player.motionHistory) {
27+
if (motion.y() != player.currentMotion.y()) {
2728
return;
2829
}
2930

3031
repeatFromTick++;
3132
}
3233

3334
if (repeatFromTick >= AdvancedConfig.flyCMinRepeatTicks) {
34-
flag("Repeat Y-motion from %s ticks.".formatted(repeatFromTick));
35+
flag("Repeat Y-motion from %s ticks: %.2f".formatted(repeatFromTick, player.currentMotion.y()));
3536
}
3637
}
3738

src/main/java/top/infsky/cheatdetector/impl/checks/movement/MotionA.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.jetbrains.annotations.NotNull;
88
import org.jetbrains.annotations.Nullable;
99
import top.infsky.cheatdetector.config.AdvancedConfig;
10-
import top.infsky.cheatdetector.config.AntiCheatConfig;
1110
import top.infsky.cheatdetector.impl.Check;
1211
import top.infsky.cheatdetector.impl.utils.world.BlockUtils;
1312
import top.infsky.cheatdetector.utils.TRPlayer;
@@ -54,8 +53,10 @@ public void _onTick() {
5453
if (tick >= 0) {
5554
List<Double> possibleMotion = Objects.requireNonNull(getPossibleMotions(player));
5655

57-
if (Math.abs(player.currentMotion.y() - possibleMotion.get(tick)) > AntiCheatConfig.threshold) {
58-
flag("Invalid jump motion at tick %s.".formatted(tick));
56+
double should = possibleMotion.get(tick);
57+
double current = player.currentMotion.y();
58+
if (Math.abs(current - should) > 0.01) {
59+
flag("Invalid jump motion at tick %s. should: %.2f current: %.2f".formatted(tick, should, current));
5960
}
6061
}
6162
} catch (IndexOutOfBoundsException ignored) {

src/main/java/top/infsky/cheatdetector/impl/modules/common/Debug.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import net.minecraft.network.Connection;
66
import net.minecraft.network.protocol.Packet;
77
import net.minecraft.network.protocol.game.ClientGamePacketListener;
8-
import net.minecraft.network.protocol.game.ClientboundEntityEventPacket;
9-
import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
8+
import net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket;
109
import org.jetbrains.annotations.NotNull;
1110
import org.jetbrains.annotations.Nullable;
1211
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -31,11 +30,10 @@ public Debug(@NotNull TRSelf player) {
3130
public boolean _onPacketReceive(@NotNull Packet<ClientGamePacketListener> basePacket, Connection connection, ChannelHandlerContext channelHandlerContext, CallbackInfo ci) {
3231
if (isDisabled()) return false;
3332

34-
if (basePacket instanceof ClientboundEntityEventPacket packet) {
35-
customMsg("EntityEvent: entity:%s eventId:%s".formatted(Objects.requireNonNull(packet.getEntity(LevelUtils.getClientLevel())).getName().getString(), packet.getEventId()));
36-
}
37-
if (basePacket instanceof ClientboundGameEventPacket packet) {
38-
customMsg("GameEvent: event:%s param:%s".formatted(Objects.requireNonNull(packet.getEvent()), packet.getParam()));
33+
if (basePacket instanceof ClientboundSetEntityMotionPacket packet) {
34+
customMsg("SetMotion: entity:%s x:%.2f y:%.2f z:%.2f".formatted(
35+
Objects.requireNonNull(LevelUtils.getClientLevel().getEntity(packet.getId())).getName().getString(),
36+
((double) packet.getXa()) / 8000, ((double) packet.getYa()) / 8000, ((double) packet.getZa()) / 8000));
3937
}
4038
return false;
4139
}

0 commit comments

Comments
 (0)