Example usage for io.netty.buffer ByteBuf readBoolean

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

Introduction

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

Prototype

public abstract boolean readBoolean();

Source Link

Document

Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.

Usage

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

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    double x = buf.readDouble();
    double y = buf.readDouble();
    double z = buf.readDouble();

    this.location = new Location(null, x, y, z); // TODO: Get the player's world

    this.onGround = buf.readBoolean();

    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  www. ja  v  a2s  .c o m*/

    return this;
}

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

License:Apache License

@Override
public Packet decode(ByteBuf buf) {
    double x = buf.readDouble();
    double y = buf.readDouble();
    double z = buf.readDouble();

    super.location = Position.create(null, x, y, z);

    this.newYaw = buf.readFloat();
    this.newPitch = buf.readFloat();

    super.onGround = buf.readBoolean();
    return this;
}

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

License:Apache License

@Override
public Packet decode(ByteBuf buf) {
    double x = buf.readDouble();
    double y = buf.readDouble();
    double z = buf.readDouble();

    this.location = Position.create(null, x, y, z); // TODO: Get the player's world

    this.onGround = buf.readBoolean();

    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   w w  w.  j  a va 2 s  .  c om*/

    return this;
}

From source file:nightkosh.gravestone_extended.packets.ChiselMessageToServer.java

License:LGPL

@Override
public void fromBytes(ByteBuf buf) {
    this.playerID = buf.readInt();
    this.dimensionID = buf.readInt();
    this.isGravestone = buf.readBoolean();
    this.graveType = buf.readInt();
    this.material = buf.readInt();
    this.isEnchanted = buf.readBoolean();
    this.isMossy = buf.readBoolean();
}

From source file:nightkosh.gravestone_extended.packets.ChokeMessageToClient.java

License:LGPL

@Override
public void fromBytes(ByteBuf buf) {
    this.air = buf.readInt();
    this.isActive = buf.readBoolean();
}

From source file:nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.chunks.Chunk1_10Type.java

License:Open Source License

@Override
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
    int chunkX = input.readInt();
    int chunkZ = input.readInt();

    boolean groundUp = input.readBoolean();
    int primaryBitmask = Type.VAR_INT.read(input);
    Type.VAR_INT.read(input);//from w w w  .  java2  s  . com

    BitSet usedSections = new BitSet(16);
    ChunkSection1_10[] sections = new ChunkSection1_10[16];
    // Calculate section count from bitmask
    for (int i = 0; i < 16; i++) {
        if ((primaryBitmask & (1 << i)) != 0) {
            usedSections.set(i);
        }
    }

    // Read sections
    for (int i = 0; i < 16; i++) {
        if (!usedSections.get(i))
            continue; // Section not set
        ChunkSection1_10 section = new ChunkSection1_10();
        sections[i] = section;
        section.readBlocks(input);
        section.readBlockLight(input);
        if (world.getEnvironment() == World.Environment.NORMAL) {
            section.readSkyLight(input);
        }
    }

    byte[] biomeData = groundUp ? new byte[256] : null;
    if (groundUp) {
        input.readBytes(biomeData);
    }

    List<CompoundTag> nbtData = Arrays.asList(Type.NBT_ARRAY.read(input));

    // Temp patch for plugins that sent wrong too big chunks TODO find the issue in LibsDisguise and PR it.
    if (input.readableBytes() > 0) {
        byte[] array = new byte[input.readableBytes()];
        input.readBytes(array);
        if (ViaVersion.getInstance().isDebug())
            System.out.println("Found " + array.length + " more bytes than expected while reading the chunk");
    }

    return new Chunk1_10(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData);
}

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();/*from w ww  .j a  v a2  s.c  o m*/

    address = SimpleString.readNullableSimpleString(buffer,
            coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool());
    if (buffer.readByte() == DataConstants.NOT_NULL) {
        byte[] bytes = new byte[16];
        buffer.readBytes(bytes);
        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());
    }
}

From source file:org.apache.activemq.artemis.utils.collections.TypedProperties.java

License:Apache License

public synchronized void decode(final ByteBuf buffer, final TypedPropertiesDecoderPools keyValuePools) {
    byte b = buffer.readByte();

    if (b == DataConstants.NULL) {
        properties = null;//from ww  w  . j  a  v  a2  s.  c  om
    } else {
        int numHeaders = buffer.readInt();

        //optimize the case of no collisions to avoid any resize (it doubles the map size!!!) when load factor is reached
        properties = new HashMap<>(numHeaders, 1.0f);
        size = 0;

        for (int i = 0; i < numHeaders; i++) {
            final SimpleString key = SimpleString.readSimpleString(buffer,
                    keyValuePools == null ? null : keyValuePools.getPropertyKeysPool());

            byte type = buffer.readByte();

            PropertyValue val;

            switch (type) {
            case NULL: {
                val = NullValue.INSTANCE;
                doPutValue(key, val);
                break;
            }
            case CHAR: {
                val = new CharValue(buffer);
                doPutValue(key, val);
                break;
            }
            case BOOLEAN: {
                val = BooleanValue.of(buffer.readBoolean());
                doPutValue(key, val);
                break;
            }
            case BYTE: {
                val = ByteValue.valueOf(buffer.readByte());
                doPutValue(key, val);
                break;
            }
            case BYTES: {
                val = new BytesValue(buffer);
                doPutValue(key, val);
                break;
            }
            case SHORT: {
                val = new ShortValue(buffer);
                doPutValue(key, val);
                break;
            }
            case INT: {
                val = new IntValue(buffer);
                doPutValue(key, val);
                break;
            }
            case LONG: {
                val = new LongValue(buffer);
                doPutValue(key, val);
                break;
            }
            case FLOAT: {
                val = new FloatValue(buffer);
                doPutValue(key, val);
                break;
            }
            case DOUBLE: {
                val = new DoubleValue(buffer);
                doPutValue(key, val);
                break;
            }
            case STRING: {
                val = StringValue.readStringValue(buffer,
                        keyValuePools == null ? null : keyValuePools.getPropertyValuesPool());
                doPutValue(key, val);
                break;
            }
            default: {
                throw ActiveMQUtilBundle.BUNDLE.invalidType(type);
            }
            }
        }
    }
}