List of usage examples for io.netty.buffer ByteBuf writeDouble
public abstract ByteBuf writeDouble(double value);
From source file:org.spout.vanilla.protocol.codec.player.pos.PlayerPositionCodec.java
License:Open Source License
@Override public ByteBuf encode(PlayerPositionMessage message) throws IOException { ByteBuf buffer = Unpooled.buffer(33); buffer.writeDouble(message.getX()); buffer.writeDouble(message.getY());//from ww w .j ava 2s. co m buffer.writeDouble(message.getStance()); buffer.writeDouble(message.getZ()); 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()); buffer.writeDouble(message.getY());/* ww w . j a v a 2 s . c om*/ 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()); buffer.writeDouble(message.getY());/*from w ww .j ava 2 s . c o m*/ 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.spoutcraft.client.network.codec.play.PositionLookCodec.java
License:MIT License
@Override public ByteBuf encode(ByteBuf buf, PositionLookMessage message) throws IOException { buf.writeDouble(message.getX()); buf.writeDouble(message.getStance()); buf.writeDouble(message.getY());//from www . ja v a 2s. c o m buf.writeDouble(message.getZ()); buf.writeFloat(message.getYaw()); buf.writeFloat(message.getPitch()); buf.writeBoolean(message.isOnGround()); return buf; }
From source file:org.starmod.net.object.field.type.NetworkDouble.java
License:MIT License
@Override public void encode(ByteBuf buf) { buf.writeDouble(getValue()); }
From source file:org.starnub.starbounddata.packets.server.UniverseTimeUpdatePacket.java
License:Open Source License
/** * Recommended: For internal use with StarNub Player Sessions * <p>// w ww . j av a 2s .c o m * Uses: This method will write to a {@link io.netty.buffer.ByteBuf} using this packets fields * <p> * * @param out ByteBuf representing the space to write out the packet reason */ @Override public void write(ByteBuf out) { out.writeDouble(universeTime); }
From source file:org.starnub.starbounddata.types.variants.Variant.java
License:Open Source License
@Override public void write(ByteBuf out) { out.writeByte(variantType.ordinal()); switch (variantType) { case NIL: {/*ww w . ja v a2s . c o m*/ break; } case DOUBLE: { out.writeDouble((Double) value); break; } case BOOLEAN: { out.writeBoolean((Boolean) value); break; } case INTEGER: { byte[] bytes = VLQ.writeUnsignedVLQNoObject((Long) value); out.writeBytes(bytes); break; } case STRING: { writeStringVLQ(out, (String) value); break; } case LIST: { ((VariantList) value).write(out); break; } case MAP: ((VariantMap) value).write(out); break; default: System.err.println("Unknown Variant Type: " + variantType); } }
From source file:org.wso2.carbon.tcp.transport.util.BinaryMessageConverterUtil.java
License:Open Source License
public static void assignData(Object data, ByteBuf eventDataBuffer) throws IOException { if (data instanceof String) { eventDataBuffer.writeInt(((String) data).length()); eventDataBuffer.writeBytes((((String) data).getBytes(BinaryMessageConstants.DEFAULT_CHARSET))); } else if (data instanceof Integer) { eventDataBuffer.writeInt((Integer) data); } else if (data instanceof Long) { eventDataBuffer.writeLong((Long) data); } else if (data instanceof Float) { eventDataBuffer.writeFloat((Float) data); } else if (data instanceof Double) { eventDataBuffer.writeDouble((Double) data); } else if (data instanceof Boolean) { eventDataBuffer.writeByte((byte) (((Boolean) data) ? 1 : 0)); } else {//from www . j a v a 2s .c om eventDataBuffer.writeInt(0); } }
From source file:org.wso2.siddhi.tcp.transport.utils.BinaryMessageConverterUtil.java
License:Open Source License
public static void assignData(Object data, ByteBuf eventDataBuffer) throws IOException { if (data instanceof String) { eventDataBuffer.writeInt(((String) data).length()); eventDataBuffer.writeBytes((((String) data).getBytes(Constant.DEFAULT_CHARSET))); } else if (data instanceof Integer) { eventDataBuffer.writeInt((Integer) data); } else if (data instanceof Long) { eventDataBuffer.writeLong((Long) data); } else if (data instanceof Float) { eventDataBuffer.writeFloat((Float) data); } else if (data instanceof Double) { eventDataBuffer.writeDouble((Double) data); } else if (data instanceof Boolean) { eventDataBuffer.writeByte((byte) (((Boolean) data) ? 1 : 0)); } else {/*from w w w . ja v a2 s. c om*/ eventDataBuffer.writeInt(0); } }
From source file:pneumaticCraft.common.network.PacketSpawnParticle.java
License:LGPL
@Override public void toBytes(ByteBuf buffer) { super.toBytes(buffer); ByteBufUtils.writeUTF8String(buffer, particleName); buffer.writeDouble(dx); buffer.writeDouble(dy);// ww w. ja v a2 s . c om buffer.writeDouble(dz); }