From 6aabe3764162d01b660570c1624fb263cc396aaf Mon Sep 17 00:00:00 2001 From: Bixilon Date: Thu, 2 Jul 2020 22:34:41 +0200 Subject: [PATCH] PacketVehicleMove --- .../serverbound/play/PacketVehicleMove.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketVehicleMove.java diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketVehicleMove.java b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketVehicleMove.java new file mode 100644 index 000000000..853a62dc1 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/serverbound/play/PacketVehicleMove.java @@ -0,0 +1,59 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.protocol.packets.serverbound.play; + +import de.bixilon.minosoft.logging.Log; +import de.bixilon.minosoft.protocol.packets.ServerboundPacket; +import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer; +import de.bixilon.minosoft.protocol.protocol.Packets; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +public class PacketVehicleMove implements ServerboundPacket { + final double x; + final double y; + final double z; + final float yaw; + final float pitch; + + + public PacketVehicleMove(double x, double y, double z, float yaw, float pitch) { + this.x = x; + this.y = y; + this.z = z; + this.yaw = yaw; + this.pitch = pitch; + log(); + } + + + @Override + public OutPacketBuffer write(ProtocolVersion version) { + OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_VEHICLE_MOVE)); + switch (version) { + case VERSION_1_9_4: + buffer.writeDouble(x); + buffer.writeDouble(y); + buffer.writeDouble(z); + buffer.writeFloat(yaw); + buffer.writeFloat(pitch); + break; + } + return buffer; + } + + @Override + public void log() { + Log.protocol(String.format("Sending vehicle movement: %s %s %s (yaw=%s, pitch=%s)", x, y, z, yaw, pitch)); + } +}