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:com.blogspot.jabelarminecraft.blocksmith.proxy.CommonProxy.java

License:Open Source License

public void convertItemStackListToPayload(ByteBuf parBuffer) {
    Iterator theIterator = itemStackRegistry.iterator();

    while (theIterator.hasNext()) {
        ItemStack theStack = (ItemStack) theIterator.next();

        // write item id and metadata
        parBuffer.writeInt(Item.getIdFromItem(theStack.getItem()));
        parBuffer.writeInt(theStack.getMetadata());

        //            // DEBUG
        //            System.out.println(Item.getIdFromItem(theStack.getItem())+" "+theStack.getMetadata());
        boolean hasNBT = theStack.hasTagCompound();
        parBuffer.writeBoolean(hasNBT);
        if (hasNBT) {
            // DEBUG
            System.out.println(/*  w  w w  .  j a  v  a2  s  .c  o  m*/
                    "The stack " + theStack.toString() + " has NBT = " + theStack.getTagCompound().toString());
            ByteBufUtils.writeTag(parBuffer, theStack.getTagCompound());
        }
        theIterator.remove(); // avoids a ConcurrentModificationException
    }

    return;
}

From source file:com.bluepowermod.network.message.MessageCircuitDatabaseTemplate.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {

    super.toBytes(buf);
    ByteBufUtils.writeItemStack(buf, stack);
    buf.writeBoolean(deleting);
}

From source file:com.builtbroken.assemblyline.content.belt.TilePipeBelt.java

@Override
public void writeDescPacket(ByteBuf buf) {
    super.writeDescPacket(buf);
    buf.writeInt(type.ordinal());/*from   w w w . j  a v  a  2  s . com*/
    buf.writeBoolean(shouldUpdateRender);
    buf.writeBoolean(shouldEjectItems);
    buf.writeBoolean(pullItems);
    buf.writeBoolean(renderTop);
    writeInvPacket(buf);
    buf.writeBoolean(beltSideData != null);
    if (beltSideData != null) {
        NBTTagCompound tag = new NBTTagCompound();
        tag.setTag("beltStates", saveBeltState());
        ByteBufUtils.writeTag(buf, tag);
    }
}

From source file:com.builtbroken.assemblyline.content.belt.TilePipeBelt.java

@Override
protected void writeGuiPacket(EntityPlayer player, ByteBuf buf) {
    buf.writeBoolean(shouldEjectItems);
    buf.writeBoolean(pullItems);//from   w w  w .  j  av  a 2 s .c  o m
    buf.writeBoolean(renderTop);
}

From source file:com.builtbroken.assemblyline.content.inserter.TileInsertArm.java

@Override
public void writeDescPacket(ByteBuf buf) {
    super.writeDescPacket(buf);
    rotation.writeBytes(buf);/* w w  w .j ava 2 s.  com*/
    buf.writeBoolean(getHeldItem() != null);
    if (getHeldItem() != null) {
        ByteBufUtils.writeItemStack(buf, getHeldItem());
    }
}

From source file:com.builtbroken.assemblyline.content.rail.powered.TilePowerRail.java

@Override
public void writeDescPacket(ByteBuf buf) {
    buf.writeInt(railType.ordinal());/*from   w w w  .  ja  va 2 s  . co  m*/
    buf.writeInt(getFacingDirection().ordinal());
    if (isRotationRail()) {
        buf.writeBoolean(rotateToAngle);
        buf.writeBoolean(rotateClockwise);
        buf.writeInt(rotateYaw);
    } else if (isStopRail()) {
        buf.writeBoolean(stopCarts);
    } else if (isLoaderRail() || isUnloadRail()) {
        buf.writeBoolean(rotateClockwise);
    }
}

From source file:com.builtbroken.atomic.network.packet.PacketBase.java

/**
 * Called to write data without manually defining the write
 *
 * @param object - object to write//from ww w.j a v a 2 s.c om
 * @param buffer - location to write to
 */
protected void writeData(Object object, ByteBuf buffer) {
    if (object.getClass().isArray()) {
        for (int i = 0; i < Array.getLength(object); i++) {
            writeData(Array.get(object, i), buffer);
        }
    } else if (object instanceof Collection) {
        for (Object o : (Collection) object) {
            writeData(o, buffer);
        }
    } else if (object instanceof Byte) {
        buffer.writeByte((Byte) object);
    } else if (object instanceof Integer) {
        buffer.writeInt((Integer) object);
    } else if (object instanceof Short) {
        buffer.writeShort((Short) object);
    } else if (object instanceof Long) {
        buffer.writeLong((Long) object);
    } else if (object instanceof Float) {
        buffer.writeFloat((Float) object);
    } else if (object instanceof Double) {
        buffer.writeDouble((Double) object);
    } else if (object instanceof Boolean) {
        buffer.writeBoolean((Boolean) object);
    } else if (object instanceof String) {
        ByteBufUtils.writeUTF8String(buffer, (String) object);
    } else if (object instanceof NBTTagCompound) {
        ByteBufUtils.writeTag(buffer, (NBTTagCompound) object);
    } else if (object instanceof ItemStack) {
        ByteBufUtils.writeItemStack(buffer, (ItemStack) object);
    } else if (object instanceof FluidTank) {
        ByteBufUtils.writeTag(buffer, ((FluidTank) object).writeToNBT(new NBTTagCompound()));
    } else if (object instanceof Pos) {
        ((Pos) object).writeByteBuf(buffer);
    } else if (object instanceof IByteBufWriter) {
        ((IByteBufWriter) object).writeBytes(buffer);
    } else if (object instanceof Enum) {
        buffer.writeInt(((Enum) object).ordinal());
    } else {
        throw new IllegalArgumentException("PacketBase: Unsupported write data type " + object);
    }
}

From source file:com.builtbroken.atomic.network.packet.trigger.PacketMouse.java

@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
    buffer.writeInt(slot);//from ww  w .j a va2  s.  co  m
    buffer.writeBoolean(forward);
    buffer.writeBoolean(ctrl);
}

From source file:com.builtbroken.comecloser.network.SyncSettings.java

@Override
public void toBytes(ByteBuf buf) {
    buf.writeFloat(min);
    buf.writeFloat(max);
    buf.writeBoolean(doRay);
}

From source file:com.builtbroken.grappling.content.entity.EntityHook.java

@Override
public void writeSpawnData(ByteBuf buffer) {
    buffer.writeBoolean(hook != null);
    if (hook != null) {
        hook.write(buffer);//  w w  w  .ja  v  a  2s .co m
    }
}