Example usage for io.netty.buffer ByteBuf writeDouble

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

Introduction

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

Prototype

public abstract ByteBuf writeDouble(double value);

Source Link

Document

Sets the specified 64-bit floating point number at the current writerIndex and increases the writerIndex by 8 in this buffer.

Usage

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

License:Open Source License

public PacketCompassResponse(final PacketCompassRequest req, final boolean hasResult, final boolean spin,
        final double radians) {

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeLong(this.attunement = req.attunement);
    data.writeInt(this.cx = req.cx);
    data.writeInt(this.cz = req.cz);
    data.writeInt(this.cdy = req.cdy);

    data.writeBoolean(hasResult);/*from w  w  w.java  2s  .  c om*/
    data.writeBoolean(spin);
    data.writeDouble(radians);

    this.configureWrite(data);
}

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

License:Open Source License

public PacketMockExplosion(final double x, final double y, final double z) {
    this.x = x;/*from  www.j av  a 2s  .  c o m*/
    this.y = y;
    this.z = z;

    final ByteBuf data = Unpooled.buffer();

    data.writeInt(this.getPacketID());
    data.writeDouble(x);
    data.writeDouble(y);
    data.writeDouble(z);

    this.configureWrite(data);
}

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

@Override
public void toBytes(ByteBuf buf) {
    buf.writeDouble(start.x).writeDouble(start.y).writeDouble(start.z);
    buf.writeDouble(end.x).writeDouble(end.y).writeDouble(end.z);
    buf.writeInt(startB.getX()).writeInt(startB.getY()).writeInt(startB.getZ());
    buf.writeInt(endB.getX()).writeInt(endB.getY()).writeInt(endB.getZ());
    buf.writeInt(blocking.getX()).writeInt(blocking.getY()).writeInt(blocking.getZ());
    ByteBufUtils.writeUTF8String(buf, wireType.getUniqueName());
}

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

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(entityID);/*from w  ww.j  a  v  a2s.c om*/
    ByteBufUtils.writeTag(buf, connection.writeToNBT());
    buf.writeDouble(linePos);
    buf.writeDouble(speed);
}

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

License:Open Source License

@Override
public void writeData(ByteBuf stream) {
    stream.writeDouble(x);
    stream.writeDouble(y);//from   w  w w .  jav a  2s  .com
    stream.writeDouble(z);
    stream.writeByte(orientation.ordinal());
}

From source file:buildcraft.builders.EntityMechanicalArm.java

License:Minecraft Mod Public

@Override
public void writeSpawnData(ByteBuf buffer) {
    buffer.writeDouble(root.xCoord);
    buffer.writeDouble(root.yCoord);/*from   w w  w. j  a va 2s  .  com*/
    buffer.writeDouble(root.zCoord);
    buffer.writeDouble(armSizeX);
    buffer.writeDouble(armSizeZ);
}

From source file:buildcraft.builders.TileQuarry.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf stream) {
    super.writeData(stream);
    box.writeData(stream);/* w ww  .  j  a v  a 2  s . c  om*/
    stream.writeInt(targetX);
    stream.writeShort(targetY);
    stream.writeInt(targetZ);
    stream.writeDouble(headPosX);
    stream.writeDouble(headPosY);
    stream.writeDouble(headPosZ);
    stream.writeFloat((float) speed);
    stream.writeFloat(headTrajectory);
    int flags = stage.ordinal();
    flags |= movingHorizontally ? 0x10 : 0;
    flags |= movingVertically ? 0x20 : 0;
    stream.writeByte(flags);

    ledState = (hasWork() && mode != Mode.Off && getTicksSinceEnergyReceived() < 12 ? 16 : 0)
            | (getBattery().getEnergyStored() * 15 / getBattery().getMaxEnergyStored());
    stream.writeByte(ledState);
}

From source file:buildcraft.core.builders.BuildingItem.java

License:Minecraft Mod Public

@Override
public void writeData(ByteBuf stream) {
    origin.writeData(stream);/*  w ww  .  j  a  v a 2 s  .  co  m*/
    destination.writeData(stream);
    stream.writeDouble(lifetime);
    stream.writeShort(stacksToDisplay.size());
    for (StackAtPosition s : stacksToDisplay) {
        s.writeData(stream);
    }
}

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

License:Minecraft Mod Public

@SuppressWarnings("rawtypes")
void writeClass(Object obj, ByteBuf data, SerializationContext context)
        throws IllegalArgumentException, IllegalAccessException {

    Class realClass = obj.getClass();

    if (realClass.equals(this.mappedClass)) {
        data.writeByte(0);/*from  w  w w .j a v a  2 s . co m*/
    } else {
        ClassMapping delegateMapping;

        if (context.classToId.containsKey(realClass.getCanonicalName())) {
            int index = context.classToId.get(realClass.getCanonicalName()) + 1;
            data.writeByte(index);
            delegateMapping = (ClassMapping) context.idToClass.get(index - 1);
        } else {
            int index = context.classToId.size() + 1;
            delegateMapping = (ClassMapping) get(realClass);

            data.writeByte(index);
            Utils.writeUTF(data, realClass.getCanonicalName());
            context.classToId.put(realClass.getCanonicalName(), context.classToId.size());
            context.idToClass.add(delegateMapping);
        }

        delegateMapping.writeClass(obj, data, context);

        return;
    }

    for (Field f : shortFields) {
        data.writeShort(f.getShort(obj));
    }

    for (Field f : intFields) {
        data.writeInt(f.getInt(obj));
    }

    for (Field f : booleanFields) {
        data.writeBoolean(f.getBoolean(obj));
    }

    for (Field f : enumFields) {
        data.writeByte(((Enum) f.get(obj)).ordinal());
    }

    for (Field f : floatFields) {
        data.writeFloat(f.getFloat(obj));
    }

    for (Field f : doubleFields) {
        data.writeDouble(f.getDouble(obj));
    }

    for (FieldObject f : objectFields) {
        Object cpt = f.field.get(obj);
        f.mapping.write(data, cpt, context);
    }
}

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

License:Minecraft Mod Public

private void writeArray(Object obj, ByteBuf data, SerializationContext context)
        throws IllegalArgumentException, IllegalAccessException {
    Class<? extends Object> cpt = mappedClass.getComponentType();

    switch (cptType) {
    case Byte: {
        byte[] arr = (byte[]) obj;
        data.writeInt(arr.length);/* w  w w  .jav a  2 s  . c o  m*/

        data.writeBytes(arr);

        break;
    }
    case Float: {
        float[] arr = (float[]) obj;
        data.writeInt(arr.length);

        for (float element : arr) {
            data.writeFloat(element);
        }

        break;
    }
    case Double: {
        double[] arr = (double[]) obj;
        data.writeInt(arr.length);

        for (double element : arr) {
            data.writeDouble(element);
        }

        break;
    }
    case Short: {
        short[] arr = (short[]) obj;
        data.writeInt(arr.length);

        for (short element : arr) {
            data.writeShort(element);
        }

        break;
    }
    case Int: {
        int[] arr = (int[]) obj;
        data.writeInt(arr.length);

        for (int element : arr) {
            data.writeInt(element);
        }

        break;
    }
    case Boolean: {
        boolean[] arr = (boolean[]) obj;
        data.writeInt(arr.length);

        for (boolean element : arr) {
            data.writeBoolean(element);
        }

        break;
    }
    case Object: {
        Object[] arr = (Object[]) obj;
        data.writeInt(arr.length);

        for (Object element : arr) {
            cptMapping.write(data, element, context);
        }

        break;
    }
    }
}