Example usage for com.google.common.io ByteArrayDataInput readFloat

List of usage examples for com.google.common.io ByteArrayDataInput readFloat

Introduction

In this page you can find the example usage for com.google.common.io ByteArrayDataInput readFloat.

Prototype

@Override
    float readFloat();

Source Link

Usage

From source file:shadowmage.ancient_warfare.common.gates.EntityGate.java

@Override
public void readSpawnData(ByteArrayDataInput data) {
    this.pos1 = new BlockPosition(data.readInt(), data.readInt(), data.readInt());
    this.pos2 = new BlockPosition(data.readInt(), data.readInt(), data.readInt());
    this.gateType = Gate.getGateByID(data.readInt());
    this.teamNum = data.readInt();
    this.edgePosition = data.readFloat();
    this.edgeMax = data.readFloat();
    this.gateStatus = data.readByte();
    this.gateOrientation = data.readByte();
    this.health = data.readInt();
}

From source file:micdoodle8.mods.galacticraft.core.tile.GCCoreTileEntitySolar.java

@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet,
        EntityPlayer player, ByteArrayDataInput dataStream) {
    try {// w w  w  .ja va2 s.  co  m
        this.mainBlockPosition = new Vector3(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
        this.solarStrength = dataStream.readInt();
        this.setEnergyStored(dataStream.readFloat());
        this.generateWatts = dataStream.readFloat();
        this.disableCooldown = dataStream.readInt();
        this.disabled = dataStream.readBoolean();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:shadowmage.ancient_warfare.common.vehicles.missiles.MissileBase.java

@Override
public void readSpawnData(ByteArrayDataInput data) {
    this.missileType = data.readInt();
    this.ammoType = AmmoRegistry.instance().getAmmoEntry(missileType);
    if (this.ammoType == null) {
        this.ammoType = Ammo.ammoArrow;
    }/*www . j a v  a2s.  c o  m*/
    this.prevRotationYaw = this.rotationYaw = data.readFloat();
    this.prevRotationPitch = this.rotationPitch = data.readFloat();
    this.inGround = data.readBoolean();
    this.blockX = data.readInt();
    this.blockY = data.readInt();
    this.blockZ = data.readInt();
    this.blockID = data.readInt();
    this.blockMeta = data.readInt();
    this.rocketBurnTime = data.readInt();
    boolean hasLauncher = data.readBoolean();
    if (hasLauncher) {
        Entity launcher = worldObj.getEntityByID(data.readInt());
    }
}

From source file:smpships.entity.EntityShipBlock.java

@Override
protected void readControlBlockSpawnData(ByteArrayDataInput data) { //runs on clients

    name = data.readUTF();/*  w w  w .  j av a  2  s .  co  m*/
    captain = data.readUTF();

    // read mates
    int mateCount = data.readInt();
    for (int i = 0; i < mateCount; i++)
        mates.set(i, data.readUTF());

    draft = data.readFloat();

    int kidCount = data.readInt(); //load kids, add to parent
    for (int i = 0; i < kidCount; i++)
        addChild(new EntityBlock(worldObj, posX + data.readInt(), posY + data.readInt(), posZ + data.readInt(),
                data.readInt(), data.readInt(), this)); // x y z b m

    // ensure all children are spawned in CLIENT world, spawn any missing (spawning in client is unusual, but needed because BlockEntity is not registered
    if (worldObj.isRemote)
        for (EntityBlock be : children) // remote check should be redundant in this method
            if (!worldObj.loadedEntityList.contains(be))
                worldObj.spawnEntityInWorld(be);

}

From source file:shadowmage.ancient_warfare.common.vehicles.VehicleBase.java

@Override
public void readSpawnData(ByteArrayDataInput data) {
    this.setHealth(data.readFloat());
    IVehicleType type = VehicleType.getVehicleType(data.readInt());
    this.setVehicleType(type, data.readInt());
    this.upgradeHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.ammoHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.moveHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.firingHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.firingVarsHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.localLaunchPower = data.readFloat();
    this.localTurretPitch = data.readFloat();
    this.localTurretRotation = data.readFloat();
    this.localTurretDestPitch = data.readFloat();
    this.localTurretDestRot = data.readFloat();
    this.firingHelper.clientLaunchSpeed = localLaunchPower;
    this.firingHelper.clientTurretPitch = localTurretPitch;
    this.firingHelper.clientTurretYaw = localTurretRotation;
    this.upgradeHelper.updateUpgradeStats();
    this.teamNum = data.readInt();
    this.localTurretRotationHome = data.readFloat();
    this.isSettingUp = data.readBoolean();
    if (this.isSettingUp) {
        this.setupTicks = data.readInt();
    }/*  www . jav  a  2s  .c om*/
    this.setPosition(posX, posY, posZ);//this is to reset the bounding box, because the size of the entity changed during vehicleType setup 
}

From source file:org.apache.druid.indexer.InputRowSerde.java

public static final InputRow fromBytes(final Map<String, IndexSerdeTypeHelper> typeHelperMap, byte[] data,
        AggregatorFactory[] aggs) {/* ww w  . j  ava2 s  . c  o m*/
    try {
        ByteArrayDataInput in = ByteStreams.newDataInput(data);

        //Read timestamp
        long timestamp = in.readLong();

        Map<String, Object> event = Maps.newHashMap();

        //Read dimensions
        List<String> dimensions = Lists.newArrayList();
        int dimNum = WritableUtils.readVInt(in);
        for (int i = 0; i < dimNum; i++) {
            String dimension = readString(in);
            dimensions.add(dimension);

            IndexSerdeTypeHelper typeHelper = typeHelperMap.get(dimension);
            if (typeHelper == null) {
                typeHelper = STRING_HELPER;
            }
            Object dimValues = typeHelper.deserialize(in);
            if (dimValues == null) {
                continue;
            }

            if (typeHelper.getType() == ValueType.STRING) {
                List<String> dimensionValues = (List<String>) dimValues;
                if (dimensionValues.size() == 1) {
                    event.put(dimension, dimensionValues.get(0));
                } else {
                    event.put(dimension, dimensionValues);
                }
            } else {
                event.put(dimension, dimValues);
            }
        }

        //Read metrics
        int metricSize = WritableUtils.readVInt(in);
        for (int i = 0; i < metricSize; i++) {
            String metric = readString(in);
            String type = getType(metric, aggs, i);
            byte metricNullability = in.readByte();
            if (metricNullability == NullHandling.IS_NULL_BYTE) {
                // metric value is null.
                continue;
            }
            if ("float".equals(type)) {
                event.put(metric, in.readFloat());
            } else if ("long".equals(type)) {
                event.put(metric, WritableUtils.readVLong(in));
            } else if ("double".equals(type)) {
                event.put(metric, in.readDouble());
            } else {
                ComplexMetricSerde serde = getComplexMetricSerde(type);
                byte[] value = readBytes(in);
                event.put(metric, serde.fromBytes(value, 0, value.length));
            }
        }

        return new MapBasedInputRow(timestamp, dimensions, event);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:micdoodle8.mods.galacticraft.core.entities.GCCoreEntityLander.java

@Override
public void readNetworkedData(ByteArrayDataInput dataStream) {
    if (this.worldObj.isRemote) {
        int cargoLength = dataStream.readInt();

        if (this.containedItems == null || this.containedItems.length == 0) {
            this.containedItems = new ItemStack[cargoLength];
            PacketDispatcher.sendPacketToServer(PacketUtil.createPacket(GalacticraftCore.CHANNEL,
                    EnumPacketServer.UPDATE_DYNAMIC_ENTITY_INV, new Object[] { this.entityId }));
        }/* www . j  a  va2s .  c o  m*/

        this.fuelTank.setFluid(new FluidStack(GalacticraftCore.fluidFuel, dataStream.readInt()));

        this.setWaitForPlayer(dataStream.readBoolean());

        this.onGround = dataStream.readBoolean();
    } else {
        this.motionX = dataStream.readDouble() / 8000.0D;
        this.motionY = dataStream.readDouble() / 8000.0D;
        this.motionZ = dataStream.readDouble() / 8000.0D;

        this.rotationPitch = dataStream.readFloat();
        this.rotationYaw = dataStream.readFloat();
    }
}