Search in sources :

Example 1 with LanternRecordType

use of org.lanternpowered.server.data.type.record.LanternRecordType in project LanternServer by LanternPowered.

the class CodecPlayOutEffect method encode.

@Override
public ByteBuffer encode(CodecContext context, Message message) throws CodecException {
    final ByteBuffer buf = context.byteBufAlloc().buffer();
    if (message instanceof MessagePlayOutEffect) {
        final MessagePlayOutEffect message1 = (MessagePlayOutEffect) message;
        buf.writeInteger(message1.getType());
        buf.write(Types.VECTOR_3_I, message1.getPosition());
        buf.writeInteger(message1.getData());
        buf.writeBoolean(message1.isBroadcast());
    } else if (message instanceof MessagePlayOutRecord) {
        final MessagePlayOutRecord message1 = (MessagePlayOutRecord) message;
        buf.writeInteger(1010);
        buf.write(Types.VECTOR_3_I, message1.getPosition());
        buf.writeInteger(message1.getRecord().map(type -> 2256 + ((LanternRecordType) type).getInternalId()).orElse(0));
        buf.writeBoolean(false);
    } else {
        throw new EncoderException("Unsupported message type: " + message.getClass().getName());
    }
    return buf;
}
Also used : EncoderException(io.netty.handler.codec.EncoderException) CodecException(io.netty.handler.codec.CodecException) Codec(org.lanternpowered.server.network.message.codec.Codec) MessagePlayOutRecord(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutRecord) LanternRecordType(org.lanternpowered.server.data.type.record.LanternRecordType) MessagePlayOutEffect(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutEffect) ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer) Types(org.lanternpowered.server.network.buffer.objects.Types) CodecContext(org.lanternpowered.server.network.message.codec.CodecContext) Message(org.lanternpowered.server.network.message.Message) EncoderException(io.netty.handler.codec.EncoderException) MessagePlayOutEffect(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutEffect) MessagePlayOutRecord(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutRecord) ByteBuffer(org.lanternpowered.server.network.buffer.ByteBuffer)

Example 2 with LanternRecordType

use of org.lanternpowered.server.data.type.record.LanternRecordType in project LanternServer by LanternPowered.

the class RecordTypeRegistryModule method registerDefaults.

@Override
public void registerDefaults() {
    register(new LanternRecordType("minecraft", "thirteen", "item.record.13.desc", 0, SoundTypes.RECORD_13));
    register(new LanternRecordType("minecraft", "cat", "item.record.cat.desc", 1, SoundTypes.RECORD_CAT));
    register(new LanternRecordType("minecraft", "blocks", "item.record.blocks.desc", 2, SoundTypes.RECORD_BLOCKS));
    register(new LanternRecordType("minecraft", "chirp", "item.record.chirp.desc", 3, SoundTypes.RECORD_CHIRP));
    register(new LanternRecordType("minecraft", "far", "item.record.far.desc", 4, SoundTypes.RECORD_FAR));
    register(new LanternRecordType("minecraft", "mall", "item.record.mall.desc", 5, SoundTypes.RECORD_MALL));
    register(new LanternRecordType("minecraft", "mellohi", "item.record.mellohi.desc", 6, SoundTypes.RECORD_MELLOHI));
    register(new LanternRecordType("minecraft", "stal", "item.record.stal.desc", 7, SoundTypes.RECORD_STAL));
    register(new LanternRecordType("minecraft", "strad", "item.record.strad.desc", 8, SoundTypes.RECORD_STRAD));
    register(new LanternRecordType("minecraft", "ward", "item.record.ward.desc", 9, SoundTypes.RECORD_WARD));
    register(new LanternRecordType("minecraft", "eleven", "item.record.11.desc", 10, SoundTypes.RECORD_11));
    register(new LanternRecordType("minecraft", "wait", "item.record.wait.desc", 11, SoundTypes.RECORD_WAIT));
}
Also used : LanternRecordType(org.lanternpowered.server.data.type.record.LanternRecordType)

Aggregations

LanternRecordType (org.lanternpowered.server.data.type.record.LanternRecordType)2 CodecException (io.netty.handler.codec.CodecException)1 EncoderException (io.netty.handler.codec.EncoderException)1 ByteBuffer (org.lanternpowered.server.network.buffer.ByteBuffer)1 Types (org.lanternpowered.server.network.buffer.objects.Types)1 Message (org.lanternpowered.server.network.message.Message)1 Codec (org.lanternpowered.server.network.message.codec.Codec)1 CodecContext (org.lanternpowered.server.network.message.codec.CodecContext)1 MessagePlayOutEffect (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutEffect)1 MessagePlayOutRecord (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutRecord)1