Search in sources :

Example 46 with ByteBuffer

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

the class CodecPlayOutRemovePotionEffect method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutRemovePotionEffect message) throws CodecException {
    final ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeVarInt(message.getEntityId());
    buf.writeByte((byte) ((LanternPotionEffectType) message.getType()).getInternalId());
    return buf;
}
Also used : LanternPotionEffectType(org.lanternpowered.server.effect.potion.LanternPotionEffectType) ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 47 with ByteBuffer

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

the class CodecPlayOutScoreboardObjective method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutScoreboardObjective message) throws CodecException {
    ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeString(message.getObjectiveName());
    if (message instanceof MessagePlayOutScoreboardObjective.CreateOrUpdate) {
        buf.writeByte((byte) (message instanceof MessagePlayOutScoreboardObjective.Create ? 0 : 2));
        MessagePlayOutScoreboardObjective.CreateOrUpdate message0 = (MessagePlayOutScoreboardObjective.CreateOrUpdate) message;
        buf.writeString(message0.getDisplayName());
        buf.writeString(message0.getDisplayMode().getId());
    } else {
        buf.writeByte((byte) 1);
    }
    return buf;
}
Also used : ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer) MessagePlayOutScoreboardObjective(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutScoreboardObjective)

Example 48 with ByteBuffer

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

the class CodecPlayOutSendResourcePack method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutSendResourcePack message) throws CodecException {
    ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeString(message.getUrl());
    buf.writeString(message.getHash());
    return buf;
}
Also used : ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 49 with ByteBuffer

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

the class CodecPlayOutSetCooldown method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutSetCooldown message) throws CodecException {
    ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeVarInt(message.getItemType());
    buf.writeVarInt(message.getCooldownTicks());
    return buf;
}
Also used : ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 50 with ByteBuffer

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

the class CodecPlayOutSetEntityPassengers method encode.

@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutSetEntityPassengers message) throws CodecException {
    final ByteBuffer buf = context.byteBufAlloc().buffer();
    buf.writeVarInt(message.getEntityId());
    final int[] passengersIds = message.getPassengersIds();
    buf.writeVarInt(passengersIds.length);
    for (int entityId : passengersIds) {
        buf.writeVarInt(entityId);
    }
    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