Example usage for io.netty.buffer ByteBuf readLong

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

Introduction

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

Prototype

public abstract long readLong();

Source Link

Document

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

Usage

From source file:daxum.temporalconvergence.network.PacketDodge.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    long uuidMost = buf.readLong();
    long uuidLeast = buf.readLong();

    playerUUID = new UUID(uuidMost, uuidLeast);
}

From source file:daxum.temporalconvergence.network.PacketDodgeSuccess.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    long uuidMost = buf.readLong();
    long uuidLeast = buf.readLong();

    mainPlayerUUID = new UUID(uuidMost, uuidLeast);

    ox = buf.readDouble();//from w  ww.j a v  a 2s  .co  m
    oy = buf.readDouble();
    oz = buf.readDouble();
}

From source file:de.sanandrew.mods.turretmod.entity.turret.EntityTurret.java

License:Creative Commons License

@Override
public void readSpawnData(ByteBuf buffer) {
    this.delegate = TurretRegistry.INSTANCE.getTurret(new UUID(buffer.readLong(), buffer.readLong()));

    this.targetProc.readFromNbt(ByteBufUtils.readTag(buffer));
    this.upgProc.readFromNbt(ByteBufUtils.readTag(buffer));

    this.isUpsideDown = buffer.readBoolean();

    if (buffer.readBoolean()) {
        this.ownerUUID = new UUID(buffer.readLong(), buffer.readLong());
        this.ownerName = ByteBufUtils.readUTF8String(buffer);
    }//from   w ww.  j av  a2s .co m

    this.delegate.readSpawnData(this, buffer);
}

From source file:de.sanandrew.mods.turretmod.network.PacketSyncUpgradeInst.java

License:Creative Commons License

@Override
public void fromBytes(ByteBuf buf) {
    this.turretId = buf.readInt();
    this.upgradeId = new UUID(buf.readLong(), buf.readLong());
    int lng = buf.readInt();
    this.instData = new byte[lng];
    if (lng > 0) {
        buf.readBytes(this.instData);
    }//  w  ww.  j av a2s.  com
}

From source file:divconq.ctp.f.BlockCommand.java

License:Open Source License

@Override
public boolean decode(ByteBuf in) {
    while (this.state != State.DONE) {
        switch (this.state) {
        case BLOCK_TYPE: {
            if (in.readableBytes() < 1)
                return false;

            this.blocktype = in.readUnsignedByte();

            this.eof = ((this.blocktype & CtpConstants.CTP_F_BLOCK_TYPE_EOF) != 0);
            this.skipHeaders = ((this.blocktype & CtpConstants.CTP_F_BLOCK_TYPE_HEADER) == 0);
            this.skipPayload = ((this.blocktype & CtpConstants.CTP_F_BLOCK_TYPE_CONTENT) == 0);

            // completely done, exit the loop and decode
            if (this.skipHeaders && this.skipPayload) {
                this.state = State.DONE;
                break;
            }//from   www  .  j a v  a  2  s. c o m

            // to skip headers, go back to loop
            if (this.skipHeaders) {
                this.state = State.STREAM_OFFSET;
                break;
            }

            this.state = State.HEADER_ATTR;

            // deliberate fall through 
        }
        case HEADER_ATTR: {
            if (in.readableBytes() < 2)
                return false;

            this.currattr = in.readShort();

            // done with headers, go back to loop to skip down to payload
            if (this.currattr == CtpConstants.CTP_F_ATTR_END) {
                if (this.skipPayload)
                    this.state = State.DONE;
                else
                    this.state = State.STREAM_OFFSET;

                break;
            }

            this.state = State.HEADER_SIZE;

            // deliberate fall through 
        }
        case HEADER_SIZE: {
            if (in.readableBytes() < 2)
                return false;

            this.currasize = in.readShort();

            // an empty attribute is like a flag - present but no data
            // go on to next header
            if (this.currasize == 0) {
                this.headers.put(this.currattr, new byte[0]);
                this.currattr = 0;
                this.state = State.HEADER_ATTR;
                break;
            }

            this.state = State.HEADER_VALUE;

            // deliberate fall through 
        }
        case HEADER_VALUE: {
            if (in.readableBytes() < this.currasize)
                return false;

            byte[] val = new byte[this.currasize];

            in.readBytes(val);

            this.headers.put(this.currattr, val);

            this.currattr = 0;
            this.currasize = 0;

            this.state = State.HEADER_ATTR;

            break;
        }
        case STREAM_OFFSET: {
            if (in.readableBytes() < 8)
                return false;

            this.streamOffset = in.readLong();

            this.state = State.PAYLOAD_SIZE;

            // deliberate fall through 
        }
        case PAYLOAD_SIZE: {
            if (in.readableBytes() < 3)
                return false;

            this.paysize = in.readMedium();

            this.state = State.PAYLOAD;

            // deliberate fall through 
        }
        case PAYLOAD: {
            // return here, without any state reset, means we need more before we can decide what to do
            if (in.readableBytes() < this.paysize)
                return false;

            // add Data only if there are some bytes, otherwise skip buffer allocation
            if (this.paysize > 0) {
                ByteBuf bb = in.readSlice(this.paysize);
                bb.retain();
                this.data = bb;
            }

            this.state = State.DONE;

            // deliberate fall through 
        }
        case DONE: {
            break;
        }
        }
    }

    return true;
}

From source file:eu.jangos.realm.network.packet.client.character.CMSG_CHAR_DELETE.java

License:Open Source License

@Override
public void decode(ByteBuf buf) throws Exception {
    if ((buf.readableBytes() + 4) < this.size) {
        throw new Exception();
    }//from ww w.  ja  v  a 2  s  .c om

    this.id = buf.readLong();
}

From source file:eu.jangos.realm.network.packet.client.query.CMSG_CREATURE_QUERY.java

License:Apache License

@Override
public void decode(ByteBuf buf) throws Exception {
    if ((buf.readableBytes() + 4) < this.size) {
        throw new Exception();
    }/* w w w. ja v  a 2 s  . c  o  m*/

    this.entry = buf.readInt();
    this.guid = buf.readLong();
}

From source file:eu.jangos.realm.network.packet.client.query.CMSG_PET_NAME_QUERY.java

License:Apache License

@Override
public void decode(ByteBuf buf) throws Exception {
    if ((buf.readableBytes() + 4) < this.size) {
        throw new Exception();
    }/*ww  w  .  j  a v  a  2  s .  c o m*/

    this.number = buf.readInt();
    this.guid = buf.readLong();
}

From source file:eu.xworlds.util.raknet.protocol.BaseMessage.java

License:Open Source License

protected long readTime(ByteBuf buf) {
    return buf.readLong();
}

From source file:eu.xworlds.util.raknet.protocol.BaseMessage.java

License:Open Source License

protected long readGuid(ByteBuf buf) {
    return buf.readLong();
}