Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Improve circuit selection on the large boilers by adding the ability to grab a ghost circuit from a input hatch and adds logic for other circuit tiers #3417

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,19 @@ public boolean drain(MTEHatch hatch, FluidStack fluid, boolean doDrain) {
return false;
}

public ItemStack getConfigurationCircuit() {
for (MTEHatchInputBus tHatch : filterValidMTEs(mInputBusses)) {
if (tHatch.allowSelectCircuit()) {
// Grabs the first ghost circuit we can find and returns it
ItemStack stack = tHatch.getStackInSlot(tHatch.getCircuitSlot());
if (stack != null) {
return stack;
}
}
}
return null;
}

public ArrayList<ItemStack> getStoredInputs() {
ArrayList<ItemStack> rList = new ArrayList<>();
Map<GTUtility.ItemId, ItemStack> inputsFromME = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList;

public abstract class MTELargeBoiler extends MTEEnhancedMultiBlockBase<MTELargeBoiler>
implements ISurvivalConstructable {
Expand Down Expand Up @@ -95,7 +96,7 @@ protected IStructureDefinition<MTELargeBoiler> computeValue(Class<?> type) {
};
private boolean firstRun = true;
private int mSuperEfficencyIncrease = 0;
private int integratedCircuitConfig = 0; // Steam output is reduced by 1000L per config
private float integratedCircuitConfig = 0; // Steam output is reduced by 1000L per config
private int excessWater = 0; // Eliminate rounding errors for water
private int excessFuel = 0; // Eliminate rounding errors for fuels that burn half items
private int excessProjectedEU = 0; // Eliminate rounding errors from throttling the boiler
Expand Down Expand Up @@ -182,7 +183,7 @@ protected MultiblockTooltipBuilder createTooltip() {

public abstract int getEfficiencyIncrease();

public int getIntegratedCircuitConfig() {
public float getIntegratedCircuitConfig() {
return integratedCircuitConfig;
}

Expand Down Expand Up @@ -258,12 +259,34 @@ protected boolean filtersFluid() {
public CheckRecipeResult checkProcessing() {
if (!isFuelValid()) return CheckRecipeResultRegistry.NO_FUEL_FOUND;
// Do we have an integrated circuit with a valid configuration?
if (Circuit_Integrated.isStackEqual(mInventory[1], true, true)) {
int circuit_config = mInventory[1].getItemDamage();

// If we don't have a circuit in the main inventory, check the hatch(s) for a ghost circuit
ItemStack hatchCircuit = mInventory[1] != null ? mInventory[1] : getConfigurationCircuit();

if (Circuit_Integrated.isStackEqual(hatchCircuit, true, true)) {
int circuit_config = hatchCircuit.getItemDamage();
if (circuit_config >= 1 && circuit_config <= 25) {
// If so, overwrite the current config
this.integratedCircuitConfig = circuit_config;
}
}
// TODO: Add logic for breakthrough and bio circuits
// Logically, biocircuit should be 1/2 of a normal circuit, however, throttle calculations are in eu/t (int)
// If we change the config to be a float, it will work since numbers such as 0.5, 0.75, 0.875, etc are evenly
// represented in binary
// EX: 1/2 of a normal circuit would be 12.5 eu/t, it would round to 12 eu/t
else if (GregtechItemList.Circuit_BioRecipeSelector.isStackEqual(hatchCircuit, true, true)) {
float circuit_config = hatchCircuit.getItemDamage();
if (circuit_config >= 1 && circuit_config <= 25) {
// If so, overwrite the current config
this.integratedCircuitConfig = circuit_config / 2;
}
} else if (GregtechItemList.Circuit_T3RecipeSelector.isStackEqual(hatchCircuit, true, true)) {
int circuit_config = hatchCircuit.getItemDamage();
if (circuit_config >= 1 && circuit_config <= 25) {
// If so, overwrite the current config
this.integratedCircuitConfig = circuit_config * 2;
}
} else {
// If not, set the config to zero
this.integratedCircuitConfig = 0;
Expand Down Expand Up @@ -470,7 +493,7 @@ public boolean explodesOnComponentBreak(ItemStack aStack) {
}

private int adjustEUtForConfig(int rawEUt) {
int adjustedSteamOutput = rawEUt - (isSuperheated() ? 75 : 25) * integratedCircuitConfig;
int adjustedSteamOutput = (int) (rawEUt - (isSuperheated() ? 75 : 25) * integratedCircuitConfig);
return Math.max(adjustedSteamOutput, 25);
}

Expand All @@ -485,7 +508,7 @@ private int adjustBurnTimeForConfig(int rawBurnTime) {
if (mEfficiencyIncrease <= 5000 && mEfficiency < getCorrectedMaxEfficiency(mInventory[1])) {
return rawBurnTime;
}
int adjustedEUt = Math.max(25, getEUt() - (isSuperheated() ? 75 : 25) * integratedCircuitConfig);
int adjustedEUt = (int) Math.max(25, getEUt() - (isSuperheated() ? 75 : 25) * integratedCircuitConfig);
int adjustedBurnTime = (int) (rawBurnTime * (long) getEUt() / adjustedEUt);
this.excessProjectedEU += getEUt() * rawBurnTime - adjustedEUt * adjustedBurnTime;
adjustedBurnTime += this.excessProjectedEU / adjustedEUt;
Expand Down
Loading