|
1 | 1 | /* |
2 | | - * This file is part of ViaLoadingBase - https://github.com/FlorianMichael/ViaLoadingBase |
3 | | - * Copyright (C) 2022-2023 FlorianMichael/EnZaXD and contributors |
| 2 | + * This file is part of ViaProtocolHack - https://github.com/RaphiMC/ViaProtocolHack |
| 3 | + * Copyright (C) 2023 RK_01/RaphiMC and contributors |
4 | 4 | * |
5 | 5 | * This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
@@ -40,20 +40,19 @@ public Object getGroundPacket() { |
40 | 40 | @Override |
41 | 41 | public void sendPlayer(UserConnection userConnection) { |
42 | 42 | if (userConnection.getProtocolInfo().getState() != State.PLAY) return; |
43 | | - |
44 | | - final int playerId = userConnection.getEntityTracker(Protocol1_9To1_8.class).clientEntityId(); |
45 | | - if (playerId == -1) return; // Only apply if the player is initialized |
| 43 | + if (userConnection.getEntityTracker(Protocol1_9To1_8.class).clientEntityId() == -1) return; |
46 | 44 |
|
47 | 45 | final MovementTracker movementTracker = userConnection.get(MovementTracker.class); |
48 | 46 | movementTracker.incrementIdlePacket(); |
49 | | - |
50 | | - final PacketWrapper c03 = PacketWrapper.create(ServerboundPackets1_8.PLAYER_MOVEMENT, userConnection); |
51 | | - c03.write(Type.BOOLEAN, movementTracker.isGround()); |
52 | | - |
53 | | - try { |
54 | | - c03.scheduleSendToServer(Protocol1_9To1_8.class); |
55 | | - } catch (Exception e) { |
56 | | - e.printStackTrace(); |
57 | | - } |
| 47 | + final boolean onGround = movementTracker.isGround(); |
| 48 | + |
| 49 | + userConnection.getChannel().eventLoop().submit(() -> { |
| 50 | + try { |
| 51 | + final PacketWrapper playerMovement = PacketWrapper.create(ServerboundPackets1_8.PLAYER_MOVEMENT, userConnection); |
| 52 | + playerMovement.write(Type.BOOLEAN, onGround); // on ground |
| 53 | + playerMovement.sendToServer(Protocol1_9To1_8.class); |
| 54 | + } catch (Throwable ignored) { |
| 55 | + } |
| 56 | + }); |
58 | 57 | } |
59 | 58 | } |
0 commit comments