From 1bf49b1f0b0634fb89e2cf7c0bf524a65ee20fdd Mon Sep 17 00:00:00 2001 From: Mats Date: Thu, 3 Mar 2016 12:18:23 +0100 Subject: [PATCH] Fix unmount --- .../transformers/OutgoingTransformer.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index 8957365f7..667d50be3 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -34,6 +34,7 @@ public class OutgoingTransformer { private boolean cancel = false; private Map uuidMap = new HashMap(); private Map clientEntityTypes = new HashMap(); + private Map vehicleMap = new HashMap<>(); public OutgoingTransformer(ConnectionInfo info) { this.info = info; @@ -82,8 +83,17 @@ public class OutgoingTransformer { if (!lead) { output.clear(); writeVarInt(PacketType.PLAY_SET_PASSENGERS.getNewPacketID(), output); - writeVarInt(vehicle, output); - writeVarIntArray(Collections.singletonList(passenger), output); + if (vehicle == -1) { + if (!vehicleMap.containsKey(passenger)) + throw new CancelException(); + vehicle = vehicleMap.remove(passenger); + writeVarInt(vehicle,output); + writeVarIntArray(Collections.emptyList(), output); + } else{ + writeVarInt(vehicle, output); + writeVarIntArray(Collections.singletonList(passenger), output); + vehicleMap.put(passenger,vehicle); + } return; } output.writeInt(passenger);