diff options
author | Mary <33456283+FourIsTheNumber@users.noreply.github.com> | 2024-10-15 09:27:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 15:27:35 +0200 |
commit | b7aaa0598761166b7c3e8ad6d347ca1d729d61b8 (patch) | |
tree | 9a9f7651128909c912001e03ccd809103e7113a1 /src/main/java/gregtech | |
parent | 7fb9507351fe1e62dfac2f6fa52e94dcb85e0e74 (diff) | |
download | GT5-Unofficial-b7aaa0598761166b7c3e8ad6d347ca1d729d61b8.tar.gz GT5-Unofficial-b7aaa0598761166b7c3e8ad6d347ca1d729d61b8.tar.bz2 GT5-Unofficial-b7aaa0598761166b7c3e8ad6d347ca1d729d61b8.zip |
Small rework to black hole instability (#3372)
Diffstat (limited to 'src/main/java/gregtech')
-rw-r--r-- | src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java | 5 | ||||
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java | 96 |
2 files changed, 52 insertions, 49 deletions
diff --git a/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java b/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java index dc7fc0d6a6..95443e8383 100644 --- a/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java +++ b/src/main/java/gregtech/api/recipe/check/CheckRecipeResultRegistry.java @@ -113,11 +113,6 @@ public final class CheckRecipeResultRegistry { * Black Hole Compressor does not have an active black hole */ public static final CheckRecipeResult NO_BLACK_HOLE = SimpleCheckRecipeResult.ofFailure("no_black_hole"); - /** - * Black Hole Compressor became unstable - */ - public static final CheckRecipeResult UNSTABLE_BLACK_HOLE = SimpleCheckRecipeResult - .ofFailure("unstable_black_hole"); public static final CheckRecipeResult NO_SEE_SKY = SimpleCheckRecipeResult.ofFailure("no_see_sky"); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java index 13d6f7c1bb..7b444c6573 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java @@ -336,7 +336,7 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl + EnumChatFormatting.GRAY + " until it reaches 0") .addInfo("At 0 stability, the black hole is " + EnumChatFormatting.DARK_RED + "UNSTABLE") - .addInfo("Once the black hole becomes unstable, it will void all inputs instantly!") + .addInfo("Once the black hole becomes unstable, it will void recipes and eventually close itself!") .addSeparator() .addInfo("Running recipes in the machine will slow the decay rate by " + EnumChatFormatting.RED + "25%") .addInfo( @@ -558,15 +558,6 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); return super.validateRecipe(recipe); } - - @Nonnull - protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { - // If recipe needs a black hole and one is active but unstable, continuously void items - if (blackHoleStatus == 3) { - return CheckRecipeResultRegistry.UNSTABLE_BLACK_HOLE; - } - return CheckRecipeResultRegistry.SUCCESSFUL; - } }.setMaxParallelSupplier(this::getMaxParallelRecipes) .setEuModifier(0.7F) .setSpeedBonus(0.2F); @@ -589,44 +580,61 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl if (!aBaseMetaTileEntity.isServerSide()) { playBlackHoleSounds(); } - if (aTick % 20 == 0) { - if (blackHoleStatus == 2) { - if (blackHoleStability >= 0) { - float stabilityDecrease = 1F; - // If the machine is running, reduce stability loss by 25% - if (this.maxProgresstime() != 0) { - stabilityDecrease = 0.75F; - } - // Search all hatches for catalyst fluid - // If found enough, drain it and reduce stability loss to 0 - // Every 30 drains, double the cost - FluidStack totalCost = new FluidStack(blackholeCatalyzingCost, catalyzingCostModifier); - - boolean didDrain = false; - for (MTEHatchInput hatch : spacetimeHatches) { - if (drain(hatch, totalCost, false)) { - drain(hatch, totalCost, true); - catalyzingCounter += 1; - stabilityDecrease = 0; - if (catalyzingCounter >= 30) { - catalyzingCostModifier *= 2; - catalyzingCounter = 0; - } - didDrain = true; - break; - } - } - if (shouldRender) { - if (rendererTileEntity == null) createRenderBlock(); - rendererTileEntity.toggleLaser(didDrain); - rendererTileEntity.setStability(blackHoleStability / 100F); + // Run stability checks once per second if a black hole is open + if (blackHoleStatus == 1 || aTick % 20 != 0) return; + + // Base 1 loss + float stabilityDecrease = 1F; + + boolean didDrain = false; + + // Only do loss reductions if the black hole is stable - unstable black hole can't be frozen + if (blackHoleStability >= 0) { + + // If the machine is running, reduce stability loss by 25% + if (this.maxProgresstime() != 0) { + stabilityDecrease = 0.75F; + } + + // Search all hatches for catalyst fluid + // If found enough, drain it and reduce stability loss to 0 + // Every 30 drains, double the cost + FluidStack totalCost = new FluidStack(blackholeCatalyzingCost, catalyzingCostModifier); + + for (MTEHatchInput hatch : spacetimeHatches) { + if (drain(hatch, totalCost, false)) { + drain(hatch, totalCost, true); + catalyzingCounter += 1; + stabilityDecrease = 0; + if (catalyzingCounter >= 30) { + // Hidden cap at 1B per tick so we don't integer overflow + if (catalyzingCostModifier <= 1000000000) catalyzingCostModifier *= 2; + catalyzingCounter = 0; } - if (blackHoleStability >= 0) blackHoleStability -= stabilityDecrease; - else blackHoleStability = 0; - } else blackHoleStatus = 3; + didDrain = true; + break; + } } + } else blackHoleStatus = 3; + + if (shouldRender) { + if (rendererTileEntity == null) createRenderBlock(); + rendererTileEntity.toggleLaser(didDrain); + rendererTileEntity.setStability(blackHoleStability / 100F); + } + + blackHoleStability -= stabilityDecrease; + + // Close black hole and reset if it has been unstable for 15 minutes or more + if (blackHoleStability <= -900) { + blackHoleStatus = 1; + blackHoleStability = 100; + catalyzingCostModifier = 1; + rendererTileEntity = null; + destroyRenderBlock(); } + } public int getMaxParallelRecipes() { |