use of org.lanternpowered.server.network.entity.parameter.AbstractParameterList in project LanternServer by LanternPowered.
the class CodecPlayOutEntityMetadata method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutEntityMetadata message) throws CodecException {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getEntityId());
((AbstractParameterList) message.getParameterList()).write(buf);
return buf;
}
use of org.lanternpowered.server.network.entity.parameter.AbstractParameterList in project LanternServer by LanternPowered.
the class CodecPlayOutSpawnMob method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutSpawnMob message) throws CodecException {
ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getEntityId());
buf.writeUniqueId(message.getUniqueId());
buf.writeVarInt(message.getMobType());
Vector3d vector = message.getPosition();
buf.writeDouble(vector.getX());
buf.writeDouble(vector.getY());
buf.writeDouble(vector.getZ());
buf.writeByte(message.getYaw());
buf.writeByte(message.getPitch());
buf.writeByte(message.getHeadPitch());
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));
((AbstractParameterList) message.getParameterList()).write(buf);
return buf;
}
use of org.lanternpowered.server.network.entity.parameter.AbstractParameterList in project LanternServer by LanternPowered.
the class CodecPlayOutSpawnPlayer method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutSpawnPlayer message) throws CodecException {
ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getEntityId());
buf.writeUniqueId(message.getUniqueId());
Vector3d vector = message.getPosition();
buf.writeDouble(vector.getX());
buf.writeDouble(vector.getY());
buf.writeDouble(vector.getZ());
buf.writeByte((byte) message.getYaw());
buf.writeByte((byte) message.getPitch());
((AbstractParameterList) message.getParameterList()).write(buf);
return buf;
}
Aggregations