Example usage for io.netty.buffer ByteBuf readUnsignedByte

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

Introduction

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

Prototype

public abstract short readUnsignedByte();

Source Link

Document

Gets an unsigned byte at the current readerIndex and increases the readerIndex by 1 in this buffer.

Usage

From source file:at.yawk.accordion.distributed.InternalProtocol.java

License:Mozilla Public License

/**
 * Read a byte array written by #writeByteArray.
 *//* www.j  av  a  2s. c  o  m*/
static byte[] readByteArray(ByteBuf from) {
    byte[] array = new byte[from.readUnsignedByte()];
    from.readBytes(array);
    return array;
}

From source file:buildcraft.builders.blueprints.BlueprintId.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf stream) {
    uniqueId = Utils.readByteArray(stream);
    name = Utils.readUTF(stream);//from www . ja va  2 s.  c o  m
    kind = Kind.values()[stream.readUnsignedByte()];
}

From source file:buildcraft.builders.TileConstructionMarker.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf stream) {
    box.readData(stream);//from  w  ww . ja va 2s  .  com
    int flags = stream.readUnsignedByte();
    if ((flags & 1) != 0) {
        laser = new LaserData();
        laser.readData(stream);
    } else {
        laser = null;
    }
    if ((flags & 2) != 0) {
        itemBlueprint = Utils.readStack(stream);
    } else {
        itemBlueprint = null;
    }
}

From source file:buildcraft.builders.TilePathMarker.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf data) {
    boolean previousState = tryingToConnect;

    int flags = data.readUnsignedByte();
    if ((flags & 1) != 0) {
        lasers[0] = new LaserData();
        lasers[0].readData(data);/*from   w w w . jav  a 2 s .c om*/
    } else {
        lasers[0] = null;
    }
    if ((flags & 2) != 0) {
        lasers[1] = new LaserData();
        lasers[1].readData(data);
    } else {
        lasers[1] = null;
    }
    tryingToConnect = (flags & 4) != 0;

    if (previousState != tryingToConnect) {
        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
    }
}

From source file:buildcraft.builders.TileQuarry.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf stream) {
    super.readData(stream);
    box.readData(stream);//  ww w .  j a v  a  2  s .  co m
    targetX = stream.readInt();
    targetY = stream.readUnsignedShort();
    targetZ = stream.readInt();
    headPosX = stream.readDouble();
    headPosY = stream.readDouble();
    headPosZ = stream.readDouble();
    speed = stream.readFloat();
    headTrajectory = stream.readFloat();
    int flags = stream.readUnsignedByte();
    stage = Stage.values()[flags & 0x07];
    movingHorizontally = (flags & 0x10) != 0;
    movingVertically = (flags & 0x20) != 0;
    int newLedState = stream.readUnsignedByte();
    if (newLedState != ledState) {
        ledState = newLedState;
        worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
    }

    createUtilsIfNeeded();

    if (arm != null) {
        arm.setHead(headPosX, headPosY, headPosZ);
        arm.updatePosition();
    }
}

From source file:buildcraft.commander.ContainerZonePlan.java

License:Minecraft Mod Public

@Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
    if (side.isClient()) {
        if ("areaLoaded".equals(command)) {
            currentAreaSelection = new ZonePlan();
            currentAreaSelection.readData(stream);
            gui.refreshSelectedArea();/*from   w w w .j a  va  2 s . c o m*/
        } else if ("receiveImage".equals(command)) {
            int size = stream.readUnsignedMedium();

            for (int i = 0; i < size; ++i) {
                mapTexture.colorMap[i] = 0xFF000000
                        | MapColor.mapColorArray[stream.readUnsignedByte()].colorValue;
            }
        }
    } else if (side.isServer()) {
        if ("loadArea".equals(command)) {
            final int index = stream.readUnsignedByte();
            BuildCraftCore.instance.sendToPlayer((EntityPlayer) sender,
                    new PacketCommand(this, "areaLoaded", new CommandWriter() {
                        public void write(ByteBuf data) {
                            map.selectArea(index).writeData(data);
                        }
                    }));
        } else if ("saveArea".equals(command)) {
            final int index = stream.readUnsignedByte();
            ZonePlan plan = new ZonePlan();
            plan.readData(stream);
            map.setArea(index, plan);
        } else if ("computeMap".equals(command)) {
            computeMap(stream.readInt(), stream.readInt(), stream.readUnsignedShort(),
                    stream.readUnsignedShort(), stream.readUnsignedByte(), (EntityPlayer) sender);
        }
    }
}

From source file:buildcraft.commander.TileRequester.java

License:Minecraft Mod Public

@Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
    if (side.isServer() && "setRequest".equals(command)) {
        setRequest(stream.readUnsignedByte(), Utils.readStack(stream));
    }/* www . j a  va  2s  .c  om*/
}

From source file:buildcraft.core.blueprints.BlueprintReadConfiguration.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf stream) {
    int flags = stream.readUnsignedByte();
    rotate = (flags & 1) != 0;/* w w  w  .  ja v a 2 s  . co  m*/
    excavate = (flags & 2) != 0;
    allowCreative = (flags & 4) != 0;
}

From source file:buildcraft.core.gui.ContainerList.java

License:Minecraft Mod Public

@Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
    if (side.isServer()) {
        if ("setLabel".equals(command)) {
            setLabel(Utils.readUTF(stream));
        } else if ("switchButton".equals(command)) {
            switchButton(stream.readUnsignedByte(), stream.readUnsignedByte());
        } else if ("setStack".equals(command)) {
            setStack(stream.readUnsignedByte(), stream.readUnsignedByte(), Utils.readStack(stream));
        }/*from  w  w w. j a  v a2s .  com*/
    }
}

From source file:buildcraft.core.lib.engines.TileEngineBase.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf stream) {
    int flags = stream.readUnsignedByte();
    energyStage = EnergyStage.values()[flags & 0x07];
    isPumping = (flags & 0x08) != 0;
    orientation = ForgeDirection.getOrientation(stream.readByte());
}