コード例 #1
0
 @SideOnly(Side.CLIENT)
 public final int getScaledStoredEnergyClient(int scale) {
   float maxEnergy = getMaxStoredEnergy();
   return MathUtil.floatEquals(maxEnergy, 0F)
       ? -1
       : MathUtil.ceil(storedEnergy * (double) scale / maxEnergy);
 }
コード例 #2
0
 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;
 }
コード例 #3
0
  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;
  }
コード例 #4
0
  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;
  }
コード例 #5
0
 @Override
 public void writeToNBT(NBTTagCompound nbt) {
   super.writeToNBT(nbt);
   if (!MathUtil.floatEquals(storedEnergy, 0F)) nbt.setFloat("storedEng", storedEnergy);
 }