Skip to content

Commit

Permalink
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ public class SolarPanelNetwork {
private boolean empty = true;

private EnergyStorage energy;
private boolean hasAppliedMaxEnergyConfig = false;

public static final int ENERGY_PER = 10000;

@@ -96,7 +97,7 @@ private int getCapacity() {
return capacity;
}

private static int getCapacity(TileEntitySolarPanel panel, int panelsCount) {
private int getCapacity(TileEntitySolarPanel panel, int panelsCount) {
int capacity = ENERGY_PER;

if (panel != null && panel.hasWorldObj()) {
@@ -112,13 +113,20 @@ private static int getCapacity(TileEntitySolarPanel panel, int panelsCount) {
capacity = Config.photovoltaicVibrantCellCapacityRF;
break;
}
hasAppliedMaxEnergyConfig = true;
}

capacity = capacity * panelsCount;

return capacity;
}

private void updateEnergyIfNeeded() {
if (!hasAppliedMaxEnergyConfig) {
updateEnergy();
}
}

private void updateEnergy() {
energy.setCapacity(getCapacity());
energy.setMaxExtract(energy.getMaxEnergyStored());
@@ -155,6 +163,7 @@ public int getEnergyStored() {
}

public int setEnergyStored(int energy) {
updateEnergyIfNeeded();
if (isValid()) {
this.energy.setEnergyStored(energy);
}

0 comments on commit 1728809

Please sign in to comment.