From 96cd23fa7cf69e0b2ce524ff90d319a96c1332e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C5=AFla?= <47734291+Tomasan7@users.noreply.github.com> Date: Sun, 21 May 2023 20:10:12 +0200 Subject: [PATCH] Fix boat steer NPE (Minestom/Minestom#1854) (cherry picked from commit 80f5db34a652e26004f33ab243008ff3a112eaa7) --- .../net/minestom/server/listener/PlayerVehicleListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minestom/server/listener/PlayerVehicleListener.java b/src/main/java/net/minestom/server/listener/PlayerVehicleListener.java index 0c3c4ac25..090744a22 100644 --- a/src/main/java/net/minestom/server/listener/PlayerVehicleListener.java +++ b/src/main/java/net/minestom/server/listener/PlayerVehicleListener.java @@ -36,8 +36,10 @@ public class PlayerVehicleListener { public static void boatSteerListener(ClientSteerBoatPacket packet, Player player) { final Entity vehicle = player.getVehicle(); + /* The packet may have been received after already exiting the vehicle. */ + if (vehicle == null) return; if (!(vehicle.getEntityMeta() instanceof BoatMeta boat)) return; boat.setLeftPaddleTurning(packet.leftPaddleTurning()); boat.setRightPaddleTurning(packet.rightPaddleTurning()); } -} +} \ No newline at end of file