Skip to content

Commit

Permalink
Include locked recipe information in WAILA tooltip (#3855)
Browse files Browse the repository at this point in the history
Co-authored-by: Maya <[email protected]>
  • Loading branch information
mak8427 and serenibyss authored Feb 3, 2025
1 parent 92b457f commit 59c3ed2
Show file tree
Hide file tree
Showing 2 changed files with 337 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static gregtech.api.enums.GTValues.V;
import static gregtech.api.enums.GTValues.VN;
import static gregtech.api.recipe.check.SingleRecipeCheck.getDisplayString;
import static gregtech.api.util.GTUtility.filterValidMTEs;
import static gregtech.api.util.GTUtility.formatNumbers;
import static gregtech.api.util.GTUtility.min;
Expand Down Expand Up @@ -2077,6 +2078,19 @@ public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDat
int tAverageTime = tag.getInteger("averageNS");
currentTip.add("Average CPU load of ~" + formatNumbers(tAverageTime) + " ns");
}
// Always show locked recipe information if the machine is locked to a recipe
if (tag.getBoolean("isLockedToRecipe")) {
String lockedRecipe = tag.getString("lockedRecipeName");
if (!lockedRecipe.isEmpty()) {
// Split the string on "\n" and add each line separately.
String[] lines = lockedRecipe.split("\n");
currentTip.add("Locked Recipe:");
for (String line : lines) {
currentTip.add(line);
}
}
}

super.getWailaBody(itemStack, currentTip, accessor, config);
}

Expand All @@ -2095,6 +2109,11 @@ public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompou
tag.setInteger("progress", mProgresstime);
tag.setInteger("maxProgress", mMaxProgresstime);
tag.setBoolean("incompleteStructure", (getErrorDisplayID() & 64) != 0);
tag.setBoolean("isLockedToRecipe", isRecipeLockingEnabled());
SingleRecipeCheck lockedRecipe = getSingleRecipeCheck();
tag.setString(
"lockedRecipeName",
lockedRecipe != null ? getDisplayString(lockedRecipe.getRecipe(), false, true, false, true) : "");

if (mOutputItems != null) {
int index = 0;
Expand Down
Loading

0 comments on commit 59c3ed2

Please sign in to comment.