From 89b686513756e38b20105749dd2aff1de7bd1372 Mon Sep 17 00:00:00 2001 From: Mary <33456283+FourIsTheNumber@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:54:42 -0400 Subject: [PATCH] Fix stocking bus on black hole (#3217) Co-authored-by: Martin Robertz --- .../compressor/MTEBlackHoleCompressor.java | 63 ++++++++++++------- 1 file changed, 39 insertions(+), 24 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 39538bfc7f6..ba1c38db405 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 @@ -434,6 +434,44 @@ private int getModeFromCircuit(ItemStack[] t) { return 0; } + private void searchAndDecrementCatalysts() { + // 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; + rendererTileEntity = null; + destroyRenderBlock(); + return; + } + } + } + } + } + } + } + @Override protected ProcessingLogic createProcessingLogic() { return new ProcessingLogic() { @@ -441,30 +479,7 @@ protected ProcessingLogic createProcessingLogic() { @NotNull @Override protected Stream findRecipeMatches(@Nullable RecipeMap map) { - // Loop through all items and look for the Activation and Deactivation Catalysts - // Deactivation resets stability to 100 and catalyzing cost to 1 - for (MTEHatchInputBus bus : mInputBusses) { - for (ItemStack inputItem : bus.mInventory) { - if (inputItem != null) { - if (inputItem.getItem() instanceof MetaGeneratedItem01) { - if (inputItem.getItemDamage() == 32418 && (blackHoleStatus == 1)) { - inputItem.stackSize -= 1; - blackHoleStatus = 2; - createRenderBlock(); - break; - } else if (inputItem.getItemDamage() == 32419 && !(blackHoleStatus == 1)) { - inputItem.stackSize -= 1; - blackHoleStatus = 1; - blackHoleStability = 100; - catalyzingCostModifier = 1; - rendererTileEntity = null; - destroyRenderBlock(); - break; - } - } - } - } - } + searchAndDecrementCatalysts(); RecipeMap realMap = (getModeFromCircuit(inputItems) == MACHINEMODE_COMPRESSOR) ? RecipeMaps.compressorRecipes