aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/main/java/gregtech/api/util/GT_Recipe.java30
-rw-r--r--src/main/java/gregtech/common/GT_Proxy.java16
-rw-r--r--src/main/java/gregtech/loaders/preload/GT_PreLoad.java4
-rw-r--r--src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java26
-rw-r--r--src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java33
-rw-r--r--src/main/resources/assets/gregtech/lang/en_US.lang6
6 files changed, 103 insertions, 12 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>();
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java
index 915fe650a7..71063949fe 100644
--- a/src/main/java/gregtech/common/GT_Proxy.java
+++ b/src/main/java/gregtech/common/GT_Proxy.java
@@ -153,7 +153,6 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
public boolean mIncreaseDungeonLoot = true;
public boolean mAxeWhenAdventure = true;
public boolean mSurvivalIntoAdventure = false;
- public boolean mNEIRecipeSecondMode = true;
public boolean mNerfedWoodPlank = true;
public boolean mNerfedVanillaTools = true;
public boolean mHardRock = false;
@@ -292,6 +291,21 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
public int mTooltipShiftVerbosity = 3;
/**
+ * Whether to show seconds or ticks on NEI
+ */
+ public boolean mNEIRecipeSecondMode = true;
+
+ /**
+ * This enables "Recipe by" display on NEI
+ */
+ public boolean mNEIRecipeOwner = false;
+
+ /**
+ * This enables showing stack traces where the recipe was added. Reboot needed
+ */
+ public boolean mNEIRecipeOwnerStackTrace = false;
+
+ /**
* What is the order of the circuits when they are selected?
*/
public Map<String, Integer> mCircuitsOrder = new HashMap<>();
diff --git a/src/main/java/gregtech/loaders/preload/GT_PreLoad.java b/src/main/java/gregtech/loaders/preload/GT_PreLoad.java
index d6b490fc9b..265b525119 100644
--- a/src/main/java/gregtech/loaders/preload/GT_PreLoad.java
+++ b/src/main/java/gregtech/loaders/preload/GT_PreLoad.java
@@ -535,7 +535,9 @@ public class GT_PreLoad {
GT_Mod.gregtechproxy.mCoverTabsFlipped = GregTech_API.sClientDataFile.get("interface", "FlipCoverTabs", false);
GT_Mod.gregtechproxy.mTooltipVerbosity = GregTech_API.sClientDataFile.get("interface", "TooltipVerbosity", 2);
GT_Mod.gregtechproxy.mTooltipShiftVerbosity = GregTech_API.sClientDataFile.get("interface", "TooltipShiftVerbosity", 3);
- GT_Mod.gregtechproxy.mNEIRecipeSecondMode = GregTech_API.sClientDataFile.get("features", "NEI_recipe_second_mode", true);
+ GT_Mod.gregtechproxy.mNEIRecipeSecondMode = GregTech_API.sClientDataFile.get("nei", "RecipeSecondMode", true);
+ GT_Mod.gregtechproxy.mNEIRecipeOwner = GregTech_API.sClientDataFile.get("nei", "RecipeOwner", false);
+ GT_Mod.gregtechproxy.mNEIRecipeOwnerStackTrace = GregTech_API.sClientDataFile.get("nei", "RecipeOwnerStackTrace", false);
final String[] Circuits = GregTech_API.sClientDataFile.get("interface", "CircuitsOrder" );
GT_Mod.gregtechproxy.mCircuitsOrder.clear();
diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java
index a550993b07..d98aa99ae7 100644
--- a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java
+++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java
@@ -24,6 +24,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
@@ -236,9 +237,10 @@ public class GT_NEI_AssLineHandler extends RecipeMapHandler {
@Override
public void drawExtras(int aRecipeIndex) {
- int tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt;
- int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration;
- String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc();
+ GT_Recipe recipe = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe;
+ int tEUt = recipe.mEUt;
+ int tDuration = recipe.mDuration;
+ String[] recipeDesc = recipe.getNeiDesc();
if (recipeDesc == null) {
if (tEUt != 0) {
drawText(10, 73, trans("152","Total: ") + GT_Utility.formatNumbers((long) tDuration * tEUt) + " EU", 0xFF000000);
@@ -261,14 +263,32 @@ public class GT_NEI_AssLineHandler extends RecipeMapHandler {
drawText(10, 113, trans("158","Time: ") + GT_Utility.formatNumbers(0.05d * tDuration) + trans("161"," secs"), 0xFF000000);
}
int tSpecial = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue;
+ boolean specialDrew = false;
if (tSpecial == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) {
drawText(10, 123, trans("159","Needs Low Gravity"), 0xFF000000);
+ specialDrew = true;
} else if (tSpecial == -200 && GT_Mod.gregtechproxy.mEnableCleanroom) {
drawText(10, 123, trans("160","Needs Cleanroom"), 0xFF000000);
+ specialDrew = true;
} else if (tSpecial == -201) {
drawText(10, 123, trans("206","Scan for Assembly Line"), 0xFF000000);
+ specialDrew = true;
} else if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) {
drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + GT_Utility.formatNumbers(tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, 0xFF000000);
+ specialDrew = true;
+ }
+ int y = 123 + (specialDrew ? 10 : 0);
+ if (GT_Mod.gregtechproxy.mNEIRecipeOwner && recipe.owner != null) {
+ drawText(10, y, EnumChatFormatting.ITALIC + GT_Utility.trans("225", "Recipe by: ") + recipe.owner.getName(), 0xFF000000);
+ y += 10;
+ }
+ if (GT_Mod.gregtechproxy.mNEIRecipeOwnerStackTrace && recipe.stackTraces != null) {
+ drawText(10, y, "stackTrace:", 0xFF000000);
+ y += 10;
+ for (StackTraceElement stackTrace : recipe.stackTraces) {
+ drawText(10, y, stackTrace.toString(), 0xFF000000);
+ y += 10;
+ }
}
} else {
int i = 0;
diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
index 49382bd859..554c724889 100644
--- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
+++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
@@ -34,6 +34,7 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.fluids.FluidStack;
import org.apache.commons.lang3.Range;
import org.lwjgl.opengl.GL11;
@@ -395,9 +396,25 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
}
}
if (this.mRecipeMap.mNEIName.equals("gt.recipe.fusionreactor") || this.mRecipeMap.mNEIName.equals("gt.recipe.complexfusionreactor")) {
- drawOptionalLine(lineCounter, getSpecialInfo(recipe.mSpecialValue) + " " + formatSpecialValueFusion(recipe.mSpecialValue, recipe.mEUt));
+ if (drawOptionalLine(lineCounter, getSpecialInfo(recipe.mSpecialValue) + " " + formatSpecialValueFusion(recipe.mSpecialValue, recipe.mEUt))) {
+ lineCounter++;
+ }
+ }
+ if (drawOptionalLine(lineCounter, getSpecialInfo(recipe.mSpecialValue))) {
+ lineCounter++;
+ }
+ if (GT_Mod.gregtechproxy.mNEIRecipeOwner && recipe.owner != null) {
+ drawLine(lineCounter, EnumChatFormatting.ITALIC + GT_Utility.trans("225", "Recipe by: ") + recipe.owner.getName());
+ lineCounter++;
+ }
+ if (GT_Mod.gregtechproxy.mNEIRecipeOwnerStackTrace && recipe.stackTraces != null) {
+ drawLine(lineCounter, "stackTrace:");
+ lineCounter++;
+ for (StackTraceElement stackTrace : recipe.stackTraces) {
+ drawLine(lineCounter, stackTrace.toString());
+ lineCounter++;
+ }
}
- drawOptionalLine(lineCounter, getSpecialInfo(recipe.mSpecialValue));
}
private void drawOverrideDescription(String[] recipeDesc) {
@@ -460,16 +477,20 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
return "(MK " + tier + ")";
}
- private void drawOptionalLine(int lineNumber, String line, String prefix) {
- if (!"unspecified".equals(line)) {
+ private boolean drawOptionalLine(int lineNumber, String line, String prefix) {
+ if (!(line == null || "unspecified".equals(line))) {
drawLine(lineNumber, prefix + line);
+ return true;
}
+ return false;
}
- private void drawOptionalLine(int lineNumber, String line) {
- if (!"unspecified".equals(line)) {
+ private boolean drawOptionalLine(int lineNumber, String line) {
+ if (!(line == null || "unspecified".equals(line))) {
drawLine(lineNumber, line);
+ return true;
}
+ return false;
}
private void drawLine(int lineNumber, String line) {
diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang
index 00f43407c3..ad5752ea1a 100644
--- a/src/main/resources/assets/gregtech/lang/en_US.lang
+++ b/src/main/resources/assets/gregtech/lang/en_US.lang
@@ -204,7 +204,11 @@ GT5U.config.render.RenderFlippedMachinesFlipped=Render flipped machines with fli
GT5U.config.render.RenderIndicatorsOnHatch=Render indicator on hatch
GT5U.config.render.RenderPollutionFog=Render pollution fog
GT5U.config.render.TileAmbientOcclusion=Enable Ambient Occlusion
-GT5U.config.feature.NEI_recipe_second_mode=Show NEI recipes using seconds (as opposed to ticks).
+GT5U.config.nei=NEI
+GT5U.config.nei.RecipeSecondMode=Show recipes using seconds (as opposed to ticks)
+GT5U.config.nei.RecipeOwner=Show which mod added the recipe
+GT5U.config.nei.RecipeOwnerStackTrace=[debug] Show stack traces of recipe addition
+GT5U.config.nei.RecipeOwnerStackTrace.tooltip=[requires reboot]
// Cover tabs
GT5U.interface.coverTabs.down=Bottom