Added Battery Box comparator output

Closes #540
This commit is contained in:
Ellpeck 2016-12-28 19:00:26 +01:00
parent a10a11badf
commit 5d09499f61
2 changed files with 20 additions and 2 deletions

View file

@ -58,7 +58,7 @@ public class WorldData extends WorldSavedData{
}
else{
data = (WorldData)savedData;
ModUtil.LOGGER.info("Successfully loaded WorldData.");
ModUtil.LOGGER.info("Successfully loaded WorldData!");
}
//TODO Remove this part as well
@ -95,7 +95,7 @@ public class WorldData extends WorldSavedData{
}
else{
data = new WorldData(DATA_TAG);
ModUtil.LOGGER.info("Created temporary WorldData to cache data on the client.");
ModUtil.LOGGER.info("Created temporary WorldData to cache data on the client!");
}
}

View file

@ -25,6 +25,7 @@ import java.util.List;
public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISharingEnergyProvider{
private int lastEnergyStored;
private int lastCompare;
public TileEntityBatteryBox(){
super(1, "batteryBox");
@ -88,12 +89,29 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
currStorage = storage.getEnergyStored();
}
if(this.lastCompare != this.getComparatorStrength()){
this.lastCompare = this.getComparatorStrength();
this.markDirty();
}
if(this.lastEnergyStored != currStorage && this.sendUpdateWithInterval()){
this.lastEnergyStored = currStorage;
}
}
}
@Override
public int getComparatorStrength(){
IEnergyStorage storage = this.getEnergyStorage(null);
if(storage != null){
float calc = ((float)storage.getEnergyStored()/(float)storage.getMaxEnergyStored())*15F;
return (int)calc;
}
else{
return 0;
}
}
@Override
public boolean respondsToPulses(){
return true;