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:buildcraft.core.fluids.TankManager.java

License:Minecraft Mod Public

public void writeData(ByteBuf data) {
    for (Tank tank : tanks) {
        FluidStack fluidStack = tank.getFluid();
        if (fluidStack != null && fluidStack.getFluid() != null) {
            data.writeShort(fluidStack.getFluid().getID());
            data.writeInt(fluidStack.amount);
            data.writeInt(fluidStack.getFluid().getColor(fluidStack));
        } else {//from   w w w.  jav  a  2 s .  c  om
            data.writeShort(-1);
        }
    }
}

From source file:buildcraft.core.lib.network.base.Packet.java

License:Minecraft Mod Public

public void writeData(ByteBuf data) {
    if (dimensionId == PacketHandler.INVALID_DIM_ID)
        throw new IllegalStateException("Invalid Dimension ID!");
    data.writeInt(dimensionId);
    hasDoneByteStuff = true;/*from  w  w w .  j a  v  a2s . c om*/
}

From source file:buildcraft.core.lib.network.command.CommandTargetEntity.java

License:Minecraft Mod Public

@Override
public void write(ByteBuf data, Object target) {
    Entity entity = (Entity) target;
    data.writeInt(entity.getEntityId());
}

From source file:buildcraft.core.lib.network.command.CommandTargetTile.java

License:Minecraft Mod Public

@Override
public void write(ByteBuf data, Object target) {
    TileEntity tile = (TileEntity) target;
    data.writeInt(tile.xCoord);
    data.writeShort(tile.yCoord);//  ww w  .j  a  v  a2s . com
    data.writeInt(tile.zCoord);
}

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

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf data) {
    data.writeByte(id);
    data.writeInt(posX);
    data.writeShort(posY);
    data.writeInt(posZ);
}

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

License:Minecraft Mod Public

@Override
public void writeIdentificationData(ByteBuf data) {
    data.writeInt(entityId);
}

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);//from   w  w w .ja v  a 2 s. com
        data.writeInt(tile.xCoord);
        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.lib.network.PacketTileUpdate.java

License:Minecraft Mod Public

@Override
public void writeIdentificationData(ByteBuf data) {
    data.writeInt(posX);
    data.writeShort(posY);
    data.writeInt(posZ);
}

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

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf data) {
    data.writeByte(id);
    data.writeInt(posX);
    data.writeInt(posY);
    data.writeInt(posZ);
}

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

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf data) {
    data.writeInt(intPayload.length);
    data.writeInt(floatPayload.length);//from  ww  w  .j  av  a 2s .com
    data.writeInt(stringPayload.length);

    for (int intData : intPayload) {
        data.writeInt(intData);
    }
    for (float floatData : floatPayload) {
        data.writeFloat(floatData);
    }
    for (String stringData : stringPayload) {
        Utils.writeUTF(data, stringData);
    }
}