use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutOpenBook in project LanternServer by LanternPowered.
the class LanternPlayer method sendBookView.
@Override
public void sendBookView(BookView bookView) {
checkNotNull(bookView, "bookView");
final DataView dataView = DataContainer.createNew(DataView.SafetyMode.NO_DATA_CLONED);
WrittenBookItemTypeObjectSerializer.writeBookData(dataView, bookView, this.locale);
// Written book internal id
final RawItemStack rawItemStack = new RawItemStack(387, 0, 1, dataView);
final int slot = this.inventory.getHotbar().getSelectedSlotIndex();
this.session.send(new MessagePlayOutSetWindowSlot(-2, slot, rawItemStack));
this.session.send(new MessagePlayOutOpenBook(HandTypes.MAIN_HAND));
this.session.send(new MessagePlayOutSetWindowSlot(-2, slot, this.inventory.getHotbar().getSelectedSlot().peek().orElse(null)));
}
use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutOpenBook in project LanternServer by LanternPowered.
the class CodecPlayInOutCustomPayload method encode0.
@Override
protected MessageResult encode0(CodecContext context, Message message) throws CodecException {
if (message instanceof MessagePlayInOutBrand) {
return new MessageResult("MC|Brand", context.byteBufAlloc().buffer().writeString(((MessagePlayInOutBrand) message).getBrand()));
} else if (message instanceof MessagePlayOutOpenBook) {
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeVarInt(((MessagePlayOutOpenBook) message).getHandType() == HandTypes.MAIN_HAND ? 0 : 1);
return new MessageResult("MC|BOpen", buf);
} else if (message instanceof MessagePlayOutStopSounds) {
final MessagePlayOutStopSounds message0 = (MessagePlayOutStopSounds) message;
final ByteBuffer buf = context.byteBufAlloc().buffer();
buf.writeString(message0.getCategory() == null ? "" : message0.getCategory().getName());
buf.writeString(message0.getSound() == null ? "" : message0.getSound());
return new MessageResult("MC|StopSound", buf);
}
throw new EncoderException("Unsupported message type: " + message);
}
Aggregations