Example usage for io.netty.buffer ByteBuf writeByte

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

Introduction

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

Prototype

public abstract ByteBuf writeByte(int value);

Source Link

Document

Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.

Usage

From source file:buildcraft.core.utils.Utils.java

License:Minecraft Mod Public

/**
 * This subprogram transforms a packet into a FML packet to be send in the
 * minecraft default packet mechanism. This always use BC-CORE as a
 * channel, and as a result, should use discriminators declared there.
 *
 * WARNING! The implementation of this subprogram relies on the internal
 * behavior of #FMLIndexedMessageToMessageCodec (in particular the encode
 * member). It is probably opening a maintenance issue and should be
 * replaced eventually by some more solid mechanism.
 *//*from w  ww .  j ava2  s .com*/
public static FMLProxyPacket toPacket(BuildCraftPacket packet, int discriminator) {
    ByteBuf buf = Unpooled.buffer();

    buf.writeByte((byte) discriminator);
    packet.writeData(buf);

    return new FMLProxyPacket(buf, DefaultProps.NET_CHANNEL_NAME + "-CORE");
}

From source file:buildcraft.energy.TileEngineCreative.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf stream) {
    super.writeData(stream);
    stream.writeByte(powerMode.ordinal());
}

From source file:buildcraft.factory.gui.ContainerRefinery.java

License:Minecraft Mod Public

public void setFilter(final int slot, final Fluid filter) {

    refinery.setFilter(slot, filter);//from   ww  w .j a  v  a  2s.  c o  m

    if (refinery.getWorldObj().isRemote) {
        PacketPayload payload = new PacketPayload(new PacketPayload.StreamWriter() {
            @Override
            public void writeData(ByteBuf data) {
                data.writeByte(slot);
                data.writeShort(filter != null ? filter.getID() : -1);
            }
        });
        BuildCraftFactory.instance.sendToServer(new PacketUpdate(PacketIds.REFINERY_FILTER_SET, refinery.xCoord,
                refinery.yCoord, refinery.zCoord, payload));
    }
}

From source file:buildcraft.factory.TileFloodGate.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf stream) {
    byte flags = 0;
    for (int i = 0; i < 6; i++) {
        if (blockedSides[i]) {
            flags |= 1 << i;/*from   www . java  2s .c o m*/
        }
    }
    stream.writeByte(flags);
}

From source file:buildcraft.factory.TileMiningWell.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf stream) {
    super.writeData(stream);

    ledState = (ticksSinceAction < 2 ? 16 : 0)
            | (getBattery().getEnergyStored() * 15 / getBattery().getMaxEnergyStored());
    stream.writeByte(ledState);
}

From source file:buildcraft.factory.TileQuarry.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf stream) {
    super.writeData(stream);
    box.writeData(stream);//from  ww  w .jav  a2s.  c o m
    stream.writeInt(targetX);
    stream.writeShort(targetY);
    stream.writeInt(targetZ);
    stream.writeDouble(headPosX);
    stream.writeDouble(headPosY);
    stream.writeDouble(headPosZ);
    stream.writeFloat((float) speed);
    stream.writeFloat((float) headTrajectory);
    int flags = stage.ordinal();
    flags |= movingHorizontally ? 0x10 : 0;
    flags |= movingVertically ? 0x20 : 0;
    stream.writeByte(flags);
}

From source file:buildcraft.robotics.EntityRobot.java

License:Minecraft Mod Public

@Override
public void writeSpawnData(ByteBuf data) {
    data.writeByte(wearables.size());
    for (ItemStack s : wearables) {
        NetworkUtils.writeStack(data, s);
    }//from ww  w.  j  ava 2 s. c o  m
}

From source file:buildcraft.robotics.EntityRobot.java

License:Minecraft Mod Public

private void syncWearablesToClient() {
    BuildCraftCore.instance.sendToEntity(new PacketCommand(this, "syncWearables", new CommandWriter() {
        public void write(ByteBuf data) {
            data.writeByte(wearables.size());
            for (ItemStack s : wearables) {
                NetworkUtils.writeStack(data, s);
            }//from   ww  w .  ja va  2 s.  c o m
        }
    }), this);
}

From source file:buildcraft.robotics.TileRequester.java

License:Minecraft Mod Public

public void setRequest(final int index, final ItemStack stack) {
    if (worldObj.isRemote) {
        BuildCraftCore.instance.sendToServer(new PacketCommand(this, "setRequest", new CommandWriter() {
            public void write(ByteBuf data) {
                data.writeByte(index);
                NetworkUtils.writeStack(data, stack);
            }/*from w  w  w . j a  v a  2  s .  c  o  m*/
        }));
    } else {
        requests.setInventorySlotContents(index, stack);
    }
}

From source file:buildcraft.robotics.ZoneChunk.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf stream) {
    int flags = (fullSet ? 2 : 0) | (property != null ? 1 : 0);
    stream.writeByte(flags);
    if (property != null) {
        NetworkUtils.writeByteArray(stream, BitSetUtils.toByteArray(property));
    }//from   ww  w .jav a 2s  . c o m
}