Example usage for io.netty.buffer ByteBuf readDouble

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

Introduction

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

Prototype

public abstract double readDouble();

Source Link

Document

Gets a 64-bit floating point number at the current readerIndex and increases the readerIndex by 8 in this buffer.

Usage

From source file:appeng.core.sync.packets.PacketCompassResponse.java

License:Open Source License

public PacketCompassResponse(final ByteBuf stream) {
    this.attunement = stream.readLong();
    this.cx = stream.readInt();
    this.cz = stream.readInt();
    this.cdy = stream.readInt();

    this.cr = new CompassResult(stream.readBoolean(), stream.readBoolean(), stream.readDouble());
}

From source file:appeng.core.sync.packets.PacketMockExplosion.java

License:Open Source License

public PacketMockExplosion(final ByteBuf stream) {
    this.x = stream.readDouble();
    this.y = stream.readDouble();
    this.z = stream.readDouble();
}

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

@Override
public void fromBytes(ByteBuf buf) {
    start = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
    end = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble());
    startB = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
    endB = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
    blocking = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
    wireType = WireType.getValue(ByteBufUtils.readUTF8String(buf));
}

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

@Override
public void fromBytes(ByteBuf buf) {
    entityID = buf.readInt();//ww w. j a v  a 2  s  .  c o  m
    NBTTagCompound tag = ByteBufUtils.readTag(buf);
    connection = Connection.readFromNBT(tag);
    linePos = buf.readDouble();
    speed = buf.readDouble();
}

From source file:buildcraft.api.core.Position.java

License:Open Source License

@Override
public void readData(ByteBuf stream) {
    x = stream.readDouble();
    y = stream.readDouble();//w  ww . j av a  2  s. c om
    z = stream.readDouble();
    orientation = ForgeDirection.getOrientation(stream.readByte());
}

From source file:buildcraft.builders.EntityMechanicalArm.java

License:Minecraft Mod Public

@Override
public void readSpawnData(ByteBuf buffer) {
    root = new Vec3d(buffer.readDouble(), buffer.readDouble(), buffer.readDouble());
    armSizeX = buffer.readDouble();//from w  w  w .  ja v  a  2  s . c  o m
    armSizeZ = buffer.readDouble();
    setArmSize(armSizeX, armSizeZ);
    updatePosition();
}

From source file:buildcraft.builders.TileQuarry.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf stream) {
    super.readData(stream);
    box.readData(stream);//from w w w . jav  a  2  s . c  om
    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.core.builders.BuildingItem.java

License:Minecraft Mod Public

@Override
public void readData(ByteBuf stream) {
    origin = new Position();
    destination = new Position();
    origin.readData(stream);/*  w w  w. j a v a  2s  .  c  o m*/
    destination.readData(stream);
    lifetime = stream.readDouble();
    stacksToDisplay.clear();
    int size = stream.readUnsignedShort();
    for (int i = 0; i < size; i++) {
        StackAtPosition e = new StackAtPosition();
        e.readData(stream);
        stacksToDisplay.add(e);
    }
}

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;// w ww. j  a  va2  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 .  ja va  2  s .c  om
    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;
}