diff options
author | Mary <33456283+FourIsTheNumber@users.noreply.github.com> | 2024-11-09 12:35:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-09 17:35:22 +0000 |
commit | d68b5f2c075dfec21d40bc1c2ab6517fefdff8a5 (patch) | |
tree | 12a6e49557af5538797cd25c5e1c4b373c53f8f4 /src/main/java/gregtech/common/tileentities/machines | |
parent | 269ac07061395f408678040978285c9478219370 (diff) | |
download | GT5-Unofficial-d68b5f2c075dfec21d40bc1c2ab6517fefdff8a5.tar.gz GT5-Unofficial-d68b5f2c075dfec21d40bc1c2ab6517fefdff8a5.tar.bz2 GT5-Unofficial-d68b5f2c075dfec21d40bc1c2ab6517fefdff8a5.zip |
Blackhole fixes (#3470)
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines')
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java | 70 |
1 files changed, 39 insertions, 31 deletions
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 4558c732c8..d945dde089 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 @@ -19,6 +19,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_BLACKHOLE_UNS import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_BLACKHOLE_UNSTABLE_GLOW; import static gregtech.api.util.GTStructureUtility.buildHatchAdder; import static gregtech.api.util.GTStructureUtility.ofFrame; +import static gregtech.api.util.GTUtility.filterValidMTEs; import java.util.ArrayList; import java.util.Arrays; @@ -77,6 +78,7 @@ import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; import gregtech.common.blocks.BlockCasings10; import gregtech.common.items.MetaGeneratedItem01; +import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch; import gregtech.common.tileentities.render.TileEntityBlackhole; import gtPlusPlus.core.util.minecraft.PlayerUtils; import mcp.mobius.waila.api.IWailaConfigHandler; @@ -474,33 +476,32 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl // Loop through all items and look for the Activation and Deactivation Catalysts // Deactivation resets stability to 100 and catalyzing cost to 1 - // Has to do this "start/endRecipeProcessing" nonsense, or it doesn't work with stocking bus. - for (MTEHatchInputBus bus : mInputBusses) { - ItemStack[] inv = bus.getRealInventory(); - if (inv != null) { - for (int i = 0; i < inv.length; i++) { - ItemStack inputItem = inv[i]; - if (inputItem != null) { - if (inputItem.getItem() instanceof MetaGeneratedItem01) { - if (inputItem.getItemDamage() == 32418 && (blackHoleStatus == 1)) { - startRecipeProcessing(); - bus.decrStackSize(i, 1); - endRecipeProcessing(); - blackHoleStatus = 2; - createRenderBlock(); - return; - } else if (inputItem.getItemDamage() == 32419 && !(blackHoleStatus == 1)) { - startRecipeProcessing(); - bus.decrStackSize(i, 1); - endRecipeProcessing(); - inputItem.stackSize -= 1; - blackHoleStatus = 1; - blackHoleStability = 100; - catalyzingCostModifier = 1; - if (rendererTileEntity != null) rendererTileEntity.startScaleChange(false); - collapseTimer = 40; - return; + for (MTEHatchInputBus bus : filterValidMTEs(mInputBusses)) { + for (int i = 0; i < bus.getSizeInventory(); i++) { + ItemStack inputItem = bus.getStackInSlot(i); + if (inputItem != null) { + if (inputItem.getItem() instanceof MetaGeneratedItem01) { + if (inputItem.getItemDamage() == 32418 && (blackHoleStatus == 1)) { + bus.decrStackSize(i, 1); + if (bus instanceof IRecipeProcessingAwareHatch aware) { + setResultIfFailure(aware.endRecipeProcessing(this)); + aware.startRecipeProcessing(); } + blackHoleStatus = 2; + createRenderBlock(); + return; + } else if (inputItem.getItemDamage() == 32419 && !(blackHoleStatus == 1)) { + bus.decrStackSize(i, 1); + if (bus instanceof IRecipeProcessingAwareHatch aware) { + setResultIfFailure(aware.endRecipeProcessing(this)); + aware.startRecipeProcessing(); + } + blackHoleStatus = 1; + blackHoleStability = 100; + catalyzingCostModifier = 1; + if (rendererTileEntity != null) rendererTileEntity.startScaleChange(false); + collapseTimer = 40; + return; } } } @@ -509,14 +510,18 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl } @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + searchAndDecrementCatalysts(); + } + + @Override protected ProcessingLogic createProcessingLogic() { return new ProcessingLogic() { @NotNull @Override protected Stream<GTRecipe> findRecipeMatches(@Nullable RecipeMap<?> map) { - searchAndDecrementCatalysts(); - switch (getModeFromCircuit(inputItems)) { case MACHINEMODE_COMPRESSOR -> { return super.findRecipeMatches(RecipeMaps.compressorRecipes); @@ -582,9 +587,6 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if (!aBaseMetaTileEntity.isServerSide()) { - playBlackHoleSounds(); - } if (collapseTimer != -1) { if (collapseTimer == 0) { @@ -593,6 +595,12 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl collapseTimer--; } + // Skip all the drain logic for clientside, just play sounds + if (!aBaseMetaTileEntity.isServerSide()) { + playBlackHoleSounds(); + return; + } + // Run stability checks once per second if a black hole is open if (blackHoleStatus == 1 || aTick % 20 != 0) return; |