use of org.spongepowered.api.util.RelativePositions in project LanternServer by LanternPowered.
the class CodecPlayOutPlayerPositionAndLook method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutPlayerPositionAndLook message) throws CodecException {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeDouble(message.getX());
buf.writeDouble(message.getY());
buf.writeDouble(message.getZ());
buf.writeFloat(message.getYaw());
buf.writeFloat(message.getPitch());
Set<RelativePositions> relativePositions = message.getRelativePositions();
byte flags = 0;
if (relativePositions.contains(RelativePositions.X)) {
flags |= 0x01;
}
if (relativePositions.contains(RelativePositions.Y)) {
flags |= 0x02;
}
if (relativePositions.contains(RelativePositions.Z)) {
flags |= 0x04;
}
if (relativePositions.contains(RelativePositions.PITCH)) {
flags |= 0x08;
}
if (relativePositions.contains(RelativePositions.YAW)) {
flags |= 0x10;
}
buf.writeByte(flags);
buf.writeVarInt(message.getTeleportId());
return buf;
}
Aggregations