Skip to content

Commit

Permalink
Solar Panels: Use config for capacity RF (#94)
Browse files Browse the repository at this point in the history
* make Solar Energy configurable

* spotlessApply

* calc capacity also for single solar panels

* getCapacity(,) sanity check 'panel' against null
  • Loading branch information
Pilzinsel64 authored Feb 8, 2023
1 parent e41827f commit 29b0d71
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/main/java/crazypants/enderio/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ public String lc() {
public static int maxPhotovoltaicAdvancedOutputRF = 40;
public static int maxPhotovoltaicVibrantOutputRF = 160;

public static int photovoltaicCellCapacityRF = 10000;
public static int photovoltaicAdvancedCellCapacityRF = 10000;
public static int photovoltaicVibrantCellCapacityRF = 10000;

public static int zombieGeneratorRfPerTick = 80;
public static int zombieGeneratorTicksPerBucketFuel = 12000;

Expand Down Expand Up @@ -808,6 +812,26 @@ public static void processConfig(Configuration config) {
"Maximum output in RF/t of the Vibrant Photovoltaic Panels.")
.getInt(maxPhotovoltaicVibrantOutputRF);

photovoltaicCellCapacityRF = config.get(
sectionPower.name,
"photovoltaicCellCapacityRF",
photovoltaicCellCapacityRF,
"Maximum capacity in RF/t of the Photovoltaic Panels.").getInt(photovoltaicCellCapacityRF);
photovoltaicAdvancedCellCapacityRF = config
.get(
sectionPower.name,
"photovoltaicAdvancedCellCapacityRF",
photovoltaicAdvancedCellCapacityRF,
"Maximum capacity in RF/t of the Advanced Photovoltaic Panels.")
.getInt(photovoltaicAdvancedCellCapacityRF);
photovoltaicVibrantCellCapacityRF = config
.get(
sectionPower.name,
"photovoltaicVibrantCellCapacityRF",
photovoltaicVibrantCellCapacityRF,
"Maximum capacity in RF/t of the Vibrant Photovoltaic Panels.")
.getInt(photovoltaicVibrantCellCapacityRF);

useAlternateBinderRecipe = config
.get(
sectionRecipe.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import cofh.api.energy.EnergyStorage;

import com.google.common.collect.Lists;
import crazypants.enderio.config.Config;

public class SolarPanelNetwork {

Expand All @@ -25,12 +26,13 @@ public class SolarPanelNetwork {

public SolarPanelNetwork() {
panels = Lists.newArrayList();
energy = new EnergyStorage(ENERGY_PER);
energy = new EnergyStorage(getCapacity());
}

SolarPanelNetwork(TileEntitySolarPanel initial) {
this();
panels.add(initial);
energy.setCapacity(getCapacity(initial, 1));
empty = false;
}

Expand Down Expand Up @@ -83,8 +85,42 @@ void removeFromNetwork(TileEntitySolarPanel panel) {
destroyNetwork();
}

private int getCapacity() {
int capacity = ENERGY_PER;

if (panels.size() > 0) {
TileEntitySolarPanel masterPanel = getMaster();
capacity = getCapacity(masterPanel, panels.size());
}

return capacity;
}

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

if (panel != null) {
int meta = panel.getBlockMetadata();
switch (meta) {
case 0: // Default
capacity = Config.photovoltaicCellCapacityRF;
break;
case 1: // Advanced
capacity = Config.photovoltaicAdvancedCellCapacityRF;
break;
case 2: // Vibrant
capacity = Config.photovoltaicVibrantCellCapacityRF;
break;
}
}

capacity = capacity * panelsCount;

return capacity;
}

private void updateEnergy() {
energy.setCapacity(ENERGY_PER * panels.size());
energy.setCapacity(getCapacity());
energy.setMaxExtract(energy.getMaxEnergyStored());
}

Expand Down

0 comments on commit 29b0d71

Please sign in to comment.