Example usage for io.netty.buffer ByteBuf writeInt

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

Introduction

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

Prototype

public abstract ByteBuf writeInt(int value);

Source Link

Document

Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.

Usage

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   www .j  a v a  2s  .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.");
    }/*w w w . j  ava 2s  .c o 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   w  w  w . jav  a  2s  . 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  .  ja  v a2 s.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;//from   w w w .  ja va  2 s.c  om
    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;//from  w  w w . java  2  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);
}

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   w  w  w  .  j  a va  2s . c  o  m*/

    this.configureWrite(data);
}