@SideOnly(Side.CLIENT) public final int getScaledStoredEnergyClient(int scale) { float maxEnergy = getMaxStoredEnergy(); return MathUtil.floatEquals(maxEnergy, 0F) ? -1 : MathUtil.ceil(storedEnergy * (double) scale / maxEnergy); }
public static boolean setItemEnergy(ItemDamagePair pair, float energyUnits) { if (!MathUtil.floatEquals( getItemEnergy(new ItemStack(pair.item, 1, pair.damage == -1 ? 0 : pair.damage)), 0F)) return false; items.put(pair, EnergyChunkData.energyDrainUnit * energyUnits); return true; }
public float drainEnergy(float amount, TileEntityAbstractEnergyInventory tile) { if (data.getEnergyLevel() >= EnergyChunkData.minSignificantEnergy) PacketPipeline.sendToAllAround(this, 64D, new C10ParticleEnergyTransfer(tile, this)); float left = data.drainEnergy(amount); if (!MathUtil.floatEquals(left, amount)) synchronize(); return left; }
public float addEnergy(float amount, TileEntityAbstractEnergyInventory tile) { if (data.getEnergyLevel() < data.getMaxEnergyLevel()) PacketPipeline.sendToAllAround(this, 64D, new C10ParticleEnergyTransfer(tile, this)); float left = data.addEnergy(amount); if (!MathUtil.floatEquals(left, amount)) synchronize(); return left; }
@Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); if (!MathUtil.floatEquals(storedEnergy, 0F)) nbt.setFloat("storedEng", storedEnergy); }