fix single solar cell max capacity (#99)

This commit is contained in:
Pilzinsel64 authored and GitHub committed 2023-02-17 22:00:12 +01:00
1 parent 0edabd4a9d
commit 1728809a8a
1 file changed
+10 -1
@@ -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 @@ public class SolarPanelNetwork {
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,6 +113,7 @@ public class SolarPanelNetwork {
capacity = Config.photovoltaicVibrantCellCapacityRF;
break;
}
hasAppliedMaxEnergyConfig = true;
}
capacity = capacity * panelsCount;
@@ -119,6 +121,12 @@ public class SolarPanelNetwork {
return capacity;
}
private void updateEnergyIfNeeded() {
if (!hasAppliedMaxEnergyConfig) {
updateEnergy();
}
}
private void updateEnergy() {
energy.setCapacity(getCapacity());
energy.setMaxExtract(energy.getMaxEnergyStored());
@@ -155,6 +163,7 @@ public class SolarPanelNetwork {
}
public int setEnergyStored(int energy) {
updateEnergyIfNeeded();
if (isValid()) {
this.energy.setEnergyStored(energy);
}