use of org.lanternpowered.server.network.buffer.ByteBuffer 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.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutSpawnParticle method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutSpawnParticle message) throws CodecException {
Vector3f position = message.getPosition();
Vector3f offset = message.getOffset();
int[] extra = message.getExtra();
ByteBuffer buf = context.byteBufAlloc().buffer(BASE_LENGTH);
buf.writeInteger(message.getParticleId());
buf.writeBoolean(message.isLongDistance());
buf.writeFloat(position.getX());
buf.writeFloat(position.getY());
buf.writeFloat(position.getZ());
buf.writeFloat(offset.getX());
buf.writeFloat(offset.getY());
buf.writeFloat(offset.getZ());
buf.writeFloat(message.getData());
buf.writeInteger(message.getCount());
for (int value : extra) {
buf.writeVarInt(value);
}
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer 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;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutSpawnThunderbolt method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutSpawnThunderbolt message) throws CodecException {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getEntityId());
buf.writeByte((byte) 1);
final Vector3d position = message.getPosition();
buf.writeDouble(position.getX());
buf.writeDouble(position.getY());
buf.writeDouble(position.getZ());
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class ProcessorPlayOutParticleEffect method processRemoval.
private void processRemoval(@Nullable ParticleEffect key, @Nullable ICachedMessage value, RemovalCause cause) {
if (value instanceof CachedFireworksMessage) {
final ByteBufParameterList parameterList = (ByteBufParameterList) ((CachedFireworksMessage) value).entityMetadataMessage.getParameterList();
parameterList.getByteBuffer().ifPresent(ByteBuffer::release);
}
}
Aggregations