From 1728809a8a9b26b54c58a083b33b8341f3f95b9c Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Fri, 17 Feb 2023 22:00:12 +0100 Subject: [PATCH] fix single solar cell max capacity (#99) --- .../enderio/machine/solar/SolarPanelNetwork.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/crazypants/enderio/machine/solar/SolarPanelNetwork.java b/src/main/java/crazypants/enderio/machine/solar/SolarPanelNetwork.java index e84d0932f2..e98ecfc4ec 100644 --- a/src/main/java/crazypants/enderio/machine/solar/SolarPanelNetwork.java +++ b/src/main/java/crazypants/enderio/machine/solar/SolarPanelNetwork.java @@ -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,6 +113,7 @@ private static int getCapacity(TileEntitySolarPanel panel, int panelsCount) { capacity = Config.photovoltaicVibrantCellCapacityRF; break; } + hasAppliedMaxEnergyConfig = true; } capacity = capacity * panelsCount; @@ -119,6 +121,12 @@ private static int getCapacity(TileEntitySolarPanel panel, int 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); }