use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutBlockAction method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutBlockAction message) throws CodecException {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.write(Types.VECTOR_3_I, message.getPosition());
final int[] parameters = message.getParameters();
buf.writeByte((byte) parameters[0]);
buf.writeByte((byte) parameters[1]);
buf.writeVarInt(message.getBlockType());
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutBlockBreakAnimation method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutBlockBreakAnimation message) throws CodecException {
ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(message.getId());
buf.write(Types.VECTOR_3_I, message.getPosition());
// Make sure that the state fits in the byte
int state = message.getState();
buf.writeByte((byte) (state >= 0 && state <= 9 ? state : 10));
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutChatMessage method encode.
@SuppressWarnings("deprecation")
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutChatMessage message) throws CodecException {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.write(Types.LOCALIZED_TEXT, message.getMessage());
buf.writeByte((byte) message.getType().ordinal());
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutScoreboardDisplayObjective method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutScoreboardDisplayObjective message) throws CodecException {
ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeByte((byte) ((LanternDisplaySlot) message.getDisplaySlot()).getInternalId());
String objectiveName = message.getObjectiveName();
buf.writeString(objectiveName == null ? "" : objectiveName);
return buf;
}
use of org.lanternpowered.server.network.buffer.ByteBuffer in project LanternServer by LanternPowered.
the class CodecPlayOutScoreboardScore method encode.
@Override
public ByteBuffer encode(CodecContext context, MessagePlayOutScoreboardScore message) throws CodecException {
ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeString(message.getScoreName());
int action = message instanceof MessagePlayOutScoreboardScore.Remove ? 1 : 0;
buf.writeByte((byte) action);
buf.writeString(message.getObjectiveName());
if (action == 0) {
buf.writeVarInt(((MessagePlayOutScoreboardScore.CreateOrUpdate) message).getValue());
}
return buf;
}
Aggregations