當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteArrayDataOutput.writeDouble方法代碼示例

本文整理匯總了Java中com.google.common.io.ByteArrayDataOutput.writeDouble方法的典型用法代碼示例。如果您正苦於以下問題:Java ByteArrayDataOutput.writeDouble方法的具體用法?Java ByteArrayDataOutput.writeDouble怎麽用?Java ByteArrayDataOutput.writeDouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.io.ByteArrayDataOutput的用法示例。


在下文中一共展示了ByteArrayDataOutput.writeDouble方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: write

import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
public void write(ByteArrayDataOutput out)
{
    // ------
    // SERVER
    // ------

    out.writeUTF( particleName );

    out.writeDouble( particlePosX );
    out.writeDouble( particlePosY );
    out.writeDouble( particlePosZ );

    out.writeDouble( velX );
    out.writeDouble( velY );
    out.writeDouble( velZ );
}
 
開發者ID:Maxwolf,項目名稱:MC-MineAPI.Java,代碼行數:18,代碼來源:ParticlePacket.java

示例2: 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());
    }
  }
}
 
開發者ID:google,項目名稱:turbine,代碼行數:31,代碼來源:ClassWriter.java

示例3: 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);
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:31,代碼來源:HammerNet.java

示例4: callMethod

import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
@Override
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception {
	switch (method) {
		case 0: {
			if (arguments.length < 1) throw new Exception("too few arguments");
			else if (!(arguments[0] instanceof String)) throw new Exception("bad argument #1 (expected string)");
			else if (arguments.length > 1 && !(arguments[1] instanceof Double)) throw new Exception("bad argument #2 (expected number)");
			
			String text = (String) arguments[0];
			if (text.length() > 255) text = text.substring(0, 255);
			
			double speed = arguments.length > 1 ? (Double)arguments[1] : 0.0D;
			if (speed < -1.0D || speed > 1.0D) throw new Exception("bad speed " + speed + " (expected -1..1)");
			
			if (++reqs > MAX_REQS) throw new Exception("too many requests (over "+MAX_REQS+" per second)");
			
			Vec3 pos = positionable.getPosition();
			ByteArrayDataOutput os = ByteStreams.newDataOutput();
			os.writeDouble(pos.xCoord);
			os.writeDouble(pos.yCoord);
			os.writeDouble(pos.zCoord);
			os.writeUTF(text);
			os.writeDouble(speed);
			
			PacketDispatcher.sendPacketToAllAround(pos.xCoord, pos.yCoord, pos.zCoord, 64.0D, positionable.getWorld().provider.dimensionId, PacketDispatcher.getTinyPacket(MiscPeripherals.instance, (short)8, os.toByteArray()));
			
			return new Object[0];
		}
	}
	
	return new Object[0];
}
 
開發者ID:austinv11,項目名稱:PeripheralsPlusPlus,代碼行數:33,代碼來源:PeripheralSpeaker.java

示例5: write

import com.google.common.io.ByteArrayDataOutput; //導入方法依賴的package包/類
public void write(ByteArrayDataOutput out) {
    double[] d = toStaticArray();
    for (int i = 0; i < d.length; i++) {
        out.writeDouble(d[i]);
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:7,代碼來源:Quaternion.java


注:本文中的com.google.common.io.ByteArrayDataOutput.writeDouble方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。