package net.minecraft.network.protocol.game; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketType; import net.minecraft.world.entity.Entity; public class ServerboundMoveVehiclePacket implements Packet { public static final StreamCodec STREAM_CODEC = Packet.codec( ServerboundMoveVehiclePacket::write, ServerboundMoveVehiclePacket::new ); private final double x; private final double y; private final double z; private final float yRot; private final float xRot; public ServerboundMoveVehiclePacket(Entity vehicle) { this.x = vehicle.lerpTargetX(); this.y = vehicle.lerpTargetY(); this.z = vehicle.lerpTargetZ(); this.yRot = vehicle.getYRot(); this.xRot = vehicle.getXRot(); } private ServerboundMoveVehiclePacket(FriendlyByteBuf buffer) { this.x = buffer.readDouble(); this.y = buffer.readDouble(); this.z = buffer.readDouble(); this.yRot = buffer.readFloat(); this.xRot = buffer.readFloat(); } /** * Writes the raw packet data to the data stream. */ private void write(FriendlyByteBuf buffer) { buffer.writeDouble(this.x); buffer.writeDouble(this.y); buffer.writeDouble(this.z); buffer.writeFloat(this.yRot); buffer.writeFloat(this.xRot); } @Override public PacketType type() { return GamePacketTypes.SERVERBOUND_MOVE_VEHICLE; } /** * Passes this Packet on to the NetHandler for processing. */ public void handle(ServerGamePacketListener handler) { handler.handleMoveVehicle(this); } public double getX() { return this.x; } public double getY() { return this.y; } public double getZ() { return this.z; } public float getYRot() { return this.yRot; } public float getXRot() { return this.xRot; } }