aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
diff options
context:
space:
mode:
authorHoleFish <48403212+HoleFish@users.noreply.github.com>2024-08-24 03:51:40 +0800
committerGitHub <noreply@github.com>2024-08-23 21:51:40 +0200
commit56c98aa0ca2ccab586abe13e3064b1e3499731ec (patch)
treeee64e4ff405d8c6a92cc097d7d18d7bf10b25554 /src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
parent71e7f3dc16a7be69a3f89c17a170d401383bf021 (diff)
downloadGT5-Unofficial-56c98aa0ca2ccab586abe13e3064b1e3499731ec.tar.gz
GT5-Unofficial-56c98aa0ca2ccab586abe13e3064b1e3499731ec.tar.bz2
GT5-Unofficial-56c98aa0ca2ccab586abe13e3064b1e3499731ec.zip
Display real data stick for assembly line recipes in NEI (#2917)
* display real data stick * spotless --------- Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java')
-rw-r--r--src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java72
1 files changed, 37 insertions, 35 deletions
diff --git a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
index 1ada9c78d5..dbe0ff2c40 100644
--- a/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
+++ b/src/main/java/gregtech/api/util/GT_AssemblyLineUtils.java
@@ -367,7 +367,12 @@ public class GT_AssemblyLineUtils {
* @return Did we set the new recipe data & Recipe Hash String on the Data Stick?
*/
public static boolean setAssemblyLineRecipeOnDataStick(ItemStack aDataStick, GT_Recipe_AssemblyLine aNewRecipe) {
- if (isItemDataStick(aDataStick)) {
+ return setAssemblyLineRecipeOnDataStick(aDataStick, aNewRecipe, true);
+ }
+
+ public static boolean setAssemblyLineRecipeOnDataStick(ItemStack aDataStick, GT_Recipe_AssemblyLine aNewRecipe,
+ boolean setUpdateTime) {
+ if (isItemDataStick(aDataStick) && aNewRecipe.mOutput != null) {
String s = aNewRecipe.mOutput.getDisplayName();
if (FMLCommonHandler.instance()
.getEffectiveSide()
@@ -419,29 +424,8 @@ public class GT_AssemblyLineUtils {
tNBT.setTag("output", aNewRecipe.mOutput.writeToNBT(new NBTTagCompound()));
tNBT.setInteger("time", aNewRecipe.mDuration);
tNBT.setInteger("eu", aNewRecipe.mEUt);
- for (int i = 0; i < aNewRecipe.mInputs.length; i++) {
- tNBT.setTag("" + i, aNewRecipe.mInputs[i].writeToNBT(new NBTTagCompound()));
- }
- for (int i = 0; i < aNewRecipe.mOreDictAlt.length; i++) {
- if (aNewRecipe.mOreDictAlt[i] != null && aNewRecipe.mOreDictAlt[i].length > 0) {
- tNBT.setInteger("a" + i, aNewRecipe.mOreDictAlt[i].length);
- for (int j = 0; j < aNewRecipe.mOreDictAlt[i].length; j++) {
- tNBT.setTag("a" + i + ":" + j, aNewRecipe.mOreDictAlt[i][j].writeToNBT(new NBTTagCompound()));
- }
- }
- }
- for (int i = 0; i < aNewRecipe.mFluidInputs.length; i++) {
- tNBT.setTag("f" + i, aNewRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound()));
- }
tNBT.setString("author", author);
NBTTagList tNBTList = new NBTTagList();
- s = aNewRecipe.mOutput.getDisplayName();
- if (FMLCommonHandler.instance()
- .getEffectiveSide()
- .isServer()) {
- s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mOutput.getDisplayName());
- if (s == null) s = aNewRecipe.mOutput.getDisplayName();
- }
tNBTList.appendTag(
new NBTTagString(
"Construction plan for " + aNewRecipe.mOutput.stackSize
@@ -452,11 +436,17 @@ public class GT_AssemblyLineUtils {
+ " Production time: "
+ (aNewRecipe.mDuration / 20)));
for (int i = 0; i < aNewRecipe.mInputs.length; i++) {
- if (aNewRecipe.mOreDictAlt[i] != null) {
+ boolean hasSetOreDictAlt = false;
+
+ if (aNewRecipe.mOreDictAlt[i] != null && aNewRecipe.mOreDictAlt[i].length > 0) {
+ tNBT.setInteger("a" + i, aNewRecipe.mOreDictAlt[i].length);
int count = 0;
StringBuilder tBuilder = new StringBuilder("Input Bus " + (i + 1) + ": ");
- for (ItemStack tStack : aNewRecipe.mOreDictAlt[i]) {
+ for (int j = 0; j < aNewRecipe.mOreDictAlt[i].length; j++) {
+ ItemStack tStack = aNewRecipe.mOreDictAlt[i][j];
if (tStack != null) {
+ tNBT.setTag("a" + i + ":" + j, tStack.writeToNBT(new NBTTagCompound()));
+
s = tStack.getDisplayName();
if (FMLCommonHandler.instance()
.getEffectiveSide()
@@ -472,21 +462,33 @@ public class GT_AssemblyLineUtils {
count++;
}
}
- if (count > 0) tNBTList.appendTag(new NBTTagString(tBuilder.toString()));
- } else if (aNewRecipe.mInputs[i] != null) {
- s = aNewRecipe.mInputs[i].getDisplayName();
- if (FMLCommonHandler.instance()
- .getEffectiveSide()
- .isServer()) {
- s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mInputs[i].getDisplayName());
- if (s == null) s = aNewRecipe.mInputs[i].getDisplayName();
+ if (count > 0) {
+ tNBTList.appendTag(new NBTTagString(tBuilder.toString()));
+ hasSetOreDictAlt = true;
+ }
+ }
+
+ if (aNewRecipe.mInputs[i] != null) {
+ tNBT.setTag("" + i, aNewRecipe.mInputs[i].writeToNBT(new NBTTagCompound()));
+
+ if (!hasSetOreDictAlt) {
+ s = aNewRecipe.mInputs[i].getDisplayName();
+ if (FMLCommonHandler.instance()
+ .getEffectiveSide()
+ .isServer()) {
+ s = GT_Assemblyline_Server.lServerNames.get(aNewRecipe.mInputs[i].getDisplayName());
+ if (s == null) s = aNewRecipe.mInputs[i].getDisplayName();
+ }
+ tNBTList.appendTag(
+ new NBTTagString(
+ "Input Bus " + (i + 1) + ": " + aNewRecipe.mInputs[i].stackSize + " " + s));
}
- tNBTList.appendTag(
- new NBTTagString("Input Bus " + (i + 1) + ": " + aNewRecipe.mInputs[i].stackSize + " " + s));
}
}
for (int i = 0; i < aNewRecipe.mFluidInputs.length; i++) {
if (aNewRecipe.mFluidInputs[i] != null) {
+ tNBT.setTag("f" + i, aNewRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound()));
+
s = aNewRecipe.mFluidInputs[i].getLocalizedName();
if (FMLCommonHandler.instance()
.getEffectiveSide()
@@ -500,7 +502,7 @@ public class GT_AssemblyLineUtils {
}
}
tNBT.setTag("pages", tNBTList);
- tNBT.setLong("lastUpdate", System.currentTimeMillis());
+ if (setUpdateTime) tNBT.setLong("lastUpdate", System.currentTimeMillis());
aDataStick.setTagCompound(tNBT);
// Set recipe hash
setRecipeHashOnDataStick(aDataStick, aHash);