aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2022-07-18 11:27:19 +0900
committerGitHub <noreply@github.com>2022-07-18 09:27:19 +0700
commitecc3a2a5e49ecf76b6811d8f42daa1ceb79ce590 (patch)
treef4ad90c99cc9aa9e0ff7f7ef4b1857fa99e57fd6 /src/main/java/gregtech/api/util
parentd698da152c3882fd3656954cbaa7ff5c0f47e2ef (diff)
downloadGT5-Unofficial-ecc3a2a5e49ecf76b6811d8f42daa1ceb79ce590.tar.gz
GT5-Unofficial-ecc3a2a5e49ecf76b6811d8f42daa1ceb79ce590.tar.bz2
GT5-Unofficial-ecc3a2a5e49ecf76b6811d8f42daa1ceb79ce590.zip
Allow showing multiple recipe owners (#1136)
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index 5a077b4171..a50c925e61 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -88,11 +88,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
/**
* Stores which mod added this recipe
*/
- public ModContainer owner = null;
+ public List<ModContainer> owners = new ArrayList<>();
/**
* Stores stack traces where this recipe was added
*/
- public List<StackTraceElement> stackTraces = null;
+ public List<List<StackTraceElement>> stackTraces = new ArrayList<>();
private GT_Recipe(GT_Recipe aRecipe) {
mInputs = GT_Utility.copyStackArray((Object[]) aRecipe.mInputs);
@@ -109,6 +109,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
mFakeRecipe = aRecipe.mFakeRecipe;
mEnabled = aRecipe.mEnabled;
mHidden = aRecipe.mHidden;
+ owners = new ArrayList<>(aRecipe.owners);
reloadOwner();
}
@@ -570,19 +571,39 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
}
public void reloadOwner() {
- this.owner = Loader.instance().activeModContainer();
+ setOwner(Loader.instance().activeModContainer());
final List<String> excludedClasses = Arrays.asList(
"java.lang.Thread",
"gregtech.api.util.GT_Recipe",
"gregtech.common.GT_RecipeAdder");
if (GT_Mod.gregtechproxy.mNEIRecipeOwnerStackTrace) {
- this.stackTraces = new ArrayList<>();
+ List<StackTraceElement> toAdd = new ArrayList<>();
for (StackTraceElement stackTrace : Thread.currentThread().getStackTrace()) {
- if (!excludedClasses.stream().anyMatch(c -> stackTrace.getClassName().contains(c))) {
- this.stackTraces.add(stackTrace);
+ if (excludedClasses.stream().noneMatch(c -> stackTrace.getClassName().contains(c))) {
+ toAdd.add(stackTrace);
}
}
+ stackTraces.add(toAdd);
+ }
+ }
+
+ public void setOwner(ModContainer newOwner) {
+ ModContainer oldOwner = owners.size() > 0 ? this.owners.get(owners.size() - 1) : null;
+ if (newOwner != null && newOwner != oldOwner) {
+ owners.add(newOwner);
+ }
+ }
+
+ /**
+ * Use in case {@link Loader#activeModContainer()} isn't helpful
+ */
+ public void setOwner(String modId) {
+ for (ModContainer mod : Loader.instance().getModList()) {
+ if (mod.getModId().equals(modId)) {
+ setOwner(mod);
+ return;
+ }
}
}