ViaRewind

ViaRewind

7.4k Downloads

1.8.8 player on 1.20.4 server kicked when right clicking blocks

jtJava opened this issue ยท 5 comments

commented

/viaversion dump Output

https://dump.viaversion.com/2157df1bae4938b4b7cdfc2bfc4e3c9ddc7c7d706217c864cce792eb5b2fc99f

Console Error

[1.8.8](https://mclo.gs/qLtQWoE)

Bug Description

Right clicking blocks causes a netty error and kicks the player on a 1.20.4 server.

Steps to Reproduce

Login with a 1.7 or 1.8 Client and right click any block

Expected Behavior

No kick or exception

Additional Server Info

public class LookFixListener extends SimplePacketListenerAbstract {
    private static final EnumSet<PacketType.Play.Client> DELAYED_PACKETS = EnumSet.of(PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT);
    private final Map<User, List<PacketWrapper<?>>> delayedActions = new HashMap<>();

    @Override
    public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
        if (!event.getUser().getClientVersion().equals(ClientVersion.V_1_8)) {
            return;
        }

        if (DELAYED_PACKETS.contains(event.getPacketType())) {
            this.delayedActions.get(event.getUser()).add(new PacketWrapper<>(event.clone()));
            event.setCancelled(true);
        } else if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())){
            handleFly(event.getUser());
        }
    }

    public void handleFly(User user) {
        for (PacketWrapper<?> wrapper : this.delayedActions.get(user)) {
            PacketEvents.getAPI().getProtocolManager().receivePacketSilently(user.getChannel(), wrapper);
        }
    }

    @Override
    public void onUserConnect(UserConnectEvent event) {
        this.delayedActions.put(event.getUser(), new ArrayList<>());
    }

    @Override
    public void onUserDisconnect(UserDisconnectEvent event) {
        super.onUserDisconnect(event);
    }
}

Checklist

commented

Platform: git--SlimeWorldManager--15816%20%28MC%3A%201.20.4%29
ViaVersion (4.10.2): Even with master
ViaBackwards(4.10.2): 2 commits behind master
ViaRewind(3.1.2): Even with master

Please update all Via* plugins from https://ci.viaversion.com/. In case the issue still persists send the new dump and the issue will be reopened


stack,outdated_proxy

commented

https://dump.viaversion.com/670b6b26a1f6e9641b506a73123e11b2d58632cc25012d1afd055c2aa1d3e1c5

I've debugged and found the following code to be the issue:

public class LookFixListener extends SimplePacketListenerAbstract {
    private static final EnumSet<PacketType.Play.Client> DELAYED_PACKETS = EnumSet.of(PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT);
    private final Map<User, List<PacketWrapper<?>>> delayedActions = new HashMap<>();

    @Override
    public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
        if (!event.getUser().getClientVersion().equals(ClientVersion.V_1_8)) {
            return;
        }

        if (DELAYED_PACKETS.contains(event.getPacketType())) {
            this.delayedActions.get(event.getUser()).add(new PacketWrapper<>(event.clone()));
            event.setCancelled(true);
        } else if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())){
            handleFly(event.getUser());
        }
    }

    public void handleFly(User user) {
        for (PacketWrapper<?> wrapper : this.delayedActions.get(user)) {
            PacketEvents.getAPI().getProtocolManager().receivePacketSilently(user.getChannel(), wrapper);
        }
    }

    @Override
    public void onUserConnect(UserConnectEvent event) {
        this.delayedActions.put(event.getUser(), new ArrayList<>());
    }

    @Override
    public void onUserDisconnect(UserDisconnectEvent event) {
        super.onUserDisconnect(event);
    }
}
commented

Platform: git--SlimeWorldManager--15816%20%28MC%3A%201.20.4%29
ViaVersion (4.10.2): Even with master
ViaRewind(3.1.2): Even with master
ViaBackwards(4.10.3-SNAPSHOT): Even with master

commented

Does this also happen with 1.9+ clients?

commented

Does this also happen with 1.9+ clients?

Not a ViaVersion issue