Example usage for io.netty.buffer ByteBuf readBoolean

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

Introduction

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

Prototype

public abstract boolean readBoolean();

Source Link

Document

Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.

Usage

From source file:blusunrize.immersiveengineering.common.util.network.MessageMinecartShaderSync.java

@Override
public void fromBytes(ByteBuf buf) {
    this.entityID = buf.readInt();
    this.request = buf.readBoolean();
    if (!request)
        this.shader = ByteBufUtils.readItemStack(buf);
}

From source file:buildcraft.builders.TileFiller.java

License:Minecraft Mod Public

public void handlePacketPayload(ByteBuf data) {
    boolean initialized = box.isInitialized();
    box.readFromStream(data);//from  ww w. j  ava 2s . c om
    done = data.readBoolean();
    setPattern((FillerPattern) FillerManager.registry.getPattern(Utils.readUTF(data)));

    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}

From source file:buildcraft.builders.TileMarker.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf stream) {
    origin.readData(stream);/*from  w w w  .  j ava2s  . c  o  m*/
    showSignals = stream.readBoolean();

    switchSignals();

    if (origin.vectO.isSet() && origin.vectO.getMarker(worldObj) != null) {
        origin.vectO.getMarker(worldObj).updateSignals();

        for (TileWrapper w : origin.vect) {
            TileMarker m = w.getMarker(worldObj);

            if (m != null) {
                m.updateSignals();
            }
        }
    }

    createLasers();
}

From source file:buildcraft.core.Box.java

License:Minecraft Mod Public

public void readFromStream(ByteBuf stream) {
    initialized = stream.readBoolean();

    xMin = stream.readInt();/*from   w ww.java 2  s  .c  o m*/
    yMin = stream.readInt();
    zMin = stream.readInt();

    xMax = stream.readInt();
    yMax = stream.readInt();
    zMax = stream.readInt();
}

From source file:buildcraft.core.LaserData.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf stream) {
    head.readData(stream);
    tail.readData(stream);
    isVisible = stream.readBoolean();
}

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

License:Minecraft Mod Public

@Override
public void readData(ByteBuf data) {
    int dim = data.readInt();
    World world = DimensionManager.getWorld(dim);
    boolean tileReturn = data.readBoolean();

    if (tileReturn) {
        int x = data.readInt();
        int y = data.readInt();
        int z = data.readInt();

        TileEntity t = world.getTileEntity(x, y, z);

        if (t instanceof IGuiReturnHandler) {
            ((IGuiReturnHandler) t).readGuiData(data, sender);
        }//from w w w  . j a  v a 2  s .c o m
    } else {
        int entityId = data.readInt();
        Entity entity = world.getEntityByID(entityId);

        if (entity instanceof IGuiReturnHandler) {
            ((IGuiReturnHandler) entity).readGuiData(data, sender);
        }
    }
}

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

License:Minecraft Mod Public

@Override
public void readData(ByteBuf data) {
    dimId = data.readShort();// w  w w  . j  ava  2  s  .co m

    x = data.readInt();
    y = data.readInt();
    z = data.readInt();
    id = data.readInt();
    moreDataToCome = data.readBoolean();
    contents = new byte[data.readableBytes()];
    data.readBytes(contents);
}

From source file:buildcraft.core.network.serializers.ClassMapping.java

License:Minecraft Mod Public

@Override
public Object read(ByteBuf data, Object o, SerializationContext context) throws IllegalArgumentException,
        IllegalAccessException, InstantiationException, ClassNotFoundException {

    if (!data.readBoolean()) {
        return null;
    } else {/*  w ww  .  ja  v  a2  s . c om*/
        if (mappedClass.isArray()) {
            return readArray(o, data, context);
        } else {
            return readClass(o, data, context);
        }
    }
}

From source file:buildcraft.core.network.serializers.ClassMapping.java

License:Minecraft Mod Public

@SuppressWarnings("rawtypes")
Object readClass(Object objI, ByteBuf data, SerializationContext context) throws IllegalArgumentException,
        IllegalAccessException, InstantiationException, ClassNotFoundException {

    Object obj = objI;/*from www .j a va 2  s.  c o  m*/

    // The data layout for an object is the following:
    // [boolean] does the object exist (e.g. non-null)
    // {false} exit
    // [int] what is the object real class?
    // {0} the same as the declared class
    // {1-x} a different one
    // [string] if the number is not yet registered, the name of the
    // class
    // [bytes] the actual contents

    int index = data.readByte();

    if (index != 0) {
        ClassMapping delegateMapping;

        if (context.idToClass.size() < index) {
            String className = Utils.readUTF(data);

            Class cls = Class.forName(className);

            delegateMapping = (ClassMapping) get(cls);

            context.idToClass.add(get(cls));
        } else {
            delegateMapping = (ClassMapping) context.idToClass.get(index - 1);
        }

        return delegateMapping.readClass(obj, data, context);
    }

    if (obj == null) {
        obj = mappedClass.newInstance();
    }

    for (Field f : shortFields) {
        f.setShort(obj, data.readShort());
    }

    for (Field f : intFields) {
        f.setInt(obj, data.readInt());
    }

    for (Field f : booleanFields) {
        f.setBoolean(obj, data.readBoolean());
    }

    for (Field f : enumFields) {
        f.set(obj, ((Class) f.getGenericType()).getEnumConstants()[data.readByte()]);
    }

    for (Field f : floatFields) {
        f.setFloat(obj, data.readFloat());
    }

    for (Field f : doubleFields) {
        f.setDouble(obj, data.readDouble());
    }

    for (FieldObject f : objectFields) {
        f.field.set(obj, f.mapping.read(data, f.field.get(obj), context));
    }

    return obj;
}

From source file:buildcraft.core.network.serializers.ClassMapping.java

License:Minecraft Mod Public

private Object readArray(Object objI, ByteBuf data, SerializationContext context)
        throws IllegalArgumentException, IllegalAccessException, InstantiationException,
        ClassNotFoundException {//  w w  w.j a  va  2 s.  c  o m
    Object obj = objI;

    Class<? extends Object> cpt = mappedClass.getComponentType();

    int size = data.readInt();

    switch (cptType) {
    case Byte: {
        byte[] arr;

        if (obj == null) {
            arr = new byte[size];
        } else {
            arr = (byte[]) obj;
        }

        data.readBytes(arr);

        obj = arr;

        break;
    }
    case Float: {
        float[] arr;

        if (obj == null) {
            arr = new float[size];
        } else {
            arr = (float[]) obj;
        }

        for (int i = 0; i < arr.length; ++i) {
            arr[i] = data.readFloat();
        }

        obj = arr;

        break;
    }
    case Double: {
        double[] arr;

        if (obj == null) {
            arr = new double[size];
        } else {
            arr = (double[]) obj;
        }

        for (int i = 0; i < arr.length; ++i) {
            arr[i] = data.readDouble();
        }

        obj = arr;

        break;
    }
    case Short: {
        short[] arr;

        if (obj == null) {
            arr = new short[size];
        } else {
            arr = (short[]) obj;
        }

        for (int i = 0; i < arr.length; ++i) {
            arr[i] = data.readShort();
        }

        obj = arr;

        break;
    }
    case Int: {
        int[] arr;

        if (obj == null) {
            arr = new int[size];
        } else {
            arr = (int[]) obj;
        }

        for (int i = 0; i < arr.length; ++i) {
            arr[i] = data.readInt();
        }

        obj = arr;

        break;
    }
    case Boolean: {
        boolean[] arr;

        if (obj == null) {
            arr = new boolean[size];
        } else {
            arr = (boolean[]) obj;
        }

        for (int i = 0; i < arr.length; ++i) {
            arr[i] = data.readBoolean();
        }

        obj = arr;

        break;
    }
    case Object: {
        Object[] arr;

        if (obj == null) {
            arr = (Object[]) Array.newInstance(cpt, size);
        } else {
            arr = (Object[]) obj;
        }

        for (int i = 0; i < arr.length; ++i) {
            arr[i] = cptMapping.read(data, arr[i], context);
        }

        obj = arr;

        break;
    }
    }

    return obj;
}