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.spout.api.util.ByteBufUtils.java

License:Open Source License

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

From source file:org.spout.vanilla.protocol.codec.entity.SteerVehicleCodec.java

License:Open Source License

@Override
public ByteBuf encode(SteerVehicleMessage message) throws IOException {
    ByteBuf buffer = Unpooled.buffer(11);
    buffer.writeFloat(message.getSideways());
    buffer.writeFloat(message.getForward());
    buffer.writeByte(message.isJumping() ? 1 : 0);
    buffer.writeByte(message.isUnmount() ? 1 : 0);
    return buffer;
}

From source file:org.spout.vanilla.protocol.codec.player.PlayerAbilityCodec.java

License:Open Source License

@Override
public ByteBuf encode(PlayerAbilityMessage message) throws IOException {
    ByteBuf buffer = Unpooled.buffer(10);
    byte flag = 0;
    flag = LogicUtil.setBit(flag, 0x1, message.isGodMode());
    flag = LogicUtil.setBit(flag, 0x2, message.isFlying());
    flag = LogicUtil.setBit(flag, 0x4, message.canFly());
    flag = LogicUtil.setBit(flag, 0x8, message.isCreativeMode());
    buffer.writeByte(flag);/*from   w  w w.  j ava2  s  .c o  m*/
    buffer.writeFloat(message.getFlyingSpeed());
    buffer.writeFloat(message.getWalkingSpeed());
    return buffer;
}

From source file:org.spout.vanilla.protocol.codec.player.PlayerExperienceCodec.java

License:Open Source License

@Override
public ByteBuf encode(PlayerExperienceMessage message) throws IOException {
    ByteBuf buffer = Unpooled.buffer(8);
    buffer.writeFloat(message.getBarValue());
    buffer.writeShort(message.getLevel());
    buffer.writeShort(message.getTotalExp());
    return buffer;
}

From source file:org.spout.vanilla.protocol.codec.player.PlayerHealthCodec.java

License:Open Source License

@Override
public ByteBuf encode(PlayerHealthMessage message) throws IOException {
    ByteBuf buffer = Unpooled.buffer(11);
    buffer.writeFloat(message.getHealth());
    buffer.writeShort(message.getFood());
    buffer.writeFloat(message.getFoodSaturation());
    return buffer;
}

From source file:org.spout.vanilla.protocol.codec.player.pos.PlayerLookCodec.java

License:Open Source License

@Override
public ByteBuf encode(PlayerLookMessage message) throws IOException {
    ByteBuf buffer = Unpooled.buffer(9);
    buffer.writeFloat(-message.getYaw());
    buffer.writeFloat(message.getPitch());
    buffer.writeByte(message.isOnGround() ? 1 : 0);
    return buffer;
}

From source file:org.spout.vanilla.protocol.codec.player.pos.PlayerPositionLookCodec.java

License:Open Source License

@Override
public ByteBuf encode(PlayerPositionLookMessage message) throws IOException {
    ByteBuf buffer = Unpooled.buffer(41);
    buffer.writeDouble(message.getX());//from   ww w .  j ava  2 s  .c o  m
    buffer.writeDouble(message.getY());
    buffer.writeDouble(message.getStance());
    buffer.writeDouble(message.getZ());
    buffer.writeFloat(-message.getYaw());
    buffer.writeFloat(message.getPitch());
    buffer.writeByte(message.isOnGround() ? 1 : 0);
    return buffer;
}

From source file:org.spout.vanilla.protocol.codec.world.ExplosionCodec.java

License:Open Source License

@Override
public ByteBuf encode(ExplosionMessage message) throws IOException {
    ByteBuf buffer = Unpooled.buffer();
    buffer.writeDouble(message.getX());//  w  w  w.j  av  a  2s. c  o  m
    buffer.writeDouble(message.getY());
    buffer.writeDouble(message.getZ());
    buffer.writeFloat(message.getRadius());
    buffer.writeInt(message.getRecords());
    buffer.writeBytes(message.getCoordinates());
    buffer.writeFloat(0.0f); // unknown (x?)
    buffer.writeFloat(0.0f); // unknown (y?)
    buffer.writeFloat(0.0f); // unknown (z?)
    return buffer;
}

From source file:org.spout.vanilla.protocol.codec.world.ParticleEffectCodec.java

License:Open Source License

@Override
public ByteBuf encode(ParticleEffectMessage message) throws IOException {
    ByteBuf buffer = Unpooled.buffer();
    VanillaByteBufUtils.writeString(buffer, message.getName());
    buffer.writeFloat(message.getX());
    buffer.writeFloat(message.getY());/* www  .ja v  a2s  . co m*/
    buffer.writeFloat(message.getZ());
    buffer.writeFloat(message.getXOffset());
    buffer.writeFloat(message.getYOffset());
    buffer.writeFloat(message.getZOffset());
    buffer.writeFloat(message.getVelocity());
    buffer.writeInt(message.getAmount());
    return buffer;
}

From source file:org.spout.vanilla.protocol.codec.world.SoundEffectCodec.java

License:Open Source License

@Override
public ByteBuf encode(SoundEffectMessage message) throws IOException {
    ByteBuf buffer = Unpooled.buffer();
    VanillaByteBufUtils.writeString(buffer, message.getSoundName());
    buffer.writeInt((int) (message.getX() * 8.0f));
    buffer.writeInt((int) (message.getY() * 8.0f));
    buffer.writeInt((int) (message.getZ() * 8.0f));
    buffer.writeFloat(message.getVolume());
    buffer.writeByte((byte) (message.getPitch() * 63f));
    return buffer;
}