use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutSpawnObject method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutSpawnObject message) throws CodecException {
ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getEntityId());
buf.writeUniqueId(message.getUniqueId());
buf.writeByte((byte) message.getObjectType());
Vector3d vector = message.getPosition();
buf.writeDouble(vector.getX());
buf.writeDouble(vector.getY());
buf.writeDouble(vector.getZ());
buf.writeByte((byte) message.getPitch());
buf.writeByte((byte) message.getYaw());
buf.writeInteger(message.getObjectData());
vector = message.getVelocity();
buf.writeShort((short) Math.min(vector.getX() * 8000.0, Short.MAX_VALUE));
buf.writeShort((short) Math.min(vector.getY() * 8000.0, Short.MAX_VALUE));
buf.writeShort((short) Math.min(vector.getZ() * 8000.0, Short.MAX_VALUE));
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutSpawnPainting method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutSpawnPainting message) throws CodecException {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getEntityId());
buf.writeUniqueId(message.getUniqueId());
buf.writeString(message.getArt().getName());
buf.write(Types.VECTOR_3_I, new Vector3i(message.getX(), message.getY(), message.getZ()));
buf.writeByte(toId(message.getDirection()));
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutEntityAnimation method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutEntityAnimation message) throws CodecException {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getEntityId());
buf.writeByte((byte) message.getAnimation());
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutEntityLookAndRelativeMove method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutEntityLookAndRelativeMove message) throws CodecException {
ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getEntityId());
buf.writeShort((short) message.getDeltaX());
buf.writeShort((short) message.getDeltaY());
buf.writeShort((short) message.getDeltaZ());
buf.writeByte(message.getYaw());
buf.writeByte(message.getPitch());
buf.writeBoolean(message.isOnGround());
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutEntityTeleport method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutEntityTeleport message) throws CodecException {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getEntityId());
buf.writeDouble(message.getX());
buf.writeDouble(message.getY());
buf.writeDouble(message.getZ());
buf.writeByte(message.getYaw());
buf.writeByte(message.getPitch());
buf.writeBoolean(message.isOnGround());
return buf;
}
Aggregations