aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2022-07-16 06:57:41 +0900
committerGitHub <noreply@github.com>2022-07-15 22:57:41 +0100
commit68bddf6abb4587ce5934c50271cd9e751b43555a (patch)
tree3a0917265a574285b38120c310cc58f449f20628 /src/main/java/gregtech/api/util
parentdbd0e98223f34787e557b7d4357d3480955db4d9 (diff)
downloadGT5-Unofficial-68bddf6abb4587ce5934c50271cd9e751b43555a.tar.gz
GT5-Unofficial-68bddf6abb4587ce5934c50271cd9e751b43555a.tar.bz2
GT5-Unofficial-68bddf6abb4587ce5934c50271cd9e751b43555a.zip
Add recipe owner display (#1135)
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index accf5fe09b..5a077b4171 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -2,6 +2,8 @@ package gregtech.api.util;
import codechicken.nei.PositionedStack;
import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.ModContainer;
+import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.*;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -27,6 +29,7 @@ import net.minecraftforge.fluids.IFluidContainerItem;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
import static gregtech.api.enums.GT_Values.*;
@@ -82,6 +85,14 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
* Used for describing recipes that do not fit the default recipe pattern (for example Large Boiler Fuels)
*/
private String[] neiDesc = null;
+ /**
+ * Stores which mod added this recipe
+ */
+ public ModContainer owner = null;
+ /**
+ * Stores stack traces where this recipe was added
+ */
+ public List<StackTraceElement> stackTraces = null;
private GT_Recipe(GT_Recipe aRecipe) {
mInputs = GT_Utility.copyStackArray((Object[]) aRecipe.mInputs);
@@ -98,6 +109,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
mFakeRecipe = aRecipe.mFakeRecipe;
mEnabled = aRecipe.mEnabled;
mHidden = aRecipe.mHidden;
+ reloadOwner();
}
public GT_Recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
@@ -194,6 +206,7 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
mSpecialValue = aSpecialValue;
mEUt = aEUt;
// checkCellBalance();
+ reloadOwner();
}
public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, int aFuelValue, int aType) {
@@ -556,6 +569,23 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
return null;
}
+ public void reloadOwner() {
+ this.owner = 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<>();
+ for (StackTraceElement stackTrace : Thread.currentThread().getStackTrace()) {
+ if (!excludedClasses.stream().anyMatch(c -> stackTrace.getClassName().contains(c))) {
+ this.stackTraces.add(stackTrace);
+ }
+ }
+ }
+ }
+
public static class GT_Recipe_AssemblyLine{
public static final ArrayList<GT_Recipe_AssemblyLine> sAssemblylineRecipes = new ArrayList<GT_Recipe_AssemblyLine>();