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:io.github.stormcloud_dev.stormcloud.frame.clientbound.CreateSlimeClientBoundFrame.java

License:Apache License

@Override
public void writeData(ByteBuf buf) {
    super.writeData(buf);
    buf.writeShort(getX());/*from   w  ww  .j  ava 2s.  c o  m*/
    buf.writeShort(getY());
    buf.writeFloat(getSize());
    buf.writeShort(getMaxHP());
    buf.writeShort(getDamage());
    buf.writeShort(getExpWorth());
    buf.writeByte(getElite());
    buf.writeShort(getEliteTier2());
    buf.writeDouble(getImageBlend());
}

From source file:io.github.stormcloud_dev.stormcloud.frame.clientbound.SpawnGhostClientBoundFrame.java

License:Apache License

@Override
public void writeData(ByteBuf buf) {
    super.writeData(buf);
    buf.writeShort(getX());/*from  www  . j av a2  s  .  co  m*/
    buf.writeShort(getY());
    buf.writeFloat(getDamageCoefficient());
    buf.writeFloat(getHealthCoefficient());
}

From source file:io.github.vastframework.codecs.primitives.EncodingPrimitiveSupport.java

License:Apache License

default void encodeFloat(ByteBuf buffer, float value) {
    buffer.writeFloat(value);
}

From source file:io.hydramq.core.type.converters.MessagePropertiesConverter.java

License:Open Source License

@Override
public void write(final ConversionContext context, final MessageProperties properties, final ByteBuf buffer) {
    int flags = 0;
    if (properties.getStringKeys().size() > 0) {
        flags = flags | HAS_STRING_PROPERTIES;
    }//from w w w.  ja v  a2  s.c o m
    if (properties.getBooleanKeys().size() > 0) {
        flags = flags | HAS_BOOLEAN_PROPERTIES;
    }
    if (properties.getIntegerKeys().size() > 0) {
        flags = flags | HAS_INTEGER_PROPERTIES;
    }
    if (properties.getLongKeys().size() > 0) {
        flags = flags | HAS_LONG_PROPERTIES;
    }
    if (properties.getFloatKeys().size() > 0) {
        flags = flags | HAS_FLOAT_PROPERTIES;
    }
    if (properties.getDoubleKeys().size() > 0) {
        flags = flags | HAS_DOUBLE_PROPERTIES;
    }
    if (properties.getBytesKeys().size() > 0) {
        flags = flags | HAS_BYTES_PROPERTIES;
    }
    if (properties.getShortKeys().size() > 0) {
        flags = flags | HAS_SHORT_PROPERTIES;
    }
    if (properties.getByteKeys().size() > 0) {
        flags = flags | HAS_BYTE_PROPERTIES;
    }
    buffer.writeInt(flags);
    if (properties.getStringKeys().size() > 0) {
        buffer.writeInt(properties.getStringKeys().size());
        for (String key : properties.getStringKeys()) {
            context.write(String.class, key, buffer);
            context.write(String.class, properties.getString(key), buffer);
        }
    }
    if (properties.getBooleanKeys().size() > 0) {
        buffer.writeInt(properties.getBooleanKeys().size());
        for (String key : properties.getBooleanKeys()) {
            context.write(String.class, key, buffer);
            buffer.writeBoolean(properties.getBoolean(key));
        }
    }
    if (properties.getIntegerKeys().size() > 0) {
        buffer.writeInt(properties.getIntegerKeys().size());
        for (String key : properties.getIntegerKeys()) {
            context.write(String.class, key, buffer);
            buffer.writeInt(properties.getInteger(key));
        }
    }
    if (properties.getLongKeys().size() > 0) {
        buffer.writeInt(properties.getLongKeys().size());
        for (String key : properties.getLongKeys()) {
            context.write(String.class, key, buffer);
            buffer.writeLong(properties.getLong(key));
        }
    }
    if (properties.getFloatKeys().size() > 0) {
        buffer.writeInt(properties.getFloatKeys().size());
        for (String key : properties.getFloatKeys()) {
            context.write(String.class, key, buffer);
            buffer.writeFloat(properties.getFloat(key));
        }
    }
    if (properties.getDoubleKeys().size() > 0) {
        buffer.writeInt(properties.getDoubleKeys().size());
        for (String key : properties.getDoubleKeys()) {
            context.write(String.class, key, buffer);
            buffer.writeDouble(properties.getDouble(key));
        }
    }
    if (properties.getBytesKeys().size() > 0) {
        buffer.writeInt(properties.getBytesKeys().size());
        for (String key : properties.getBytesKeys()) {
            context.write(String.class, key, buffer);
            context.write(byte[].class, properties.getBytes(key), buffer);
        }
    }
    if (properties.getShortKeys().size() > 0) {
        buffer.writeInt(properties.getShortKeys().size());
        for (String key : properties.getShortKeys()) {
            context.write(String.class, key, buffer);
            buffer.writeShort(properties.getShort(key));
        }
    }
    if (properties.getByteKeys().size() > 0) {
        buffer.writeInt(properties.getByteKeys().size());
        for (String key : properties.getByteKeys()) {
            context.write(String.class, key, buffer);
            buffer.writeByte(properties.getByte(key));
        }
    }
}

From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java

License:Apache License

private static void binaryEncodeFLOAT4(Number value, ByteBuf buff) {
    buff.writeFloat(value.floatValue());
}

From source file:ivorius.ivtoolkit.network.IvPacketHelper.java

License:Apache License

public static void writeNumber(ByteBuf buffer, Number number) {
    if (number instanceof Byte) {
        buffer.writeByte((Byte) number);
    } else if (number instanceof Double) {
        buffer.writeDouble((Double) number);
    } else if (number instanceof Float) {
        buffer.writeFloat((Float) number);
    } else if (number instanceof Integer) {
        buffer.writeInt((Integer) number);
    } else if (number instanceof Long) {
        buffer.writeLong((Long) number);
    } else if (number instanceof Short) {
        buffer.writeShort((Short) number);
    } else {//  w ww  .j  a v a2  s .c  o  m
        throw new IllegalArgumentException();
    }
}

From source file:jayavery.geomastery.packets.CPacketLid.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {

    buf.writeFloat(this.lidAngle);
    buf.writeFloat(this.prevLidAngle);
    buf.writeInt(this.x);
    buf.writeInt(this.y);
    buf.writeInt(this.z);
}

From source file:makeo.gadomancy.common.network.packets.PacketTCNodeBolt.java

License:LGPL

@Override
public void toBytes(ByteBuf buf) {
    buf.writeFloat(x);
    buf.writeFloat(y);//from   w w  w . ja  va2 s  .  c om
    buf.writeFloat(z);
    buf.writeFloat(targetX);
    buf.writeFloat(targetY);
    buf.writeFloat(targetZ);
}

From source file:matteroverdrive.api.weapon.WeaponShot.java

License:Open Source License

public void writeTo(ByteBuf buf) {
    buf.writeInt(seed);/* www .  j a va2s .c  om*/
    buf.writeFloat(damage);
    buf.writeFloat(accuracy);
    buf.writeInt(color);
    buf.writeShort(range);
    buf.writeByte(count);
}

From source file:matteroverdrive.entity.weapon.PlasmaBolt.java

License:Open Source License

@Override
public void writeSpawnData(ByteBuf buffer) {
    buffer.writeFloat(damage);
    buffer.writeInt(color);//from  w  w  w  . j  a  v  a  2  s .  c  om
    buffer.writeFloat(fireDamageMultiply);
    buffer.writeInt(life);
}