aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util/GT_Recipe.java
diff options
context:
space:
mode:
authorJohann Bernhardt <johann.bernhardt@tum.de>2021-12-01 14:34:14 +0100
committerJohann Bernhardt <johann.bernhardt@tum.de>2021-12-01 14:34:14 +0100
commit8e45b04722ee129ff412d8329b93d35eb8744c1f (patch)
tree5ed344f739e2349854b6acb5d451f00d8ca35319 /src/main/java/gregtech/api/util/GT_Recipe.java
parent899aa570f096e2850e35627950f9f67ccfe8b186 (diff)
parent5fc226f1385e13afbf3406f4d3283638fc7b8a70 (diff)
downloadGT5-Unofficial-8e45b04722ee129ff412d8329b93d35eb8744c1f.tar.gz
GT5-Unofficial-8e45b04722ee129ff412d8329b93d35eb8744c1f.tar.bz2
GT5-Unofficial-8e45b04722ee129ff412d8329b93d35eb8744c1f.zip
Merge remote-tracking branch 'origin/experimental' into unify-build-script
# Conflicts: # .github/workflows/gradle.yml # build.gradle # build.properties
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_Recipe.java')
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java53
1 files changed, 36 insertions, 17 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index c0ea06af07..6e12a3d36c 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -1585,23 +1585,8 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
GT_Recipe rRecipe = super.findRecipe(aTileEntity, aRecipe, aNotUnificated, aVoltage, aFluids, aSpecialSlot, aInputs);
if (aInputs == null || aInputs.length < 2 || aInputs[0] == null || aInputs[1] == null || !GregTech_API.sPostloadFinished)
return rRecipe;
- if (rRecipe == null) {
- if (ItemList.Shape_Mold_Name.isStackEqual(aInputs[0], false, true)) {
- ItemStack tOutput = GT_Utility.copyAmount(1, aInputs[1]);
- tOutput.setStackDisplayName(aInputs[0].getDisplayName());
- rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, aInputs[1])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 8, 0);
- rRecipe.mCanBeBuffered = false;
- return rRecipe;
- }
- if (ItemList.Shape_Mold_Name.isStackEqual(aInputs[1], false, true)) {
- ItemStack tOutput = GT_Utility.copyAmount(1, aInputs[0]);
- tOutput.setStackDisplayName(aInputs[1].getDisplayName());
- rRecipe = new GT_Recipe(false, new ItemStack[]{ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, aInputs[0])}, new ItemStack[]{tOutput}, null, null, null, null, 128, 8, 0);
- rRecipe.mCanBeBuffered = false;
- return rRecipe;
- }
- return null;
- }
+ if (rRecipe == null)
+ return findRenamingRecipe(aInputs);
for (ItemStack aMold : aInputs) {
if (ItemList.Shape_Mold_Credit.isStackEqual(aMold, false, true)) {
NBTTagCompound tNBT = aMold.getTagCompound();
@@ -1617,6 +1602,40 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
}
return rRecipe;
}
+
+ private ItemStack findNameMoldIndex(ItemStack[] inputs) {
+ for (ItemStack stack: inputs) {
+ if (ItemList.Shape_Mold_Name.isStackEqual(stack, false, true))
+ return stack;
+ }
+ return null;
+ }
+
+ private ItemStack findStackToRename(ItemStack[] inputs, ItemStack mold) {
+ for (ItemStack stack: inputs) {
+ if (stack == mold || stack == null)
+ continue;
+ return stack;
+ }
+ return null;
+ }
+
+ private GT_Recipe findRenamingRecipe(ItemStack[] inputs) {
+ ItemStack mold = findNameMoldIndex(inputs);
+ if (mold == null)
+ return null;
+ ItemStack input = findStackToRename(inputs, mold);
+ if (input == null)
+ return null;
+ ItemStack output = GT_Utility.copyAmount(1, input);
+ output.setStackDisplayName(mold.getDisplayName());
+ GT_Recipe recipe = new GT_Recipe(false,
+ new ItemStack[]{ ItemList.Shape_Mold_Name.get(0), GT_Utility.copyAmount(1, input) },
+ new ItemStack[]{ output },
+ null, null, null, null, 128, 8, 0);
+ recipe.mCanBeBuffered = false;
+ return recipe;
+ }
}
/**