Skip to content

Commit

Permalink
fix single solar cell max capacity (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pilzinsel64 authored Feb 17, 2023
1 parent 0edabd4 commit 1728809
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()) {
Expand All @@ -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());
Expand Down Expand Up @@ -155,6 +163,7 @@ public int getEnergyStored() {
}

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

0 comments on commit 1728809

Please sign in to comment.