Search in sources :

Example 1 with AbstractParameterList

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;
}
Also used : AbstractParameterList(org.lanternpowered.server.network.entity.parameter.AbstractParameterList) ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 2 with AbstractParameterList

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;
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) AbstractParameterList(org.lanternpowered.server.network.entity.parameter.AbstractParameterList) ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 3 with AbstractParameterList

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;
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) AbstractParameterList(org.lanternpowered.server.network.entity.parameter.AbstractParameterList) ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Aggregations

ByteBuffer (org.lanternpowered.server.network.buffer.ByteBuffer)3 AbstractParameterList (org.lanternpowered.server.network.entity.parameter.AbstractParameterList)3 Vector3d (com.flowpowered.math.vector.Vector3d)2