Example usage for io.netty.buffer Unpooled buffer

List of usage examples for io.netty.buffer Unpooled buffer

Introduction

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

Prototype

public static ByteBuf buffer() 

Source Link

Document

Creates a new big-endian Java heap buffer with reasonably small initial capacity, which expands its capacity boundlessly on demand.

Usage

From source file:appeng.core.sync.packets.PacketMultiPart.java

License:Open Source License

public PacketMultiPart() {
    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketNEIRecipe.java

License:Open Source License

public PacketNEIRecipe(final NBTTagCompound recipe) throws IOException {
    final ByteBuf data = Unpooled.buffer();

    final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    final DataOutputStream outputStream = new DataOutputStream(bytes);

    data.writeInt(this.getPacketID());

    CompressedStreamTools.writeCompressed(recipe, outputStream);
    data.writeBytes(bytes.toByteArray());

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketNewStorageDimension.java

License:Open Source License

public PacketNewStorageDimension(final int newDim) {
    this.newDim = newDim;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(newDim);//from  ww  w . j a  v  a2 s .c o  m

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketPaintedEntity.java

License:Open Source License

public PacketPaintedEntity(final int myEntity, final AEColor myColor, final int ticksLeft) {

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(this.entityId = myEntity);
    data.writeByte((this.myColor = myColor).ordinal());
    data.writeInt(ticksLeft);//from w  w  w  .j a  v a2 s.  c o  m

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketPartialItem.java

License:Open Source License

public PacketPartialItem(final int page, final int maxPages, final byte[] buf) {

    final ByteBuf data = Unpooled.buffer();

    this.pageNum = (short) (page | (maxPages << 8));
    this.data = buf;
    data.writeInt(this.getPacketID());
    data.writeShort(this.pageNum);
    data.writeBytes(buf);//w  w  w. j  av a  2s . c o m

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketPartPlacement.java

License:Open Source License

public PacketPartPlacement(final BlockPos pos, final EnumFacing face, final float eyeHeight,
        final EnumHand hand) {
    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(pos.getX());/*from w  ww  .jav a  2  s  .  c  o m*/
    data.writeInt(pos.getY());
    data.writeInt(pos.getZ());
    data.writeByte(face.ordinal());
    data.writeFloat(eyeHeight);
    data.writeByte(hand.ordinal());

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketPatternSlot.java

License:Open Source License

public PacketPatternSlot(final IInventory pat, final IAEItemStack slotItem, final boolean shift)
        throws IOException {

    this.slotItem = slotItem;
    this.shift = shift;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());

    data.writeBoolean(shift);//from  w  w  w. ja  v  a  2 s . c  om

    this.writeItem(slotItem, data);
    for (int x = 0; x < 9; x++) {
        this.pattern[x] = AEApi.instance().storage().createItemStack(pat.getStackInSlot(x));
        this.writeItem(this.pattern[x], data);
    }

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketProgressBar.java

License:Open Source License

public PacketProgressBar(final int shortID, final long value) {
    this.id = (short) shortID;
    this.value = value;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeShort(shortID);/*from w  w w.j a v a 2  s. c  o  m*/
    data.writeLong(value);

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketSwapSlots.java

License:Open Source License

public PacketSwapSlots(final int slotA, final int slotB) {
    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(this.slotA = slotA);
    data.writeInt(this.slotB = slotB);

    this.configureWrite(data);
}

From source file:appeng.core.sync.packets.PacketSwitchGuis.java

License:Open Source License

public PacketSwitchGuis(final GuiBridge newGui) {
    this.newGui = newGui;

    if (Platform.isClient()) {
        AEBaseGui.setSwitchingGuis(true);
    }/*  www.j a  va 2s  . c  o m*/

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(newGui.ordinal());

    this.configureWrite(data);
}