Example usage for io.netty.buffer ByteBuf writeBoolean

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

Introduction

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

Prototype

public abstract ByteBuf writeBoolean(boolean value);

Source Link

Document

Sets the specified boolean at the current writerIndex and increases the writerIndex by 1 in this buffer.

Usage

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

@Override
public void toBytes(ByteBuf buf) {
    buf.writeBoolean(this.forward);
}

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

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(this.entityID);
    buf.writeBoolean(this.request);
    if (!request)
        ByteBufUtils.writeItemStack(buf, this.shader);
}

From source file:buildcraft.builders.gui.GuiFiller.java

License:Minecraft Mod Public

@Override
protected void actionPerformed(GuiButton button) {
    super.actionPerformed(button);

    if (button.id == 0) {
        filler.currentPattern = (FillerPattern) FillerManager.registry
                .getPreviousPattern(filler.currentPattern);
    } else if (button.id == 1) {
        filler.currentPattern = (FillerPattern) FillerManager.registry.getNextPattern(filler.currentPattern);
    } else if (button.id == 2) {
        filler.setExcavate(!filler.isExcavate());

        buttonList.set(2, getExcavateButton());

        BuildCraftCore.instance.sendToServer(new PacketCommand(filler, "setFlags", new CommandWriter() {
            public void write(ByteBuf data) {
                data.writeBoolean(filler.isExcavate());
            }/*from   w w  w .jav  a 2  s.  com*/
        }));
    }

    filler.rpcSetPatternFromString(filler.currentPattern.getUniqueTag());
}

From source file:buildcraft.builders.TileFiller.java

License:Minecraft Mod Public

@Override
public PacketPayload getPacketPayload() {
    PacketPayload payload = new PacketPayload(new PacketPayload.StreamWriter() {
        @Override//w  w w. ja  va  2 s. co  m
        public void writeData(ByteBuf data) {
            box.writeToStream(data);
            data.writeBoolean(done);
            Utils.writeUTF(data, currentPattern.getUniqueTag());
        }
    });

    return payload;
}

From source file:buildcraft.builders.TileMarker.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf stream) {
    origin.writeData(stream);
    stream.writeBoolean(showSignals);
}

From source file:buildcraft.core.Box.java

License:Minecraft Mod Public

public void writeToStream(ByteBuf stream) {
    stream.writeBoolean(initialized);

    stream.writeInt(xMin);/*from   w  w  w . j a va  2 s  . c o  m*/
    stream.writeInt(yMin);
    stream.writeInt(zMin);

    stream.writeInt(xMax);
    stream.writeInt(yMax);
    stream.writeInt(zMax);
}

From source file:buildcraft.core.LaserData.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf stream) {
    head.writeData(stream);
    tail.writeData(stream);
    stream.writeBoolean(isVisible);
}

From source file:buildcraft.core.lib.network.PacketGuiReturn.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf data) {
    data.writeInt(obj.getWorld().provider.dimensionId);

    if (obj instanceof TileEntity) {
        TileEntity tile = (TileEntity) obj;
        data.writeBoolean(true);
        data.writeInt(tile.xCoord);/*w  ww  . j  a  v a  2  s. c  o m*/
        data.writeInt(tile.yCoord);
        data.writeInt(tile.zCoord);
    } else if (obj instanceof Entity) {
        Entity entity = (Entity) obj;
        data.writeBoolean(false);
        data.writeInt(entity.getEntityId());
    } else {
        return;
    }

    obj.writeGuiData(data);

    if (extraData != null) {
        data.writeBytes(extraData);
    }
}

From source file:buildcraft.core.network.PacketRPCTile.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf data) {
    // In order to save space on message, we assuming dimensions ids
    // small. Maybe worth using a varint instead
    data.writeShort(tile.getWorldObj().provider.dimensionId);
    data.writeInt(tile.xCoord);/*from   www . java  2 s. c o  m*/
    data.writeInt(tile.yCoord);
    data.writeInt(tile.zCoord);

    data.writeInt(id);
    data.writeBoolean(moreDataToCome);
    data.writeBytes(contents);
}

From source file:buildcraft.core.network.serializers.ClassMapping.java

License:Minecraft Mod Public

/**
 * This class will update data in an object from a stream. Public data
 * market #NetworkData will get synchronized. The following rules will
 * apply://from   w  w w  .j a v a 2s. c  om
 *
 * In the following description, we consider strings as primitive objects.
 *
 * Market primitives data will be directly updated on the destination
 * object after the value of the source object
 *
 * Market primitive arrays will be re-created in the destination object
 * after the primitive array of the source object. This means that array
 * references are not preserved by the proccess. If an array is null
 * in the source array and not in the destination one, it will be turned to
 * null.
 *
 * Market object will be synchronized - that it we do not create new
 * instances in the destination object if they are already there but rather
 * recursively synchronize values. If destination is null and not
 * source, the destination will get the instance created. If destination is
 * not null and source is, the destination will get truned to null.
 *
 * Market object arrays will be synchronized - not re-created. If
 * destination is null and not source, the destination will get the instance
 * created. If destination is not null and source is, the destination will
 * get turned to null. The same behavior applies to the contents of the
 * array. Trying to synchronize two arrays of different size is an error
 * and will lead to an exception - so if the array needs to change on the
 * destination it needs to be set to null first.
 *
 * WARNINGS
 *
 *  - only public non-final fields can be serialized
 *  - non static nested classes are not supported
 *  - no reference analysis is done, e.g. an object referenced twice will
 *    be serialized twice
 */
@Override
public void write(ByteBuf data, Object o, SerializationContext context)
        throws IllegalArgumentException, IllegalAccessException {
    if (o == null) {
        data.writeBoolean(false);
    } else {
        data.writeBoolean(true);

        if (mappedClass.isArray()) {
            writeArray(o, data, context);
        } else {
            writeClass(o, data, context);
        }
    }
}