ViaFabricPlus icon indicating copy to clipboard operation
ViaFabricPlus copied to clipboard

Sprinting Into Wall Causes Anti-Cheat Flagging

Open lowercasebtw opened this issue 6 months ago • 7 comments

General Information

https://dump.viaversion.com/34ef146dd45671d8eabd0aab9f7b9bb35e96c1eaf34621bc4eabd3c1a6134a8f

Bug Description

In 1.8 and below, when sprinting into a wall, it flags anticheat GrimAC.

Image

Steps to Reproduce

Join eu.loyisa.cn w/ version 1.8 Go to a block, spam W (w/ toggle sprint enabled, also happens even without toggle sprint)

Expected Behavior

No flagging

lowercasebtw avatar Jul 14 '25 19:07 lowercasebtw

BadPacketsX seems to flag due to duplicate packets

    public void onPacketReceive(PacketReceiveEvent event) {
        if (player.gamemode == GameMode.SPECTATOR || isTickPacket(event.getPacketType())) {
            sprint = sneak = false;
            return;
        }

        if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) {
            switch (new WrapperPlayClientEntityAction(event).getAction()) {
                case START_SNEAKING, STOP_SNEAKING -> {
                    if (sneak) {
                        if (player.canSkipTicksPreVia() || flagAndAlert()) {
                            flags++;
                        }
                    }

                    sneak = true;
                }
                case START_SPRINTING, STOP_SPRINTING -> {
                    if (player.inVehicle()) {
                        return;
                    }

                    if (sprint) {
                        if (player.canSkipTicksPreVia() || flagAndAlert()) {
                            flags++;
                        }
                    }

                    sprint = true;
                }
            }
        }
    }

Exterminate5573 avatar Jul 24 '25 08:07 Exterminate5573

Yeah, it's multiple actions in one tick. The other BadPackets check is checking for very close position updates. My assumption was sendMovementPackets() or tick() inside the ClientPlayerEntity to be called too often?

FlorianMichael avatar Jul 24 '25 08:07 FlorianMichael

I may have found the cause for this

Latest:

        profiler.push("rest");
        boolean bl = !MathHelper.approximatelyEquals(movement.x, vec3d.x);
        boolean bl2 = !MathHelper.approximatelyEquals(movement.z, vec3d.z);
        this.horizontalCollision = bl || bl2;

17w46a (Pre-Collision change)

        this.world.profiler.push("rest");
        this.setPositionFromShape();
        this.collidingHorizontally = n != x || p != z;

This is in the Entity Class under the move func

Exterminate5573 avatar Jul 24 '25 12:07 Exterminate5573

Looks interesting even if it doesn’t fix it, should probably still be fixed / added if not already

lowercasebtw avatar Jul 25 '25 07:07 lowercasebtw

I just did some testing with viaproxy and was unable to flag BadPacketsX even on latest, it's definitely a VFP change that is causing the flag.

Exterminate5573 avatar Jul 25 '25 09:07 Exterminate5573

Oh well, that's bad lol

FlorianMichael avatar Jul 25 '25 09:07 FlorianMichael

I may have found the cause for this

Latest:

        profiler.push("rest");
        boolean bl = !MathHelper.approximatelyEquals(movement.x, vec3d.x);
        boolean bl2 = !MathHelper.approximatelyEquals(movement.z, vec3d.z);
        this.horizontalCollision = bl || bl2;

17w46a (Pre-Collision change)

        this.world.profiler.push("rest");
        this.setPositionFromShape();
        this.collidingHorizontally = n != x || p != z;

This is in the Entity Class under the move func

Seems important, but it doesn't seem to fix the issue sadly. Still would be good to add

FlorianMichael avatar Jul 27 '25 15:07 FlorianMichael