Example usage for io.netty.buffer ByteBuf readInt

List of usage examples for io.netty.buffer ByteBuf readInt

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf readInt.

Prototype

public abstract int readInt();

Source Link

Document

Gets a 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.

Usage

From source file:blusunrize.immersiveengineering.common.util.network.MessageMineralListSync.java

@Override
public void fromBytes(ByteBuf buf) {
    int size = buf.readInt();
    for (int i = 0; i < size; i++) {
        NBTTagCompound tag = ByteBufUtils.readTag(buf);
        MineralMix mix = MineralMix.readFromNBT(tag);
        if (mix != null)
            map.put(mix, tag.getInteger("weight"));
    }/*from  w ww.  j  a va 2s  .co  m*/

}

From source file:blusunrize.immersiveengineering.common.util.network.MessageNoSpamChatComponents.java

@Override
public void fromBytes(ByteBuf buf) {
    int l = buf.readInt();
    chatMessages = new ITextComponent[l];
    for (int i = 0; i < l; i++)
        chatMessages[i] = ITextComponent.Serializer.jsonToComponent(ByteBufUtils.readUTF8String(buf));
}

From source file:blusunrize.immersiveengineering.common.util.network.MessageObstructedConnection.java

@Override
public void fromBytes(ByteBuf buf) {
    start = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
    end = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
    startB = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
    endB = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
    blocking = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
    wireType = WireType.getValue(ByteBufUtils.readUTF8String(buf));
}

From source file:blusunrize.immersiveengineering.common.util.network.MessageRequestBlockUpdate.java

@Override
public void fromBytes(ByteBuf buf) {
    pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
}

From source file:blusunrize.immersiveengineering.common.util.network.MessageSetGhostSlots.java

@Override
public void fromBytes(ByteBuf buf) {
    int size = buf.readInt();
    stacksToSet = new Int2ObjectOpenHashMap<>(size);
    for (int i = 0; i < size; i++) {
        int slot = buf.readInt();
        NBTTagCompound nbt = ByteBufUtils.readTag(buf);
        assert nbt != null;
        ItemStack stack = new ItemStack(nbt);
        stacksToSet.put(slot, stack);//from   w w  w .j  a  v  a  2s.  c  o  m
    }
}

From source file:blusunrize.immersiveengineering.common.util.network.MessageShaderManual.java

@Override
public void fromBytes(ByteBuf buf) {
    this.key = MessageType.values()[buf.readInt()];
    int l = buf.readInt();
    args = new String[l];
    for (int i = 0; i < l; i++)
        args[i] = ByteBufUtils.readUTF8String(buf);
}

From source file:blusunrize.immersiveengineering.common.util.network.MessageSkyhookSync.java

@Override
public void fromBytes(ByteBuf buf) {
    entityID = buf.readInt();
    NBTTagCompound tag = ByteBufUtils.readTag(buf);
    connection = Connection.readFromNBT(tag);
    linePos = buf.readDouble();//from  w  ww  .  j av a 2  s .c om
    speed = buf.readDouble();
}

From source file:blusunrize.immersiveengineering.common.util.network.MessageTileSync.java

@Override
public void fromBytes(ByteBuf buf) {
    this.pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
    this.nbt = ByteBufUtils.readTag(buf);
}

From source file:books.netty.protocol.netty.codec.MarshallingDecoder.java

License:Apache License

protected Object decode(ByteBuf in) throws Exception {
    int objectSize = in.readInt();
    ByteBuf buf = in.slice(in.readerIndex(), objectSize);
    ByteInput input = new ChannelBufferByteInput(buf);
    try {//  w w w  .  j  a va 2  s  .co  m
        unmarshaller.start(input);
        Object obj = unmarshaller.readObject();
        unmarshaller.finish();
        in.readerIndex(in.readerIndex() + objectSize);
        return obj;
    } finally {
        unmarshaller.close();
    }
}

From source file:books.netty.protocol.netty.codec.NettyMessageDecoder.java

License:Apache License

@Override
protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
    ByteBuf frame = (ByteBuf) super.decode(ctx, in);
    if (frame == null) {
        return null;
    }/*from  w  ww.j a  v  a  2 s  .  c  o m*/

    NettyMessage message = new NettyMessage();
    Header header = new Header();
    header.setCrcCode(frame.readInt());
    header.setLength(frame.readInt());
    header.setSessionID(frame.readLong());
    header.setType(frame.readByte());
    header.setPriority(frame.readByte());

    int size = frame.readInt();
    if (size > 0) {
        Map<String, Object> attch = new HashMap<String, Object>(size);
        int keySize = 0;
        byte[] keyArray = null;
        String key = null;
        for (int i = 0; i < size; i++) {
            keySize = frame.readInt();
            keyArray = new byte[keySize];
            frame.readBytes(keyArray);
            key = new String(keyArray, "UTF-8");
            attch.put(key, marshallingDecoder.decode(frame));
        }
        keyArray = null;
        key = null;
        header.setAttachment(attch);
    }
    if (frame.readableBytes() > 4) {
        message.setBody(marshallingDecoder.decode(frame));
    }
    message.setHeader(header);
    return message;
}