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:org.eclipse.scada.protocol.iec60870.asdu.message.SetPointCommandShortFloatingPoint.java

License:Open Source License

@Override
public void encode(final ProtocolOptions options, final ByteBuf out) {
    EncodeHelper.encodeHeader(this, options, null, this.header, out);

    this.informationObjectAddress.encode(options, out);

    out.writeFloat(this.value);

    byte b = 0;//from  ww w.ja va 2s.  co m

    b |= this.type & 0b011111111;
    b |= this.execute ? 0 : 0b100000000;

    out.writeByte(b);
}

From source file:org.eclipse.scada.protocol.iec60870.asdu.message.SetPointCommandShortFloatingPointCP56Time2a.java

License:Open Source License

@Override
public void encode(final ProtocolOptions options, final ByteBuf out) {
    EncodeHelper.encodeHeader(this, options, null, this.header, out);

    this.informationObjectAddress.encode(options, out);

    out.writeFloat(this.value.getValue());

    byte b = 0;//ww w.  java  2 s.com

    b |= this.type & 0b011111111;
    b |= this.execute ? 0 : 0b100000000;

    out.writeByte(b);

    TypeHelper.encodeTimestamp(options, out, this.value.getTimestamp());
}

From source file:org.spongepowered.clean.network.packet.play.clientbound.PlayerAbilitiesPacket.java

License:MIT License

@Override
public void write(ByteBuf buffer) {
    buffer.writeByte(this.flags);
    buffer.writeFloat(this.fly_speed);
    buffer.writeFloat(this.fov_modifier);
}

From source file:org.spongepowered.clean.network.packet.play.clientbound.PlayerPositionAndLookPacket.java

License:MIT License

@Override
public void write(ByteBuf buffer) {
    buffer.writeDouble(this.x);
    buffer.writeDouble(this.y);
    buffer.writeDouble(this.z);
    buffer.writeFloat(this.yaw);
    buffer.writeFloat(this.pitch);
    buffer.writeByte(this.flags);
    ByteBufUtil.writeVarInt(buffer, this.teleportId);
}

From source file:org.spongepowered.clean.network.packet.play.clientbound.SetExperiencePacket.java

License:MIT License

@Override
public void write(ByteBuf buffer) {
    buffer.writeFloat(this.bar);
    ByteBufUtil.writeVarInt(buffer, this.level);
    ByteBufUtil.writeVarInt(buffer, this.total);
}

From source file:org.spongepowered.clean.network.packet.play.clientbound.UpdateHealthPacket.java

License:MIT License

@Override
public void write(ByteBuf buffer) {
    buffer.writeFloat(this.health);
    ByteBufUtil.writeVarInt(buffer, this.food);
    buffer.writeFloat(this.saturation);
}

From source file:org.spout.api.util.ByteBufUtils.java

License:Open Source License

/**
 * Writes a list of parameters (e.g. mob metadata) to the buffer.
 *
 * @param buf The buffer./* w  w w  .ja v  a 2  s .co m*/
 * @param parameters The parameters.
 */
@SuppressWarnings("unchecked")
public static void writeParameters(ByteBuf buf, List<Parameter<?>> parameters) {
    for (Parameter<?> parameter : parameters) {
        int type = parameter.getType();
        int index = parameter.getIndex();
        if (index > 0x1F) {
            throw new IllegalArgumentException("Index has a maximum of 0x1F!");
        }

        buf.writeByte(type << 5 | index & 0x1F);

        switch (type) {
        case Parameter.TYPE_BYTE:
            buf.writeByte(((Parameter<Byte>) parameter).getValue());
            break;
        case Parameter.TYPE_SHORT:
            buf.writeShort(((Parameter<Short>) parameter).getValue());
            break;
        case Parameter.TYPE_INT:
            buf.writeInt(((Parameter<Integer>) parameter).getValue());
            break;
        case Parameter.TYPE_FLOAT:
            buf.writeFloat(((Parameter<Float>) parameter).getValue());
            break;
        case Parameter.TYPE_STRING:
            writeString(buf, ((Parameter<String>) parameter).getValue());
            break;
        case Parameter.TYPE_ITEM:
            ItemStack item = ((Parameter<ItemStack>) parameter).getValue();
            buf.writeShort(item.getMaterial().getId());
            buf.writeByte(item.getAmount());
            buf.writeShort(item.getData());
            break;
        }
    }

    buf.writeByte(127);
}

From source file:org.spout.api.util.ByteBufUtils.java

License:Open Source License

public static void writeVector2(ByteBuf buf, Vector2 vec) {
    buf.writeFloat(vec.getX());
    buf.writeFloat(vec.getY());
}

From source file:org.spout.api.util.ByteBufUtils.java

License:Open Source License

public static void writeVector3(ByteBuf buffer, Vector3 vec) {
    buffer.writeFloat(vec.getX());
    buffer.writeFloat(vec.getY());// ww  w. ja  v  a 2 s  .c  o m
    buffer.writeFloat(vec.getZ());
}

From source file:org.spout.api.util.ByteBufUtils.java

License:Open Source License

public static void writePoint(ByteBuf buffer, Point vec) {
    writeUUID(buffer, vec.getWorld().getUID());
    buffer.writeFloat(vec.getX());
    buffer.writeFloat(vec.getY());/*ww  w. j  a  v a 2s  . com*/
    buffer.writeFloat(vec.getZ());
}