use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutSetReducedDebug in project LanternServer by LanternPowered.
the class CodecPlayOutEntityStatus method encode.
@Override
public ByteBuffer encode(CodecContext context, Message message) throws CodecException {
final int entityId;
final int action;
if (message instanceof MessagePlayOutSetReducedDebug) {
entityId = context.getChannel().attr(CodecPlayOutPlayerJoinGame.PLAYER_ENTITY_ID).get();
action = ((MessagePlayOutSetReducedDebug) message).isReduced() ? 22 : 23;
} else if (message instanceof MessagePlayOutSetOpLevel) {
entityId = context.getChannel().attr(CodecPlayOutPlayerJoinGame.PLAYER_ENTITY_ID).get();
action = 24 + Math.max(0, Math.min(4, ((MessagePlayOutSetOpLevel) message).getOpLevel()));
} else if (message instanceof MessagePlayOutEntityStatus) {
entityId = ((MessagePlayOutEntityStatus) message).getEntityId();
action = ((MessagePlayOutEntityStatus) message).getStatus();
} else if (message instanceof MessagePlayInOutFinishUsingItem) {
entityId = context.getChannel().attr(CodecPlayOutPlayerJoinGame.PLAYER_ENTITY_ID).get();
action = 9;
} else {
throw new CodecException("Unsupported message type: " + message.getClass().getName());
}
return context.byteBufAlloc().buffer(LENGTH).writeInteger(entityId).writeByte((byte) action);
}
Aggregations