Example usage for io.netty.buffer ByteBuf writeFloat

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

Introduction

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

Prototype

public abstract ByteBuf writeFloat(float value);

Source Link

Document

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

Usage

From source file:com.flowpowered.engine.util.FlowByteBufUtils.java

License:MIT License

public static void writePoint(ByteBuf buffer, Point vec) {
    try {//w  w  w  .  j a va2  s.  co  m
        ByteBufUtils.writeUTF8(buffer, vec.getWorld().getName());
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
    buffer.writeFloat(vec.getBlockX());
    buffer.writeFloat(vec.getBlockY());
    buffer.writeFloat(vec.getBlockZ());
}

From source file:com.flowpowered.engine.util.FlowByteBufUtils.java

License:MIT License

public static void writeQuaternion(ByteBuf buffer, Quaternionf quaternion) {
    buffer.writeFloat(quaternion.getX());
    buffer.writeFloat(quaternion.getY());
    buffer.writeFloat(quaternion.getZ());
    buffer.writeFloat(quaternion.getW());
}

From source file:com.heliosapm.ohcrs.core.AbstractDriverCodec.java

License:Apache License

/**
 * {@inheritDoc}// w  w  w .  ja  v a2s  .  c  om
 * @see com.heliosapm.ohcrs.core.DriverCodec#write(float, io.netty.buffer.ByteBuf)
 */
@Override
public int write(final Float p, final ByteBuf b) throws SQLException {
    prefix(p, DBType.FLOAT, b);
    b.writeFloat(p);
    return b.writerIndex();
}

From source file:com.heliosapm.ohcrs.core.AbstractDriverCodec.java

License:Apache License

/**
 * {@inheritDoc}/*  w w w .j  a va  2  s .  com*/
 * @see com.heliosapm.ohcrs.core.DriverCodec#write(float, io.netty.buffer.ByteBuf)
 */
@Override
public int write(final float p, final ByteBuf b) throws SQLException {
    prefix(P, DBType.FLOAT, b);
    b.writeFloat(p);
    return b.writerIndex();
}

From source file:com.specialeffect.messages.MovePlayerMessage.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeFloat(moveAmount);
    buf.writeFloat(moveAngle);
}

From source file:com.teambr.modularsystems.storage.network.ScrollStorageCore.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeFloat(scrollValue);
}

From source file:com.theoriginalbit.moarperipherals.common.network.message.MessageGeneric.java

License:Apache License

@Override
public void toBytes(ByteBuf buf) {
    // Write any string data
    if (stringData != null) {
        buf.writeInt(stringData.length);
        for (String str : stringData) {
            ByteBufUtils.writeUTF8String(buf, str);
        }//from  w ww. jav  a  2 s  .co  m
    } else {
        buf.writeInt(0);
    }

    // Write any integer data
    if (intData != null) {
        buf.writeInt(intData.length);
        for (int i : intData) {
            buf.writeInt(i);
        }
    } else {
        buf.writeInt(0);
    }

    // Write any byte data
    if (byteData != null) {
        buf.writeInt(byteData.length);
        buf.writeBytes(byteData);
    } else {
        buf.writeInt(0);
    }

    // Write any char data
    if (charData != null) {
        buf.writeInt(charData.length);
        for (char c : charData) {
            buf.writeChar(c);
        }
    } else {
        buf.writeInt(0);
    }

    // Write any float data
    if (floatData != null) {
        buf.writeInt(floatData.length);
        for (float f : floatData) {
            buf.writeFloat(f);
        }
    } else {
        buf.writeInt(0);
    }

    // Write any double data
    if (doubleData != null) {
        buf.writeInt(doubleData.length);
        for (double d : doubleData) {
            buf.writeDouble(d);
        }
    } else {
        buf.writeInt(0);
    }

    // Write any NBT data
    if (nbtData != null) {
        buf.writeBoolean(true);
        ByteBufUtils.writeTag(buf, nbtData);
    } else {
        buf.writeBoolean(false);
    }
}

From source file:de.ellpeck.actuallyadditions.mod.network.PacketParticle.java

@Override
public void toBytes(ByteBuf buf) {
    buf.writeDouble(this.startX);
    buf.writeDouble(this.startY);
    buf.writeDouble(this.startZ);
    buf.writeDouble(this.endX);
    buf.writeDouble(this.endY);
    buf.writeDouble(this.endZ);
    buf.writeInt(this.particleAmount);
    buf.writeFloat(this.particleSize);

    for (float aColor : this.color) {
        buf.writeFloat(aColor);//  w w w  .ja  v a  2s  .  c om
    }
}

From source file:de.jackwhite20.hftp.shared.packet.ListDirectoryPacket.java

License:Open Source License

@Override
public void write(ByteBuf byteBuf) throws Exception {

    byteBuf.writeInt(listFileData.size());
    for (ListFileData data : listFileData) {
        writeString(byteBuf, data.getName());
        byteBuf.writeFloat(data.getSize());
        writeString(byteBuf, data.getHash());
        byteBuf.writeBoolean(data.isDirectory());
    }//from w  w  w.j  av a 2 s .c o  m
}

From source file:de.sanandrew.mods.betterboat.network.PacketSendBoatPos.java

License:Creative Commons License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(this.boatId);
    buf.writeDouble(this.posX);
    buf.writeDouble(this.posY);
    buf.writeDouble(this.posZ);
    buf.writeFloat(this.rotationYaw);
    buf.writeFloat(this.rotationPitch);
}