Skip to content

Commit

Permalink
Fix stocking bus on black hole (GTNewHorizons#3217)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <dream-master@gmx.net>
  • Loading branch information
FourIsTheNumber and Dream-Master authored Sep 17, 2024
1 parent c7e451f commit 89b6865
Showing 1 changed file with 39 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -434,37 +434,52 @@ 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() {

@NotNull
@Override
protected Stream<GTRecipe> 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
Expand Down

0 comments on commit 89b6865

Please sign in to comment.