From b7aaa0598761166b7c3e8ad6d347ca1d729d61b8 Mon Sep 17 00:00:00 2001 From: Mary <33456283+FourIsTheNumber@users.noreply.github.com> Date: Tue, 15 Oct 2024 09:27:35 -0400 Subject: Small rework to black hole instability (#3372) --- .../recipe/check/CheckRecipeResultRegistry.java | 5 -- .../multi/compressor/MTEBlackHoleCompressor.java | 96 ++++++++++++---------- src/main/resources/assets/gregtech/lang/en_US.lang | 1 - 3 files changed, 52 insertions(+), 50 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= 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() { diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index d76bdfdefc..53a2282b08 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -535,7 +535,6 @@ GT5U.gui.text.drill_generic_finished=§7Mining pipes have been retracted GT5U.gui.text.drill_retract_pipes_finished=§7Operation aborted GT5U.gui.text.backfiller_no_concrete=§7No liquid concrete GT5U.gui.text.no_black_hole=§7Requires an active black hole -GT5U.gui.text.unstable_black_hole=§7Black hole is unstable GT5U.gui.text.backfiller_finished=§aWork complete GT5U.gui.text.backfiller_working=§aPouring concrete GT5U.gui.text.backfiller_current_area=§7Filling at y-level: §a%s -- cgit