minecraft_25w45a_unobfuscated/net/minecraft/network/protocol/game/ServerboundMoveVehiclePacket.java
2025-11-24 22:52:51 +03:00

38 lines
1.7 KiB
Java

/*
* 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<ServerGamePacketListener>
{
public static final StreamCodec<FriendlyByteBuf, ServerboundMoveVehiclePacket> 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<ServerboundMoveVehiclePacket> type() {
return GamePacketTypes.SERVERBOUND_MOVE_VEHICLE;
}
@Override
public void handle(ServerGamePacketListener listener) {
listener.handleMoveVehicle(this);
}
}