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.PacketCompassRequest.java

License:Open Source License

public PacketCompassRequest(final long attunement, final int cx, final int cz, final int cdy) {

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeLong(this.attunement = attunement);
    data.writeInt(this.cx = cx);
    data.writeInt(this.cz = cz);
    data.writeInt(this.cdy = cdy);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketCompassResponse(final PacketCompassRequest req, final boolean hasResult, final boolean spin,
        final double radians) {

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeLong(this.attunement = req.attunement);
    data.writeInt(this.cx = req.cx);
    data.writeInt(this.cz = req.cz);
    data.writeInt(this.cdy = req.cdy);

    data.writeBoolean(hasResult);/*from w ww  .j  a v  a2  s .  c  o m*/
    data.writeBoolean(spin);
    data.writeDouble(radians);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketConfigButton(final Settings option, final boolean rotationDirection) {
    this.option = option;
    this.rotationDirection = rotationDirection;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(option.ordinal());/*from ww w  .  ja  v  a  2s.co m*/
    data.writeBoolean(rotationDirection);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketCraftRequest(final int craftAmt, final boolean shift) {
    this.amount = craftAmt;
    this.heldShift = shift;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeBoolean(shift);//from  ww  w.ja  v  a2s .  c o m
    data.writeLong(this.amount);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketInventoryAction(final InventoryAction action, final int slot, final IAEItemStack slotItem)
        throws IOException {

    if (Platform.isClient()) {
        throw new IllegalStateException("invalid packet, client cannot post inv actions with stacks.");
    }/*from  w  w  w  .j av a 2s.  co m*/

    this.action = action;
    this.slot = slot;
    this.id = 0;
    this.slotItem = slotItem;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(action.ordinal());
    data.writeInt(slot);
    data.writeLong(this.id);

    if (slotItem == null) {
        data.writeBoolean(false);
    } else {
        data.writeBoolean(true);
        slotItem.writeToPacket(data);
    }

    this.configureWrite(data);
}

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

License:Open Source License

public PacketInventoryAction(final InventoryAction action, final int slot, final long id) {
    this.action = action;
    this.slot = slot;
    this.id = id;
    this.slotItem = null;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeInt(action.ordinal());/*from   www  . j ava2  s  .  c  o m*/
    data.writeInt(slot);
    data.writeLong(id);
    data.writeBoolean(false);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketJEIRecipe(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.PacketLightning.java

License:Open Source License

public PacketLightning(final double x, final double y, final double z) {
    this.x = x;/*from w  ww.  j  a  va  2s. c  o m*/
    this.y = y;
    this.z = z;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeFloat((float) x);
    data.writeFloat((float) y);
    data.writeFloat((float) z);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketMatterCannon(final double x, final double y, final double z, final float dx, final float dy,
        final float dz, final byte len) {
    final float dl = dx * dx + dy * dy + dz * dz;
    final float dlz = (float) Math.sqrt(dl);

    this.x = x;//w  w w  . j  a  v  a 2  s .c  o  m
    this.y = y;
    this.z = z;
    this.dx = dx / dlz;
    this.dy = dy / dlz;
    this.dz = dz / dlz;
    this.len = len;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeFloat((float) x);
    data.writeFloat((float) y);
    data.writeFloat((float) z);
    data.writeFloat((float) this.dx);
    data.writeFloat((float) this.dy);
    data.writeFloat((float) this.dz);
    data.writeByte(len);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketMockExplosion(final double x, final double y, final double z) {
    this.x = x;/*  w w  w .j a  v a2 s. c o m*/
    this.y = y;
    this.z = z;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeDouble(x);
    data.writeDouble(y);
    data.writeDouble(z);

    this.configureWrite(data);
}