Search in sources :

Example 41 with ByteBuffer

use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.

the class CodecPlayOutEntityHeadLook method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutEntityHeadLook message) throws CodecException {
    final ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeVarInt(message.getEntityId());
    buf.writeByte(message.getYaw());
    return buf;
}
Also used : ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 42 with ByteBuffer

use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.

the class CodecPlayOutEntityLook method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutEntityLook message) throws CodecException {
    final ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeVarInt(message.getEntityId());
    buf.writeByte(message.getYaw());
    buf.writeByte(message.getPitch());
    buf.writeBoolean(message.isOnGround());
    return buf;
}
Also used : ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 43 with ByteBuffer

use of org.lanternpowered.server.network.buffer.ByteBuffer 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 44 with ByteBuffer

use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.

the class CodecPlayOutEntityRelativeMove method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutEntityRelativeMove 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.writeBoolean(message.isOnGround());
    return buf;
}
Also used : ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 45 with ByteBuffer

use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.

the class CodecPlayOutEntityVelocity method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutEntityVelocity message) throws CodecException {
    ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeVarInt(message.getEntityId());
    buf.writeShort((short) Math.min(message.getX() * 8000.0, Short.MAX_VALUE));
    buf.writeShort((short) Math.min(message.getY() * 8000.0, Short.MAX_VALUE));
    buf.writeShort((short) Math.min(message.getZ() * 8000.0, Short.MAX_VALUE));
    return buf;
}
Also used : ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Aggregations

ByteBuffer (org.lanternpowered.server.network.buffer.ByteBuffer)75 EncoderException (io.netty.handler.codec.EncoderException)9 Vector3d (com.flowpowered.math.vector.Vector3d)7 Message (org.lanternpowered.server.network.message.Message)5 Map (java.util.Map)4 MessagePlayInOutChannelPayload (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayInOutChannelPayload)4 AbstractParameterList (org.lanternpowered.server.network.entity.parameter.AbstractParameterList)3 NullMessage (org.lanternpowered.server.network.message.NullMessage)3 ItemStack (org.spongepowered.api.item.inventory.ItemStack)3 Vector3i (com.flowpowered.math.vector.Vector3i)2 CodecException (io.netty.handler.codec.CodecException)2 LanternPotionEffectType (org.lanternpowered.server.effect.potion.LanternPotionEffectType)2 LanternPlayer (org.lanternpowered.server.entity.living.player.LanternPlayer)2 NetworkSession (org.lanternpowered.server.network.NetworkSession)2 LanternByteBuffer (org.lanternpowered.server.network.buffer.LanternByteBuffer)2 BulkMessage (org.lanternpowered.server.network.message.BulkMessage)2 CodecRegistration (org.lanternpowered.server.network.message.CodecRegistration)2 HandlerMessage (org.lanternpowered.server.network.message.HandlerMessage)2 Codec (org.lanternpowered.server.network.message.codec.Codec)2 RawItemStack (org.lanternpowered.server.network.objects.RawItemStack)2