aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaya <10861407+serenibyss@users.noreply.github.com>2024-10-03 15:39:53 -0500
committerGitHub <noreply@github.com>2024-10-03 22:39:53 +0200
commitc7b62657804a5bf6278b485d6fcb8b3e9b7e5c77 (patch)
treed7b64c67a0e373dab4c906c5e5736f5ad73cba6d
parent7e5ebec80b0f55c9a4412b801037c9d8a2a2a541 (diff)
downloadGT5-Unofficial-c7b62657804a5bf6278b485d6fcb8b3e9b7e5c77.tar.gz
GT5-Unofficial-c7b62657804a5bf6278b485d6fcb8b3e9b7e5c77.tar.bz2
GT5-Unofficial-c7b62657804a5bf6278b485d6fcb8b3e9b7e5c77.zip
Fix issues with catalyst damage + empty catalyst output (#3321)
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java
index 1e5d1bb9ea..f678f084fc 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/MTEChemicalPlant.java
@@ -545,21 +545,25 @@ public class MTEChemicalPlant extends GTPPMultiBlockBase<MTEChemicalPlant> imple
}
}
- private void damageCatalyst(@Nonnull ItemStack aStack, int minParallel) {
+ /**
+ * @return if the catalyst item is fully destroyed as a result of the damage applied.
+ */
+ private boolean damageCatalyst(@Nonnull ItemStack aStack, int minParallel) {
// Awakened Draconium Coils with Tungstensteel Pipe Casings (or above) no longer consume catalysts.
- if (!isCatalystDamageable()) return;
+ if (!isCatalystDamageable()) return false;
for (int i = 0; i < minParallel; i++) {
if (MathUtils.randFloat(0, 10000000) / 10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) {
int damage = getDamage(aStack) + 1;
if (damage >= getMaxCatalystDurability()) {
addOutput(CI.getEmptyCatalyst(1));
aStack.stackSize -= 1;
- return;
+ return aStack.stackSize == 0;
} else {
setDamage(aStack, damage);
}
}
}
+ return false;
}
private boolean isCatalystDamageable() {
@@ -592,6 +596,9 @@ public class MTEChemicalPlant extends GTPPMultiBlockBase<MTEChemicalPlant> imple
if (catalyst == null) {
return SimpleCheckRecipeResult.ofFailure("no_catalyst");
}
+ } else {
+ // remove reference to the old catalyst if our new recipe doesn't use it
+ catalyst = null;
}
return CheckRecipeResultRegistry.SUCCESSFUL;
}
@@ -608,8 +615,9 @@ public class MTEChemicalPlant extends GTPPMultiBlockBase<MTEChemicalPlant> imple
@NotNull
@Override
protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) {
- if (catalyst != null) {
- damageCatalyst(catalyst, getCurrentParallels());
+ if (!GTUtility.isStackValid(catalyst) || damageCatalyst(catalyst, getCurrentParallels())) {
+ // remove reference to the catalyst if it is invalid, or if the damage destroys it
+ catalyst = null;
}
return super.onRecipeStart(recipe);
}