本文整理匯總了Java中com.google.common.io.ByteArrayDataOutput.writeFloat方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteArrayDataOutput.writeFloat方法的具體用法?Java ByteArrayDataOutput.writeFloat怎麽用?Java ByteArrayDataOutput.writeFloat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.io.ByteArrayDataOutput
的用法示例。
在下文中一共展示了ByteArrayDataOutput.writeFloat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeConstantPool
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
static void writeConstantPool(ConstantPool constantPool, ByteArrayDataOutput output) {
output.writeShort(constantPool.nextEntry);
for (ConstantPool.Entry e : constantPool.constants()) {
output.writeByte(e.kind().tag());
Value value = e.value();
switch (e.kind()) {
case CLASS_INFO:
case STRING:
output.writeShort(((IntValue) value).value());
break;
case INTEGER:
output.writeInt(((IntValue) value).value());
break;
case DOUBLE:
output.writeDouble(((DoubleValue) value).value());
break;
case FLOAT:
output.writeFloat(((FloatValue) value).value());
break;
case LONG:
output.writeLong(((LongValue) value).value());
break;
case UTF8:
output.writeUTF(((StringValue) value).value());
break;
default:
throw new AssertionError(e.kind());
}
}
}
示例2: makePacket
import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
public static FMLProxyPacket makePacket(byte type, Object... items) {
ByteArrayDataOutput dos = ByteStreams.newDataOutput();
dos.writeByte(type);
for (int i = 0; i < items.length; i++) {
Object obj = items[i];
if (obj instanceof Quaternion) {
((Quaternion) obj).write(dos);
} else if (obj instanceof Integer) {
dos.writeInt((Integer) obj);
} else if (obj instanceof Byte) {
dos.writeByte((Byte) obj);
} else if (obj instanceof Float) {
dos.writeFloat((Float) obj);
} else if (obj instanceof Double) {
dos.writeDouble((Double) obj);
} else if (obj instanceof MovingObjectPosition) {
MovingObjectPosition mop = (MovingObjectPosition) obj;
writePos(dos, mop.getBlockPos());
dos.writeByte((byte) mop.sideHit.ordinal());
} else if (obj instanceof Vec3) {
Vec3 vec = (Vec3) obj;
dos.writeDouble(vec.xCoord);
dos.writeDouble(vec.yCoord);
dos.writeDouble(vec.zCoord);
} else {
throw new IllegalArgumentException("Can only do Quaternions/Integers/Bytes/Floats/Doubles/MovingObjectPosition/Vec3! Not " + obj);
}
}
return new FMLProxyPacket(new PacketBuffer(Unpooled.wrappedBuffer(dos.toByteArray())), channelName);
}