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:net.tridentsdk.packets.play.in.PacketPlayInPlayerDig.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    this.status = (short) buf.readByte();
    long encodedLocation = buf.readLong();

    this.location = new Location(null, (double) (encodedLocation >> 38), (double) (encodedLocation << 26 >> 52),
            (double) (encodedLocation << 38 >> 38));
    this.blockFace = (short) buf.readByte();

    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInPlayerSpectate.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    this.uuid = new UUID(buf.readLong(), buf.readLong());

    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInTabComplete.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    this.text = Codec.readString(buf);
    this.hasPosition = buf.readBoolean();

    if (this.hasPosition) {
        long encoded = buf.readLong();
        double x = (double) (encoded << 38);
        double y = (double) (encoded << 26 >> 52);
        double z = (double) (encoded << 38 >> 38);

        this.lookedAtBlock = new Location(null, x, y, z);
    }/*from   ww  w. j a  v a2  s .co m*/

    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInUpdateSign.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    long encoded = buf.readLong();
    double x = (double) (encoded >> 38);
    double y = (double) (encoded << 26 >> 52);
    double z = (double) (encoded << 38 >> 38);

    this.signLocation = new Location(null, x, y, z);

    for (int i = 0; i <= 4; i++) {
        this.jsonContents[i] = Codec.readString(buf);
    }//from   www .  j a  v  a  2  s  . c  o m
    return this;
}

From source file:net.tridentsdk.server.packets.play.in.PacketPlayInBlockPlace.java

License:Apache License

@Override
public Packet decode(ByteBuf buf) {
    long encodedLocation = buf.readLong();

    this.location = Position.create(null, (double) (encodedLocation >> 38),
            (double) ((encodedLocation >> 26) & 0xFFF), (double) (encodedLocation << 38 >> 38));
    this.direction = buf.readByte();

    // ignore held item
    // TODO possible NBT
    for (int i = 0; i < buf.readableBytes() - 3; i++) {
        buf.readByte();/*from   ww w . ja va2s .  co m*/
    }

    double x = (double) buf.readByte();
    double y = (double) buf.readByte();
    double z = (double) buf.readByte();

    this.cursorPosition = new Vector(x, y, z);
    return this;
}

From source file:net.tridentsdk.server.packets.play.in.PacketPlayInPlayerDig.java

License:Apache License

@Override
public Packet decode(ByteBuf buf) {
    this.status = (short) buf.readByte();
    long encodedLocation = buf.readLong();

    this.location = Position.create(null, (double) (encodedLocation >> 38),
            (double) (encodedLocation << 26 >> 52), (double) (encodedLocation << 38 >> 38));
    this.blockFace = (short) buf.readByte();

    return this;
}

From source file:net.tridentsdk.server.packets.play.in.PacketPlayInTabComplete.java

License:Apache License

@Override
public Packet decode(ByteBuf buf) {
    this.text = Codec.readString(buf);
    this.hasPosition = buf.readBoolean();

    if (this.hasPosition) {
        long encoded = buf.readLong();
        double x = (double) (encoded << 38);
        double y = (double) (encoded << 26 >> 52);
        double z = (double) (encoded << 38 >> 38);

        this.lookedAtBlock = Position.create(null, x, y, z);
    }//from   ww  w  .  j a  v  a2  s  .  c om

    return this;
}

From source file:net.tridentsdk.server.packets.play.in.PacketPlayInUpdateSign.java

License:Apache License

@Override
public Packet decode(ByteBuf buf) {
    long encoded = buf.readLong();
    double x = (double) (encoded >> 38);
    double y = (double) (encoded << 26 >> 52);
    double z = (double) (encoded << 38 >> 38);

    this.signLocation = Position.create(null, x, y, z);

    for (int i = 0; i <= 4; i++) {
        this.jsonContents[i] = Codec.readString(buf);
    }/*from  www  .  ja  v a 2 s  .  co m*/
    return this;
}

From source file:org.aotorrent.common.protocol.tracker.UDPConnectReply.java

License:Apache License

public UDPConnectReply(ByteBuf in) throws ProtocolException {
    int length = in.readableBytes();
    int action = in.readInt();
    if (action != 0 || length < 16) {
        throw new ProtocolException("Invalid packet");
    }/*from   w w  w . j a v  a 2s.  c o m*/

    transactionId = in.readInt();
    connectionId = in.readLong();
}

From source file:org.apache.activemq.artemis.core.message.impl.CoreMessage.java

License:Apache License

private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) {
    messageIDPosition = buffer.readerIndex();
    messageID = buffer.readLong();

    address = SimpleString.readNullableSimpleString(buffer,
            coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool());
    if (buffer.readByte() == DataConstants.NOT_NULL) {
        byte[] bytes = new byte[16];
        buffer.readBytes(bytes);/*  w  w  w. j a v a2 s  .c o  m*/
        userID = new UUID(UUID.TYPE_TIME_BASED, bytes);
    } else {
        userID = null;
    }
    type = buffer.readByte();
    durable = buffer.readBoolean();
    expiration = buffer.readLong();
    timestamp = buffer.readLong();
    priority = buffer.readByte();
    if (lazyProperties) {
        properties = null;
        propertiesLocation = buffer.readerIndex();
    } else {
        properties = new TypedProperties();
        properties.decode(buffer,
                coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools());
    }
}