aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/nei
diff options
context:
space:
mode:
authorConnor-Colenso <52056774+Connor-Colenso@users.noreply.github.com>2022-06-10 10:15:08 +0100
committerGitHub <noreply@github.com>2022-06-10 11:15:08 +0200
commita894c865281c0d8875600dbe6125231421424ad5 (patch)
tree7fbe19c93dbfcf12c84fd35ee5f30fb10b26092b /src/main/java/gregtech/nei
parent6ced738344fbf1b2bfccc2b753cf52c4d720e408 (diff)
downloadGT5-Unofficial-a894c865281c0d8875600dbe6125231421424ad5.tar.gz
GT5-Unofficial-a894c865281c0d8875600dbe6125231421424ad5.tar.bz2
GT5-Unofficial-a894c865281c0d8875600dbe6125231421424ad5.zip
Adjust NEI recipe pages (#1077)
* Add config support for changes. * Change ticks config to default OFF. * Usage -> Voltage for some cases. Also fix language translations. * Remove comment. * Remove redundant null check. * Bring back null checks (crashes). Move config to client. Adjust priorities so that if OC is detected it will display usage instead of voltage. * Remove null checks again (but for realsies this time). * Add language localisation. * Update language localisation. Co-authored-by: GTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/nei')
-rw-r--r--src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java77
1 files changed, 46 insertions, 31 deletions
diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
index b83c59eb20..39b0c9e3bb 100644
--- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
+++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java
@@ -14,17 +14,14 @@ import codechicken.nei.recipe.IUsageHandler;
import codechicken.nei.recipe.RecipeCatalysts;
import codechicken.nei.recipe.TemplateRecipeHandler;
import gregtech.GT_Mod;
+import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.gui.GT_GUIContainer;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtech.api.objects.ItemData;
-import gregtech.api.util.GT_LanguageManager;
-import gregtech.api.util.GT_Log;
-import gregtech.api.util.GT_OreDictUnificator;
-import gregtech.api.util.GT_Recipe;
-import gregtech.api.util.GT_Utility;
+import gregtech.api.util.*;
import gregtech.common.power.EUPower;
import gregtech.common.power.Power;
import gregtech.common.power.UnspecifiedEUPower;
@@ -64,7 +61,7 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
private NEIHandlerAbsoluteTooltip mRecipeNameTooltip;
private static final int RECIPE_NAME_WIDTH = 140;
- /**
+ /**
* Static version of {@link TemplateRecipeHandler#cycleticks}.
* Can be referenced from cached recipes.
*/
@@ -96,10 +93,10 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
List<CachedDefaultRecipe> cache;
if (cacheHolder.getCachedRecipesVersion() != GT_Mod.gregtechproxy.getReloadCount() || (cache = cacheHolder.getCachedRecipes()) == null) {
cache = mRecipeMap.mRecipeList.stream() // do not use parallel stream. This is already parallelized by NEI
- .filter(r -> !r.mHidden)
- .sorted()
- .map(CachedDefaultRecipe::new)
- .collect(Collectors.toList());
+ .filter(r -> !r.mHidden)
+ .sorted()
+ .map(CachedDefaultRecipe::new)
+ .collect(Collectors.toList());
// while the NEI parallelize handlers, for each individual handler it still uses sequential execution model
// so we do not need any synchronization here
// even if it does break, at worst case it's just recreating the cache multiple times, which should be fine
@@ -314,7 +311,7 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
for (PositionedStack tStack : tRecipe.mInputs) {
if (aStack == tStack.item) {
if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) ||
- (tStack.item.stackSize != 0)) {
+ (tStack.item.stackSize != 0)) {
break;
}
currenttip.add(GT_Utility.trans("151", "Does not get consumed in the process"));
@@ -356,23 +353,41 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
mPower = getPowerFromRecipeMap();
}
mPower.computePowerUsageAndDuration(recipe.mEUt, recipe.mDuration);
+
+ int lineCounter = 0;
if (mPower.getEuPerTick() > 0) {
- drawPowerUsageLines();
+ drawLine(lineCounter, GT_Utility.trans("152", "Total: ") + mPower.getTotalPowerString());
+ lineCounter++;
+
+ if (mPower.getAmperageString().equals("unspecified") || mPower.getPowerUsageString().contains("(OC)")){
+ drawLine(lineCounter, GT_Utility.trans("153", "Usage: ") + mPower.getPowerUsageString());
+ lineCounter++;
+ } else if (mPower.getAmperageString().equals("1")) {
+ drawLine(lineCounter, GT_Utility.trans("154", "Voltage: ") + mPower.getVoltageString());
+ lineCounter++;
+ } else {
+ drawLine(lineCounter, GT_Utility.trans("153", "Usage: ") + mPower.getPowerUsageString());
+ lineCounter++;
+ drawLine(lineCounter, GT_Utility.trans("154", "Voltage: ") + mPower.getVoltageString());
+ lineCounter++;
+ drawLine(lineCounter, GT_Utility.trans("155", "Amperage: ") + mPower.getAmperageString());
+ lineCounter++;
+ }
+
}
if (mPower.getDurationTicks() > 0) {
- drawLine(4, GT_Utility.trans("158", "Time: ") + mPower.getDurationString());
+ if(GT_Mod.gregtechproxy.mNEIRecipeSecondMode) {
+ drawLine(lineCounter, GT_Utility.trans("158", "Time: ") + mPower.getDurationStringSeconds());
+ lineCounter++;
+ } else {
+ drawLine(lineCounter, GT_Utility.trans("158", "Time: ") + mPower.getDurationStringTicks());
+ lineCounter++;
+ }
}
if (this.mRecipeMap.mNEIName.equals("gt.recipe.fusionreactor")) {
- drawOptionalLine(5, getSpecialInfo(recipe.mSpecialValue) + " " + formatSpecialValueFusion(recipe.mSpecialValue, recipe.mEUt));
+ drawOptionalLine(lineCounter, getSpecialInfo(recipe.mSpecialValue) + " " + formatSpecialValueFusion(recipe.mSpecialValue, recipe.mEUt));
}
- drawOptionalLine(5, getSpecialInfo(recipe.mSpecialValue));
- }
-
- private void drawPowerUsageLines() {
- drawLine(0, GT_Utility.trans("152", "Total: ") + mPower.getTotalPowerString());
- drawLine(1, GT_Utility.trans("153", "Usage: ") + mPower.getPowerUsageString());
- drawOptionalLine(2, mPower.getVoltageString(), GT_Utility.trans("154", "Voltage: "));
- drawOptionalLine(3, mPower.getAmperageString(), GT_Utility.trans("155", "Amperage: "));
+ drawOptionalLine(lineCounter, getSpecialInfo(recipe.mSpecialValue));
}
private void drawOverrideDescription(String[] recipeDesc) {
@@ -403,13 +418,13 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
private boolean hasSpecialValueFormat() {
return (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre))
- || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost));
+ || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost));
}
private String formatSpecialValue(int SpecialValue) {
return this.mRecipeMap.mNEISpecialValuePre + GT_Utility.formatNumbers(
- (long) SpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier)
- + this.mRecipeMap.mNEISpecialValuePost;
+ (long) SpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier)
+ + this.mRecipeMap.mNEISpecialValuePost;
}
private String formatSpecialValueFusion(int SpecialValue, int Voltage) {
@@ -436,13 +451,13 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
}
private void drawOptionalLine(int lineNumber, String line, String prefix) {
- if (line != null) {
+ if (!"unspecified".equals(line)) {
drawLine(lineNumber, prefix + line);
}
}
private void drawOptionalLine(int lineNumber, String line) {
- if (line != null) {
+ if (!"unspecified".equals(line)) {
drawLine(lineNumber, line);
}
}
@@ -452,7 +467,7 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
}
public static class GT_RectHandler
- implements IContainerInputHandler, IContainerTooltipHandler {
+ implements IContainerInputHandler, IContainerTooltipHandler {
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
if (canHandle(gui)) {
@@ -471,8 +486,8 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
private Point getMousePos(GuiContainer gui, int mousex, int mousey) {
Point point = new Point(
- mousex - ((GT_GUIContainer) gui).getLeft() - getGuiOffset(gui)[0],
- mousey - ((GT_GUIContainer) gui).getTop() - getGuiOffset(gui)[1]);
+ mousex - ((GT_GUIContainer) gui).getLeft() - getGuiOffset(gui)[0],
+ mousey - ((GT_GUIContainer) gui).getTop() - getGuiOffset(gui)[1]);
return point;
}
@@ -602,7 +617,7 @@ public class GT_NEI_DefaultHandler extends RecipeMapHandler {
}
public class CachedDefaultRecipe
- extends TemplateRecipeHandler.CachedRecipe {
+ extends TemplateRecipeHandler.CachedRecipe {
public final GT_Recipe mRecipe;
public final List<PositionedStack> mOutputs;
public final List<PositionedStack> mInputs;