/* * Decompiled with CFR 0.152. */ package net.minecraft.network.protocol.game; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketType; import net.minecraft.network.protocol.game.GamePacketTypes; import net.minecraft.network.protocol.game.ServerGamePacketListener; import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.Vec3; public record ServerboundMoveVehiclePacket(Vec3 position, float yRot, float xRot, boolean onGround) implements Packet { public static final StreamCodec STREAM_CODEC = StreamCodec.composite(Vec3.STREAM_CODEC, ServerboundMoveVehiclePacket::position, ByteBufCodecs.FLOAT, ServerboundMoveVehiclePacket::yRot, ByteBufCodecs.FLOAT, ServerboundMoveVehiclePacket::xRot, ByteBufCodecs.BOOL, ServerboundMoveVehiclePacket::onGround, ServerboundMoveVehiclePacket::new); public static ServerboundMoveVehiclePacket fromEntity(Entity entity) { if (entity.isInterpolating()) { return new ServerboundMoveVehiclePacket(entity.getInterpolation().position(), entity.getInterpolation().yRot(), entity.getInterpolation().xRot(), entity.onGround()); } return new ServerboundMoveVehiclePacket(entity.position(), entity.getYRot(), entity.getXRot(), entity.onGround()); } @Override public PacketType type() { return GamePacketTypes.SERVERBOUND_MOVE_VEHICLE; } @Override public void handle(ServerGamePacketListener listener) { listener.handleMoveVehicle(this); } }