Fix a few crashes

This commit is contained in:
Ben Spiers 2013-12-16 15:53:46 +00:00
parent c7a22b7cfd
commit 79e8b36a4b
4 changed files with 4 additions and 4 deletions

View file

@ -295,7 +295,7 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
public float getScale()
{
return (gasStored != null ? gasStored.amount : 0)/getCapacity();
return (gasStored == null || getCapacity() == 0 ? 0 : gasStored.amount/getCapacity());
}
@Override

View file

@ -113,7 +113,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
*/
public double getMeanCapacity()
{
return transmitters.iterator().next().getCapacity();
return transmitters.size() > 0 ? transmitters.iterator().next().getCapacity() : 0;
}
@Override

View file

@ -405,7 +405,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
public double getPowerScale()
{
return Math.max(joulesLastTick == 0 ? 0 : Math.min(Math.ceil(Math.log10(getPower())*2)/10, 1), electricityStored/getCapacity());
return Math.max(joulesLastTick == 0 ? 0 : Math.min(Math.ceil(Math.log10(getPower())*2)/10, 1), getCapacity() == 0 ? 0 : electricityStored/getCapacity());
}
public void clearJoulesTransmitted()

View file

@ -303,7 +303,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
public float getScale()
{
return (fluidStored != null ? fluidStored.amount : 0)/getCapacity();
return (fluidStored == null || getCapacity() == 0 ? 0 : fluidStored.amount/getCapacity());
}
@Override