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

Apply correct EU modifier for calculating parallels in the Volcanus. #3754

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
86611ed
Apply correct EU modifier for calculating parallels in the Volcanus.
Jan 6, 2025
21aa120
Remove star imports.
Jan 6, 2025
9647b27
Merge branch 'master' into master
Dream-Master Jan 7, 2025
7984c6a
Merge branch 'master' into master
Dream-Master Jan 8, 2025
eb7cc52
Merge branch 'master' into master
Dream-Master Jan 9, 2025
d13a3c3
Merge branch 'master' into master
Dream-Master Jan 9, 2025
3d0bd19
Merge branch 'master' into master
Dream-Master Jan 10, 2025
d830d40
Merge branch 'master' into master
Dream-Master Jan 11, 2025
049cc3e
Merge branch 'master' into master
Dream-Master Jan 11, 2025
a257506
Merge branch 'master' into master
Dream-Master Jan 12, 2025
b509398
Merge branch 'master' into master
Dream-Master Jan 12, 2025
166a060
Merge branch 'master' into master
Dream-Master Jan 15, 2025
9af0df7
Merge branch 'master' into master
Dream-Master Jan 17, 2025
1563b4f
Merge branch 'master' into master
Dream-Master Jan 18, 2025
08a6654
Merge branch 'master' into master
Dream-Master Jan 19, 2025
82baa9f
Merge branch 'master' into master
Dream-Master Jan 20, 2025
540aa49
Merge branch 'master' into master
Dream-Master Jan 22, 2025
0837e41
Merge branch 'master' into master
serenibyss Jan 22, 2025
72b3884
Merge branch 'master' into master
Dream-Master Jan 23, 2025
b3875ed
Merge branch 'master' into master
Dream-Master Jan 25, 2025
bfed2a6
Merge branch 'master' into master
Dream-Master Jan 25, 2025
cda334c
Merge branch 'master' into master
Dream-Master Jan 25, 2025
612125f
Merge branch 'master' into master
Dream-Master Jan 26, 2025
980b664
Merge branch 'master' into master
Dream-Master Jan 27, 2025
671a131
Start rework of `ProcessingLogic`
Jan 29, 2025
392c2a8
Start rework of `ProcessingLogic`
Jan 29, 2025
40cc188
Small post-merge fixes
Jan 29, 2025
0cc90da
More work
Jan 30, 2025
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
25 changes: 13 additions & 12 deletions src/functionalTest/java/gregtech/test/GTParallelHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import gregtech.api.enums.TierEU;
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.api.util.ParallelHelper;
import gregtech.api.util.ProcessingHelper;
import gregtech.test.mock.MockIVoidableMachine;

public class GTParallelHelperTest {
Expand Down Expand Up @@ -46,10 +46,10 @@ static void setup() {

@Test
void OutputsIntegerOverflow() {
ParallelHelper helper = new ParallelHelper().setRecipe(rubberRecipe)
ProcessingHelper helper = new ProcessingHelper().setRecipe(rubberRecipe)
.setMachine(machine, false, false)
.setItemInputs(inputItems)
.setMaxParallel(4_000_000)
.setMaxParallels(4_000_000)
.setAvailableEUt(4_000_000)
.setOutputCalculation(true)
.setConsumption(false);
Expand All @@ -64,33 +64,34 @@ void OutputsIntegerOverflow() {
@Test
void parallelIntegerOverflow() {
// Without batch mode
ParallelHelper helperWithoutBatchMode = new ParallelHelper().setRecipe(rubberRecipe)
ProcessingHelper helperWithoutBatchMode = new ProcessingHelper().setRecipe(rubberRecipe)
.setMachine(machine, false, false)
.setItemInputs(inputItems)
.setMaxParallel(Integer.MAX_VALUE)
.setMaxParallels(Integer.MAX_VALUE)
.setAvailableEUt(TierEU.MAX * 16)
.setConsumption(false)
.build();
assertEquals(Integer.MAX_VALUE, helperWithoutBatchMode.getCurrentParallel());

// With batch mode
ParallelHelper helperWithBatchMode = new ParallelHelper().setRecipe(rubberRecipe)
ProcessingHelper helperWithBatchMode = new ProcessingHelper().setRecipe(rubberRecipe)
.setMachine(machine, false, false)
.setItemInputs(inputItems)
.setMaxParallel(Integer.MAX_VALUE / 50)
.setMaxParallels(Integer.MAX_VALUE / 50)
.setAvailableEUt(TierEU.MAX * 16)
.enableBatchMode(128)
.setBatchMode(true)
.setBatchModifier(128)
.setConsumption(false)
.build();
assertEquals(Integer.MAX_VALUE, helperWithBatchMode.getCurrentParallel());
}

@Test
void chanceMultiplier() {
ParallelHelper helper = new ParallelHelper().setRecipe(rubberRecipe)
ProcessingHelper helper = new ProcessingHelper().setRecipe(rubberRecipe)
.setMachine(machine, false, false)
.setItemInputs(inputItems)
.setMaxParallel(10)
.setMaxParallels(10)
.setAvailableEUt(10)
.setConsumption(false)
.setOutputCalculation(true)
Expand All @@ -106,10 +107,10 @@ void chanceMultiplier() {

@Test
void outputMultiplier() {
ParallelHelper helper = new ParallelHelper().setRecipe(rubberRecipe)
ProcessingHelper helper = new ProcessingHelper().setRecipe(rubberRecipe)
.setMachine(machine, false, false)
.setItemInputs(inputItems)
.setMaxParallel(1)
.setMaxParallels(1)
.setAvailableEUt(1)
.setConsumption(false)
.setOutputCalculation(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
import gregtech.api.util.GTRecipeConstants;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.ParallelHelper;
import gregtech.api.util.ProcessingHelper;
import gregtech.api.util.recipe.Sievert;

public class MTEBioVat extends MTEEnhancedMultiBlockBase<MTEBioVat> implements ISurvivalConstructable {
Expand Down Expand Up @@ -264,10 +264,10 @@ protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) {

@NotNull
@Override
protected ParallelHelper createParallelHelper(@NotNull GTRecipe recipe) {
return super.createParallelHelper(recipeWithMultiplier(recipe, inputFluids));
protected ProcessingHelper createProcessingHelper(@NotNull GTRecipe recipe) {
return super.createProcessingHelper(recipeWithMultiplier(recipe, inputFluids));
}
};
}.setOverclock(true);
}

protected GTRecipe recipeWithMultiplier(GTRecipe recipe, FluidStack[] fluidInputs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ public Collection<RecipeMap<?>> getAvailableRecipeMaps() {
@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

@Override
@Nonnull
protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) {
Expand All @@ -323,7 +322,8 @@ protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) {
}
return CheckRecipeResultRegistry.SUCCESSFUL;
}
}.enablePerfectOverclock();
}.setOverclock(true)
.setPerfectOverclock();
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe
.setEUt(MTEElectricImplosionCompressor.this.getMaxInputEu())
.setAmperage(1);
}
}.setMaxParallelSupplier(() -> (int) Math.pow(4, Math.max(this.mBlockTier - 1, 0)));
}.setOverclock(true)
.setMaxParallelSupplier(() -> (int) Math.pow(4, Math.max(this.mBlockTier - 1, 0)));
}

private void updateChunkCoordinates() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.OverclockCalculator;
import gregtech.common.pollution.PollutionConfig;

public class MTEMegaBlastFurnace extends MegaMultiBlockBase<MTEMegaBlastFurnace> implements ISurvivalConstructable {
Expand Down Expand Up @@ -276,22 +275,18 @@ protected String[] getExtendedInfoData() {
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

@Nonnull
@Override
protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) {
return super.createOverclockCalculator(recipe).setRecipeHeat(recipe.mSpecialValue)
.setMachineHeat(MTEMegaBlastFurnace.this.mHeatingCapacity)
.setHeatOC(true)
.setHeatDiscount(true);
}

@Override
protected @Nonnull CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) {
return recipe.mSpecialValue <= MTEMegaBlastFurnace.this.mHeatingCapacity
? CheckRecipeResultRegistry.SUCCESSFUL
: CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue);
}
}.setMaxParallel(Configuration.Multiblocks.megaMachinesMax);
}.setOverclock(true)
.setHeatOC(true)
.setHeatDiscount(true)
.setHeatDiscountMultiplier(0.95)
.setMachineHeat(MTEMegaBlastFurnace.this.mHeatingCapacity)
.setMaxParallel(Configuration.Multiblocks.megaMachinesMax);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrench

@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic().enablePerfectOverclock()
return new ProcessingLogic()
.setOverclock(true)
.setPerfectOverclock()
.setMaxParallel(Configuration.Multiblocks.megaMachinesMax);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,9 @@ public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrench

@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic().setMaxParallel(Configuration.Multiblocks.megaMachinesMax);
return new ProcessingLogic()
.setOverclock(true)
.setMaxParallel(Configuration.Multiblocks.megaMachinesMax);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import java.util.List;
import java.util.Map;

import javax.annotation.Nonnull;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
Expand Down Expand Up @@ -62,7 +60,6 @@
import gregtech.api.metatileentity.implementations.MTEHatchOutput;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.maps.OilCrackerBackend;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTUtility;
Expand Down Expand Up @@ -223,15 +220,10 @@ public RecipeMap<OilCrackerBackend> getRecipeMap() {

@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

@Override
@Nonnull
public CheckRecipeResult process() {
this.setEuModifier(1.0F - Math.min(0.1F * (MTEMegaOilCracker.this.heatLevel.getTier() + 1), 0.5F));
return super.process();
}
}.setMaxParallel(Configuration.Multiblocks.megaMachinesMax);
return new ProcessingLogic()
.setOverclock(true)
.setEUtModifier(1 - Math.min(0.1 * (this.heatLevel.getTier() + 1), 0.5))
.setMaxParallel(Configuration.Multiblocks.megaMachinesMax);
}

public HeatingCoilLevel getCoilLevel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import java.util.Arrays;
import java.util.Optional;

import javax.annotation.Nonnull;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -60,10 +58,8 @@
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.OverclockCalculator;
import gregtech.api.util.shutdown.ShutDownReasonRegistry;
import gregtech.common.blocks.BlockCasingsAbstract;

Expand Down Expand Up @@ -409,24 +405,14 @@ public SubspaceCoolingFluid findSubspaceCoolingFluid() {

@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

@Nonnull
@Override
protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) {
// Check if the freezer is T2
if (mTier == 1) return super.createOverclockCalculator(recipe);

// First try to detect the current fluid used for subspace cooling.
currentCoolingFluid = findSubspaceCoolingFluid();

return super.createOverclockCalculator(recipe)
.setMachineHeat(currentCoolingFluid == null ? 0 : currentCoolingFluid.perfectOverclocks * 1800)
.setRecipeHeat(0)
.setHeatOC(true)
.setHeatDiscount(false);
}
}.setMaxParallel(Configuration.Multiblocks.megaMachinesMax);
currentCoolingFluid = findSubspaceCoolingFluid();

return new ProcessingLogic()
.setOverclock(true)
.setHeatOC(true)
.setHeatDiscount(false)
.setMachineHeat(currentCoolingFluid == null ? 0 : currentCoolingFluid.perfectOverclocks * 1800)
.setMaxParallel(Configuration.Multiblocks.megaMachinesMax);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe
int overclockAmount = Tier - recipe.mSpecialValue;
return super.createOverclockCalculator(recipe).limitOverclockCount(overclockAmount);
}
}.enablePerfectOverclock();
}.setPerfectOverclock();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.api.util.IGTHatchAdder;
import gregtech.api.util.MultiblockTooltipBuilder;
import gregtech.api.util.OverclockCalculator;
import tectech.thing.metaTileEntity.multi.base.INameFunction;
import tectech.thing.metaTileEntity.multi.base.IStatusFunction;
import tectech.thing.metaTileEntity.multi.base.LedStatus;
Expand Down Expand Up @@ -111,14 +109,6 @@ public MTENeutronActivator(int id, String name, String nameRegional) {
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

@NotNull
@Override
protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) {
return OverclockCalculator.ofNoOverclock(recipe)
.setDuration((int) Math.ceil(recipe.mDuration * Math.pow(0.9f, height - 4)))
.setDurationUnderOneTickSupplier(() -> recipe.mDuration * Math.pow(0.9f, height - 4));
}

@NotNull
@Override
public CheckRecipeResult process() {
Expand All @@ -132,10 +122,10 @@ public CheckRecipeResult process() {
overwriteOutputItems(ItemRefer.Radioactive_Waste.get(4));
}
// NA does not consume power, its hatches do. Set it to 0 to be sure
calculatedEut = 0;
calculatedEUt = 0;
return result;
}
};
}.setDurationSupplier((recipe) -> recipe.mDuration * Math.pow(0.9f, this.height - 4));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
import gregtech.api.util.GTUtility;
import gregtech.api.util.HatchElementBuilder;
import gregtech.api.util.OverclockCalculator;
import gregtech.api.util.ParallelHelper;
import gregtech.api.util.ProcessingHelper;
import gregtech.api.util.shutdown.ShutDownReasonRegistry;
import gregtech.common.tileentities.machines.IDualInputHatch;
import gregtech.common.tileentities.machines.multi.drone.MTEHatchDroneDownLink;
Expand Down Expand Up @@ -422,9 +422,9 @@ protected ProcessingLogic createProcessingLogic() {

@NotNull
@Override
protected ParallelHelper createParallelHelper(@NotNull GTRecipe recipe) {
protected ProcessingHelper createProcessingHelper(@NotNull GTRecipe recipe) {
// When the fusion first loads and is still processing, it does the recipe check without consuming.
return super.createParallelHelper(recipe).setConsumption(!mRunningOnLoad);
return super.createProcessingHelper(recipe).setConsumption(!mRunningOnLoad);
}

@NotNull
Expand Down
Empty file.
Empty file.
Loading
Loading