Fix no comparator signal on near-empty storage

Comparators would output a zero power level both when attached to empty
storage, and nearly empty storage. This made it impossible to
differentiate between the two. The new semantics are equivalent to those
used by Minecraft for chests, etc.
This commit is contained in:
Xyxen committed 2015-11-03 17:20:03 -07:00
1 parent 7fadcac718
commit 1ae46ca4b5
3 files changed
+9 -3

No files matched your search

@@ -693,7 +693,8 @@ public class TileCapBank extends TileEntityEio implements IInternalPowerReceiver
}
public int getComparatorOutput() {
return (int) (((double) getEnergyStored() / (double) getMaxEnergyStored()) * 15);
double stored = getEnergyStored();
return stored == 0 ? 0 : (int) (1 + stored / getMaxEnergyStored() * 14);
}
@Override
@@ -269,7 +269,8 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerHa
}
public int getComparatorOutput() {
return (int) (((double) getEnergyStored() / (double) getMaxEnergyStored()) * 15);
double stored = getEnergyStored();
return stored == 0 ? 0 : (int) (1 + stored / getMaxEnergyStored() * 14);
}
public List<GaugeBounds> getGaugeBounds() {
@@ -297,7 +297,11 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler, IT
public int getComparatorOutput() {
FluidTankInfo info = getTankInfo(null)[0];
return info == null || info.fluid == null ? 0 : (int) (((double) info.fluid.amount / (double) info.capacity) * 15);
if (info == null || info.fluid == null) {
return 0;
}
return info.fluid.amount == 0 ? 0 : (int) (1 + ((double) info.fluid.amount / (double) info.capacity) * 14);
}
private boolean processItems(boolean redstoneCheckPassed) {