Skip to content

Commit

Permalink
feat: Add config flag to disable machine energy input throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
Rover656 committed Sep 25, 2024
1 parent 23dbd8c commit 6c7d0be
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"enderio_machines.configuration.spawnAmount": "Spawn Amount",
"enderio_machines.configuration.spawnType": "Spawn Type",
"enderio_machines.configuration.stirlingGenerator": "Stirling Generator",
"enderio_machines.configuration.throttleEnergyUsage": "Throttle Energy Use",
"enderio_machines.configuration.usage": "Consumption Rate (µI/t)",
"enderio_machines.configuration.vacuumChestRangeColor": "Vaccum Chest Range Color",
"enderio_machines.configuration.vacuumXpRangeColor": "XP Vacuum Range Color",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.enderio.machines.common.config;

import com.enderio.EnderIOBase;
import com.enderio.machines.EnderIOMachines;

public class MachinesConfigLang {
Expand All @@ -11,6 +10,7 @@ public static void register() {

// Energy
addTranslation("energy", "Energy");
addTranslation("throttleEnergyUsage", "Throttle Energy Use");
addTranslation("capacity", "Capacity (\u00B5I)");
addTranslation("usage", "Consumption Rate (\u00B5I/t)");
addTranslation("energyCost", "Energy Cost (\u00B5I)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.neoforged.neoforge.common.ModConfigSpec;

public class EnergyConfig {
public final ModConfigSpec.BooleanValue THROTTLE_ENERGY_INPUT;

public final ModConfigSpec.ConfigValue<Integer> ALLOY_SMELTER_CAPACITY;
public final ModConfigSpec.ConfigValue<Integer> ALLOY_SMELTER_USAGE;
public final ModConfigSpec.ConfigValue<Integer> ALLOY_SMELTER_VANILLA_ITEM_ENERGY;
Expand Down Expand Up @@ -50,6 +52,10 @@ public class EnergyConfig {
public EnergyConfig(ModConfigSpec.Builder builder) {
builder.push("energy");

THROTTLE_ENERGY_INPUT = builder
.comment("Whether or not the machine should throttle energy input to 2x it's consumption rate")
.define("throttleEnergyUsage", true);

builder.push("alloySmelter");
ALLOY_SMELTER_CAPACITY = builder.comment("The base energy capacity in uI.").defineInRange("capacity", 64_000, 1, Integer.MAX_VALUE);
ALLOY_SMELTER_USAGE = builder.comment("The base energy consumption in uI/t.").defineInRange("usage", 20, 1, Integer.MAX_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.enderio.base.api.io.IOConfigurable;
import com.enderio.base.api.io.energy.EnergyIOMode;
import com.enderio.machines.common.MachineNBTKeys;
import com.enderio.machines.common.config.MachinesConfig;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
import net.minecraft.nbt.CompoundTag;
Expand Down Expand Up @@ -121,7 +122,14 @@ public int receiveEnergy(int maxReceive, boolean simulate) {
return 0;
}

int energyReceived = Math.min(getMaxEnergyStored() - getEnergyStored(), Math.min(getMaxEnergyUse() * 2, maxReceive));
int maximumEnergyToReceive;
if (MachinesConfig.COMMON.ENERGY.THROTTLE_ENERGY_INPUT.get()) {
maximumEnergyToReceive = Math.min(getMaxEnergyUse() * 2, maxReceive);
} else {
maximumEnergyToReceive = maxReceive;
}

int energyReceived = Math.min(getMaxEnergyStored() - getEnergyStored(), maximumEnergyToReceive);
if (!simulate) {
addEnergy(energyReceived);
}
Expand Down

0 comments on commit 6c7d0be

Please sign in to comment.