Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
Fix compact fusions (#241)
Browse files Browse the repository at this point in the history
* fix machine not shut down when no enough startup power

* tweak EU capacity and power restriction for a single hatch

* fix missing OCs and code clean

* too much hatch power
  • Loading branch information
HoleFish authored Mar 12, 2024
1 parent af38e95 commit 71709d9
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,22 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType("Fusion Reactor").addInfo("Millions of nuclear.")
.addInfo("Controller block for the Compact Fusion Reactor MK-I Prototype.")
.addInfo("131,072EU/t and 5M EU capacity per Energy Hatch")
.addInfo(
EnumChatFormatting.AQUA + GT_Utility.formatNumbers(getSingleHatchPower())
+ EnumChatFormatting.GRAY
+ " EU/t and "
+ EnumChatFormatting.AQUA
+ GT_Utility.formatNumbers(capableStartupCanonical() / 32 / M)
+ "M"
+ EnumChatFormatting.GRAY
+ " EU capacity per Energy Hatch")
.addInfo("If the recipe has a startup cost greater than the")
.addInfo("number of energy hatches * cap, you can't do it")
.addInfo(
"If the recipe requires a voltage tier over "
+ GT_Utility.getColoredTierNameFromTier((byte) tier())
+ EnumChatFormatting.GRAY
+ " , you can't do it either")
.addInfo("Make sure the whole structure is built in the 3x3")
.addInfo("chunk area of the ring center (not controller).").addInfo("It can run 64x recipes at most.")
.addInfo(
Expand Down Expand Up @@ -72,11 +85,6 @@ public int tier() {
return 6;
}

@Override
public long maxEUStore() {
return 160008000L * (Math.min(32, this.mEnergyHatches.size() + this.eEnergyMulti.size())) / 32L;
}

@Override
public long capableStartupCanonical() {
return 160_000_000;
Expand Down Expand Up @@ -137,11 +145,6 @@ public ITexture getTextureOverlay() {
return textureOverlay;
}

@Override
public int tierOverclock() {
return 1;
}

@Override
public String[] getStructureDescription(ItemStack stackSize) {
return DescTextLocalization.addText("LargeFusion1.hint", 9);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,25 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType("Fusion Reactor").addInfo("Millions of nuclear.")
.addInfo("Controller block for the Compact Fusion Reactor MK-II.")
.addInfo("524,288EU/t and 10M EU capacity per Energy Hatch")
.addInfo(
EnumChatFormatting.AQUA + GT_Utility.formatNumbers(getSingleHatchPower())
+ EnumChatFormatting.GRAY
+ " EU/t and "
+ EnumChatFormatting.AQUA
+ GT_Utility.formatNumbers(capableStartupCanonical() / 32 / M)
+ "M"
+ EnumChatFormatting.GRAY
+ " EU capacity per Energy Hatch")
.addInfo("If the recipe has a startup cost greater than the")
.addInfo("number of energy hatches * cap, you can't do it")
.addInfo(
"If the recipe requires a voltage tier over "
+ GT_Utility.getColoredTierNameFromTier((byte) tier())
+ EnumChatFormatting.GRAY
+ " , you can't do it either")
.addInfo("Make sure the whole structure is built in the 3x3")
.addInfo("chunk area of the ring center (not controller).")
.addInfo("Startup < 160,000,000 EU: 128x Parallel").addInfo("Startup < 320,000,000 EU: 64x Parallel")
.addInfo("Startup < 160,000,000 EU: 128x Parallel").addInfo("Startup >= 160,000,000 EU: 64x Parallel")
.addInfo(
"Support" + EnumChatFormatting.BLUE
+ " Tec"
Expand All @@ -73,11 +86,6 @@ public int tier() {
return 7;
}

@Override
public long maxEUStore() {
return 320006000L * (Math.min(32, this.mEnergyHatches.size() + this.eEnergyMulti.size())) / 32L;
}

@Override
public long capableStartupCanonical() {
return 320_000_000;
Expand Down Expand Up @@ -138,11 +146,6 @@ public ITexture getTextureOverlay() {
return textureOverlay;
}

@Override
public int tierOverclock() {
return 2;
}

@Override
public String[] getStructureDescription(ItemStack stackSize) {
return DescTextLocalization.addText("LargeFusion2.hint", 9);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,26 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType("Fusion Reactor").addInfo("Millions of nuclear.")
.addInfo("Controller block for the Compact Fusion Reactor MK-III.")
.addInfo("1,572,864EU/t and 20M EU capacity per Energy Hatch")
.addInfo(
EnumChatFormatting.AQUA + GT_Utility.formatNumbers(getSingleHatchPower())
+ EnumChatFormatting.GRAY
+ " EU/t and "
+ EnumChatFormatting.AQUA
+ GT_Utility.formatNumbers(capableStartupCanonical() / 32 / M)
+ "M"
+ EnumChatFormatting.GRAY
+ " EU capacity per Energy Hatch")
.addInfo("If the recipe has a startup cost greater than the")
.addInfo("number of energy hatches * cap, you can't do it")
.addInfo(
"If the recipe requires a voltage tier over "
+ GT_Utility.getColoredTierNameFromTier((byte) tier())
+ EnumChatFormatting.GRAY
+ " , you can't do it either")
.addInfo("Make sure the whole structure is built in the 3x3")
.addInfo("chunk area of the ring center (not controller).")
.addInfo("Startup < 160,000,000 EU: 192x Parallel").addInfo("Startup < 320,000,000 EU: 128x Parallel")
.addInfo("Startup < 640,000,000 EU: 64x Parallel")
.addInfo("Startup >= 320,000,000 EU: 64x Parallel")
.addInfo(
"Support" + EnumChatFormatting.BLUE
+ " Tec"
Expand All @@ -74,11 +87,6 @@ public int tier() {
return 8;
}

@Override
public long maxEUStore() {
return 640060000L * (Math.min(32, this.mEnergyHatches.size() + this.eEnergyMulti.size())) / 32L;
}

@Override
public long capableStartupCanonical() {
return 640_000_000;
Expand Down Expand Up @@ -139,11 +147,6 @@ public ITexture getTextureOverlay() {
return textureOverlay;
}

@Override
public int tierOverclock() {
return 4;
}

@Override
public String[] getStructureDescription(ItemStack stackSize) {
return DescTextLocalization.addText("LargeFusion3.hint", 9);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,22 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType("Fusion Reactor").addInfo("Galaxy Collapse.")
.addInfo("Controller block for the Compact Fusion Reactor MK-IV Prototype.")
.addInfo("33,554,432EU/t and 80M EU capacity per Energy Hatch")
.addInfo(
EnumChatFormatting.AQUA + GT_Utility.formatNumbers(getSingleHatchPower())
+ EnumChatFormatting.GRAY
+ " EU/t and "
+ EnumChatFormatting.AQUA
+ GT_Utility.formatNumbers(capableStartupCanonical() / 32 / M)
+ "M"
+ EnumChatFormatting.GRAY
+ " EU capacity per Energy Hatch")
.addInfo("If the recipe has a startup cost greater than the")
.addInfo("number of energy hatches * cap, you can't do it")
.addInfo(
"If the recipe requires a voltage tier over "
+ GT_Utility.getColoredTierNameFromTier((byte) tier())
+ EnumChatFormatting.GRAY
+ " , you can't do it either")
.addInfo("Make sure the whole structure is built in the 3x3")
.addInfo("chunk area of the ring center (not controller).").addInfo("Performs 4/4 overclock.")
.addInfo("Startup < 160,000,000 EU: 256x Parallel").addInfo("Startup < 320,000,000 EU: 192x Parallel")
Expand Down Expand Up @@ -79,14 +92,9 @@ public int tier() {
return 9;
}

@Override
public long maxEUStore() {
return 2560060000L * (Math.min(32, this.mEnergyHatches.size() + this.eEnergyMulti.size())) / 32L;
}

@Override
public long capableStartupCanonical() {
return 2_560_060_000L;
return 5_120_000_000L;
}

@Override
Expand Down Expand Up @@ -142,11 +150,6 @@ public int getMaxPara() {
return 64;
}

@Override
public int tierOverclock() {
return 8;
}

@Override
public int extraPara(int startEnergy) {
if (startEnergy < 160000000) return 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,22 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType("Fusion Reactor").addInfo("Galaxy Collapse.")
.addInfo("Controller block for the Compact Fusion Reactor MK-V.")
.addInfo("167,772,160EU/t and 320M EU capacity per Energy Hatch")
.addInfo(
EnumChatFormatting.AQUA + GT_Utility.formatNumbers(getSingleHatchPower())
+ EnumChatFormatting.GRAY
+ " EU/t and "
+ EnumChatFormatting.AQUA
+ GT_Utility.formatNumbers(capableStartupCanonical() / 32 / M)
+ "M"
+ EnumChatFormatting.GRAY
+ " EU capacity per Energy Hatch")
.addInfo("If the recipe has a startup cost greater than the")
.addInfo("number of energy hatches * cap, you can't do it")
.addInfo(
"If the recipe requires a voltage tier over "
+ GT_Utility.getColoredTierNameFromTier((byte) tier())
+ EnumChatFormatting.GRAY
+ " , you can't do it either")
.addInfo("Make sure the whole structure is built in the 3x3")
.addInfo("chunk area of the ring center (not controller).").addInfo("Performs 4/4 overclock.")
.addInfo("Startup < 160,000,000 EU: 320x Parallel").addInfo("Startup < 320,000,000 EU: 256x Parallel")
Expand Down Expand Up @@ -79,14 +92,9 @@ public int tier() {
return 10;
}

@Override
public long maxEUStore() {
return 10240800000L * (Math.min(32, this.mEnergyHatches.size() + this.eEnergyMulti.size())) / 32L;
}

@Override
public long capableStartupCanonical() {
return 10_240_800_000L;
return 20_480_000_000L;
}

@Override
Expand Down Expand Up @@ -142,11 +150,6 @@ public int getMaxPara() {
return 64;
}

@Override
public int tierOverclock() {
return 16;
}

@Override
public int extraPara(int startEnergy) {
if (startEnergy < 160000000) return 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static gregtech.api.util.GT_StructureUtility.filterByMTETier;
import static gregtech.api.util.GT_StructureUtility.ofFrame;
import static gregtech.api.util.GT_Utility.filterValidMTEs;
import static gregtech.api.util.GT_Utility.roundUpVoltage;

import java.util.List;

Expand Down Expand Up @@ -69,6 +68,7 @@ public abstract class LargeFusionComputer extends GT_MetaTileEntity_TooltipMulti
implements IConstructable, ISurvivalConstructable, IOverclockDescriptionProvider {

public static final String MAIN_NAME = "largeFusion";
public static final int M = 1_000_000;
private boolean isLoadedChunk;
public GT_Recipe mLastRecipe;
public int para;
Expand Down Expand Up @@ -140,7 +140,9 @@ public OverclockDescriber getOverclockDescriber() {
public abstract int tier();

@Override
public abstract long maxEUStore();
public long maxEUStore() {
return capableStartupCanonical() * (Math.min(32, this.mEnergyHatches.size() + this.eEnergyMulti.size())) / 32L;
}

/**
* Unlike {@link #maxEUStore()}, this provides theoretical limit of startup EU, without considering the amount of
Expand Down Expand Up @@ -326,6 +328,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
< this.mLastRecipe.mSpecialValue + this.lEUt) {
mMaxProgresstime = 0;
turnCasingActive(false);
criticalStopMachine();
}
getBaseMetaTileEntity().decreaseStoredEnergyUnits(
this.mLastRecipe.mSpecialValue + this.lEUt,
Expand Down Expand Up @@ -353,7 +356,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
* @return The power one hatch can deliver to the reactor
*/
protected long getSingleHatchPower() {
return 2048L * tierOverclock() * getMaxPara() * extraPara(100);
return GT_Values.V[tier()] * getMaxPara() * extraPara(100) / 32;
}

public boolean turnCasingActive(boolean status) {
Expand Down Expand Up @@ -405,27 +408,6 @@ public void onMachineBlockUpdate() {
mUpdate = 100;
}

public abstract int tierOverclock();

public int overclock(int mStartEnergy) {
if (tierOverclock() == 1) {
return 0;
}
if (tierOverclock() == 2) {
return mStartEnergy <= 160000000 ? 1 : 0;
}
if (tierOverclock() == 4) {
return (mStartEnergy <= 160000000 ? 2 : (mStartEnergy <= 320000000 ? 1 : 0));
}
if (tierOverclock() == 8) {
return (mStartEnergy <= 160000000) ? 3
: ((mStartEnergy <= 320000000) ? 2 : (mStartEnergy <= 640000000) ? 1 : 0);
}
return (mStartEnergy <= 160000000) ? 4
: ((mStartEnergy <= 320000000) ? 3
: ((mStartEnergy <= 640000000) ? 2 : (mStartEnergy <= 1280000000) ? 1 : 0));
}

@Override
public RecipeMap<?> getRecipeMap() {
return RecipeMaps.fusionRecipes;
Expand All @@ -450,19 +432,19 @@ protected GT_ParallelHelper createParallelHelper(@NotNull GT_Recipe recipe) {
@NotNull
@Override
protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe) {
int overclockCount = overclock(recipe.mSpecialValue);
if (GT_Values.VP[LargeFusionComputer.this.tier()] <= roundUpVoltage(recipe.mEUt)) {
overclockCount = 0;
}
return super.createOverclockCalculator(recipe).limitOverclockCount(overclockCount);
return overclockDescriber.createCalculator(super.createOverclockCalculator(recipe), recipe);
}

@NotNull
@Override
protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) {
if (!mRunningOnLoad && recipe.mSpecialValue > maxEUStore()
|| GT_Values.VP[LargeFusionComputer.this.tier()] < recipe.mEUt) {
return CheckRecipeResultRegistry.insufficientStartupPower(recipe.mSpecialValue);
if (!mRunningOnLoad) {
if (recipe.mSpecialValue > maxEUStore()) {
return CheckRecipeResultRegistry.insufficientStartupPower(recipe.mSpecialValue);
}
if (recipe.mEUt > GT_Values.V[tier()]) {
return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt);
}
}
maxParallel = getMaxPara() * extraPara(recipe.mSpecialValue);
return CheckRecipeResultRegistry.SUCCESSFUL;
Expand All @@ -482,14 +464,13 @@ public CheckRecipeResult process() {
para = getCurrentParallels();
return result;
}
}.setOverclock(1, 1);
};
}

@Override
protected void setProcessingLogicPower(ProcessingLogic logic) {
logic.setAvailableVoltage(GT_Values.V[hatchTier()]);
logic.setAvailableAmperage(
getSingleHatchPower() * (mEnergyHatches.size() + eEnergyMulti.size()) / GT_Values.V[hatchTier()]);
logic.setAvailableVoltage(GT_Values.V[tier()]);
logic.setAvailableAmperage(getSingleHatchPower() * 32 / GT_Values.V[tier()]);
}

@Override
Expand Down Expand Up @@ -549,11 +530,6 @@ public IStructureDefinition<LargeFusionComputer> getStructure_EM() {
return STRUCTURE_DEFINITION.get(getClass());
}

@Override
public boolean isGivingInformation() {
return true;
}

@Override
public int getMaxEfficiency(ItemStack aStack) {
return 10000;
Expand All @@ -577,7 +553,7 @@ protected ResourceLocation getActivitySound() {
@Override
public String[] getInfoData() {
IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity();
String tier = switch (hatchTier()) {
String tier = switch (tier()) {
case 6 -> EnumChatFormatting.RED + "I" + EnumChatFormatting.RESET;
case 7 -> EnumChatFormatting.RED + "II" + EnumChatFormatting.RESET;
case 8 -> EnumChatFormatting.RED + "III" + EnumChatFormatting.RESET;
Expand Down
Loading

0 comments on commit 71709d9

Please sign in to comment.