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:appeng.tile.crafting.TileCraftingMonitorTile.java

License:Open Source License

@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TileCraftingMonitorTile(final ByteBuf data) throws IOException {
    final AEColor oldPaintedColor = this.paintedColor;
    this.paintedColor = AEColor.values()[data.readByte()];

    final boolean hasItem = data.readBoolean();

    if (hasItem) {
        this.dspPlay = AEItemStack.loadItemStackFromPacket(data);
    } else {/*from  w  w  w.  j av  a 2s.  c  o m*/
        this.dspPlay = null;
    }

    this.setUpdateList(true);
    return oldPaintedColor != this.paintedColor; // tesr!
}

From source file:appeng.tile.crafting.TileMolecularAssembler.java

License:Open Source License

@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TileMolecularAssembler(final ByteBuf data) {
    final boolean oldPower = this.isPowered;
    this.isPowered = data.readBoolean();
    return this.isPowered != oldPower;
}

From source file:appeng.tile.misc.TileInterface.java

License:Open Source License

@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TileInterface(final ByteBuf data) {
    boolean oldOmniDirectional = this.omniDirectional;
    this.omniDirectional = data.readBoolean();
    return oldOmniDirectional != omniDirectional;
}

From source file:appeng.tile.misc.TileQuartzGrowthAccelerator.java

License:Open Source License

@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TileQuartzGrowthAccelerator(final ByteBuf data) {
    final boolean hadPower = this.isPowered();
    this.setPowered(data.readBoolean());
    return this.isPowered() != hadPower;
}

From source file:appeng.tile.misc.TileSecurity.java

License:Open Source License

@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TileSecurity(final ByteBuf data) {
    final boolean wasActive = this.isActive;
    this.isActive = data.readBoolean();

    final AEColor oldPaintedColor = this.paintedColor;
    this.paintedColor = AEColor.values()[data.readByte()];

    return oldPaintedColor != this.paintedColor || wasActive != this.isActive;
}

From source file:appeng.tile.misc.TileVibrationChamber.java

License:Open Source License

@Reflected
@TileEvent(TileEventType.NETWORK_READ)/*from   w  w  w .  j a va2  s  . c o m*/
public boolean hasUpdate(final ByteBuf data) {
    final boolean wasOn = this.isOn;

    this.isOn = data.readBoolean();

    return wasOn != this.isOn; // TESR doesn't need updates!
}

From source file:appeng.tile.storage.TileSkyChest.java

License:Open Source License

@TileEvent(TileEventType.NETWORK_READ)
public boolean readFromStream_TileSkyChest(final ByteBuf data) {
    final int wasOpen = this.getPlayerOpen();
    this.setPlayerOpen(data.readBoolean() ? 1 : 0);

    if (wasOpen != this.getPlayerOpen()) {
        this.setLastEvent(System.currentTimeMillis());
    }//from w  w w  .  jav  a2  s .co  m

    return false; // TESR yo!
}

From source file:at.yawk.accordion.codec.unsafe.NullableCodec.java

License:Mozilla Public License

@Override
public T decode(ByteBuf encoded) {
    if (!encoded.readBoolean()) {
        return null;
    }/*  w ww  .j a v a 2  s . c  o  m*/
    return delegate.decode(encoded);
}

From source file:at.yawk.accordion.codec.unsafe.OptionalCodec.java

License:Mozilla Public License

@Override
@SuppressWarnings("unchecked")
protected ByteCodec<Optional> createCodec(CodecSupplier registry, FieldWrapper field) {
    FieldWrapper componentType = field.genericType(0).get();
    ByteCodec componentCodec = registry.getCodecOrThrow(componentType).toByteCodec();
    return new ByteCodec<Optional>() {
        @Override/*from   w ww.j  a  va2  s.  c o m*/
        public void encode(ByteBuf target, Optional message) {
            boolean present = message.isPresent();
            target.writeBoolean(present);
            if (present) {
                componentCodec.encode(target, message.get());
            }
        }

        @Override
        public Optional decode(ByteBuf encoded) {
            boolean present = encoded.readBoolean();
            if (present) {
                Object v = componentCodec.decode(encoded);
                return Optional.of(v);
            } else {
                return Optional.empty();
            }
        }
    };
}

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

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