aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/nei/formatter
diff options
context:
space:
mode:
authormiozune <miozune@gmail.com>2023-12-04 05:34:27 +0900
committerGitHub <noreply@github.com>2023-12-03 21:34:27 +0100
commitf74c7cc297d1d19d38a19683cd277ad9ce605d3a (patch)
treeb2a5d66ec5a959099240fb1db239ffc0f9531839 /src/main/java/gregtech/nei/formatter
parentb08cde7de4ec93cba05fb070991ad1dffb800ce1 (diff)
downloadGT5-Unofficial-f74c7cc297d1d19d38a19683cd277ad9ce605d3a.tar.gz
GT5-Unofficial-f74c7cc297d1d19d38a19683cd277ad9ce605d3a.tar.bz2
GT5-Unofficial-f74c7cc297d1d19d38a19683cd277ad9ce605d3a.zip
Refactor RecipeMap (#2345)
* Remove deprecated and unused things * Move recipemap subclasses * Move GT_Recipe_Map to outside and rename to RecipeMap * Move recipemap instances to separated class & remove prepending s * Remove useless GT_Recipe constructors * Always use ModularUI * Rename IGT_RecipeMap -> IRecipeMap * Add RecipeMapBuilder * Remove more deprecated and unused things * Fix RecipeMap type parameters * Use multimap for recipe index * Fix bending recipe error in dev env * Remove mUniqueIdentifier * Update AE2FC * Less edgy texture for NEI recipe background * Add replicator fluid output slot for NEI and machine GUI * Fix fluid fuels not having fuel value in large boilers * Remove GT_RectHandler and NEI_TransferRectHost * Remove RecipeMapHandler * Move NEI energy description from RecipeMapFrontend to Power * Refactor the way to filter fusion recipes * Check restriction for some properties * Remove showVoltageAmperage * Make Power accept GT_Recipe * Fix NPE * Move NEI duration description to Power from Frontend * Directly implement IRecipeProcessingAwareHatch for GT_MetaTileEntity_Hatch_InputBus_ME * Make Power integrated with GT_OverclockCalculator * Rename Power -> OverclockDescriber * Don't modify recipe find logic until postload finishes * Reformat reserved MTE ids * Fix check for too few inputs on recipe addition * Move replicator logic to backend * Stop un-hiding assline recipes * Allow setting custom recipe comparator & implement for fusion * Update AE2FC * Rename getRecipeList and getRecipes -> getRecipeMap * Automatically register recipe catalysts * Cleanup the way to detect recipe collision * Make use of BasicUIProperties for basic machines * Make use of BasicUIProperties for UIHelper * Rename specialHandler -> recipeTransformer * Add way to automatically register handler info * Add recipe category * Add some APIs for addons * Rename blastRecipes -> blastFurnaceRecipes * Remove GT_MetaTileEntity_BasicMachine_GT_Recipe#mSharedTank and #mRequiresFluidForFiltering * Don't require setting duration and EU/t for fuel recipes * Don't require setting EU/t for primitive blast furnace recipes * Revert change to addMultiblockChemicalRecipe * Fix large boiler general desc recipe not being added * Hide duration and EU/t from large boiler * Cleanup recipe stacktrace draw * Extend metadata usage of recipe builder to recipe itself * Implement metadata handling & NEI comparator for PCB factory * Some rename around NEIRecipeInfo * Some toString implementations * Add more APIs for addons & some rename * Infer handler icon from recipe catalyst if one is not set * Also shrink recipe title when OC is not used * Remove rare earth centrifuge recipe * Use metadata for replicator backend * Adjust geothermal generator output slot * Allow having multiple transferrects * Store recipemap reference in backend * Rename vacuumRecipes -> vacuumFreezerRecipes * Add config to tweak visibility of recipe categories * Remove mHideRecyclingRecipes in favor of recipe category config * Fix typo fluidSolidfierRecipes -> fluidSolidifierRecipes * Refactor findRecipe and ProcessingLogic to use Stream * Fix BBF handler icon & remove bronze blast furnace * Add fluent API for findRecipe * Add way to stop adding progressbar * Change arg order for special texture * Avoid overwriting interesting failure with NO_RECIPE * Some changes for FuelBackend * Set space project icon * Remove localization from TT * Remove CNC recipe adder * Move recipe extractor from AE2FC * Minor internal change for ProcessingLogic#applyRecipe * More javadoc on #getAvailableRecipeMaps * Better implementation of #ofSupplier * Move replicator exponent config to GT_Proxy * Remove RC & IC2 macerator handling * Rename StreamUtil -> GT_StreamUtil * Refactor code around RecipeMetadataStorage * Revise #compileRecipe javadoc * Switch extreme diesel recipe loader to downstream recipe map * Optimize #reMap * Rename reload -> reloadNEICache * Minor tweak for drawEnergyInfo * a bit more doc * Adjust recipe catalysts * Add toString implementation for GT_Fluid for debug * Minor revision for OilCrackerBackend * Index replicator recipes by material --------- Co-authored-by: Glease <4586901+Glease@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/nei/formatter')
-rw-r--r--src/main/java/gregtech/nei/formatter/DefaultSpecialValueFormatter.java36
-rw-r--r--src/main/java/gregtech/nei/formatter/FuelSpecialValueFormatter.java27
-rw-r--r--src/main/java/gregtech/nei/formatter/FusionSpecialValueFormatter.java59
-rw-r--r--src/main/java/gregtech/nei/formatter/HeatingCoilSpecialValueFormatter.java30
-rw-r--r--src/main/java/gregtech/nei/formatter/INEISpecialInfoFormatter.java24
-rw-r--r--src/main/java/gregtech/nei/formatter/SimpleSpecialValueFormatter.java49
6 files changed, 225 insertions, 0 deletions
diff --git a/src/main/java/gregtech/nei/formatter/DefaultSpecialValueFormatter.java b/src/main/java/gregtech/nei/formatter/DefaultSpecialValueFormatter.java
new file mode 100644
index 0000000000..1c4d486319
--- /dev/null
+++ b/src/main/java/gregtech/nei/formatter/DefaultSpecialValueFormatter.java
@@ -0,0 +1,36 @@
+package gregtech.nei.formatter;
+
+import static gregtech.api.util.GT_Utility.trans;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import gregtech.GT_Mod;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public class DefaultSpecialValueFormatter implements INEISpecialInfoFormatter {
+
+ public static DefaultSpecialValueFormatter INSTANCE = new DefaultSpecialValueFormatter();
+
+ @Override
+ public List<String> format(RecipeDisplayInfo recipeInfo) {
+ int specialValue = recipeInfo.recipe.mSpecialValue;
+ if (specialValue == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) {
+ return Collections.singletonList(trans("159", "Needs Low Gravity"));
+ } else if (specialValue == -200 && GT_Mod.gregtechproxy.mEnableCleanroom) {
+ return Collections.singletonList(trans("160", "Needs Cleanroom"));
+ } else if (specialValue == -201) {
+ return Collections.singletonList(trans("206", "Scan for Assembly Line"));
+ } else if (specialValue == -300 && GT_Mod.gregtechproxy.mEnableCleanroom) {
+ return Collections.singletonList(trans("160.1", "Needs Cleanroom & LowGrav"));
+ } else if (specialValue == -400) {
+ return Collections.singletonList(trans("216", "Deprecated Recipe"));
+ }
+ return Collections.emptyList();
+ }
+}
diff --git a/src/main/java/gregtech/nei/formatter/FuelSpecialValueFormatter.java b/src/main/java/gregtech/nei/formatter/FuelSpecialValueFormatter.java
new file mode 100644
index 0000000000..dcfe2617dd
--- /dev/null
+++ b/src/main/java/gregtech/nei/formatter/FuelSpecialValueFormatter.java
@@ -0,0 +1,27 @@
+package gregtech.nei.formatter;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import net.minecraft.util.StatCollector;
+
+import gregtech.api.util.GT_Utility;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public class FuelSpecialValueFormatter implements INEISpecialInfoFormatter {
+
+ public static FuelSpecialValueFormatter INSTANCE = new FuelSpecialValueFormatter();
+
+ @Override
+ public List<String> format(RecipeDisplayInfo recipeInfo) {
+ return Collections.singletonList(
+ StatCollector.translateToLocalFormatted(
+ "GT5U.nei.fuel",
+ GT_Utility.formatNumbers(recipeInfo.recipe.mSpecialValue * 1000L)));
+ }
+}
diff --git a/src/main/java/gregtech/nei/formatter/FusionSpecialValueFormatter.java b/src/main/java/gregtech/nei/formatter/FusionSpecialValueFormatter.java
new file mode 100644
index 0000000000..77cd41b343
--- /dev/null
+++ b/src/main/java/gregtech/nei/formatter/FusionSpecialValueFormatter.java
@@ -0,0 +1,59 @@
+package gregtech.nei.formatter;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import net.minecraft.util.StatCollector;
+
+import gregtech.api.enums.GT_Values;
+import gregtech.api.util.GT_Utility;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public class FusionSpecialValueFormatter implements INEISpecialInfoFormatter {
+
+ public static final FusionSpecialValueFormatter INSTANCE = new FusionSpecialValueFormatter();
+ private static final long M = 1000000;
+
+ @Override
+ public List<String> format(RecipeDisplayInfo recipeInfo) {
+ int euToStart = recipeInfo.recipe.mSpecialValue;
+ int voltage = recipeInfo.recipe.mEUt;
+ int tier = getFusionTier(euToStart, voltage);
+
+ return Collections.singletonList(
+ StatCollector.translateToLocalFormatted("GT5U.nei.start_eu", GT_Utility.formatNumbers(euToStart), tier));
+ }
+
+ public static int getFusionTier(long startupPower, long voltage) {
+ int tier;
+ if (startupPower <= 10 * M * 16) {
+ tier = 1;
+ } else if (startupPower <= 20 * M * 16) {
+ tier = 2;
+ } else if (startupPower <= 40 * M * 16) {
+ tier = 3;
+ } else if (startupPower <= 320 * M * 16) {
+ tier = 4;
+ } else {
+ tier = 5;
+ }
+
+ if (voltage <= GT_Values.V[6]) {
+ // no-op
+ } else if (voltage <= GT_Values.V[7]) {
+ tier = Math.max(tier, 2);
+ } else if (voltage <= GT_Values.V[8]) {
+ tier = Math.max(tier, 3);
+ } else if (voltage <= GT_Values.V[9]) {
+ tier = Math.max(tier, 4);
+ } else {
+ tier = 5;
+ }
+ return tier;
+ }
+}
diff --git a/src/main/java/gregtech/nei/formatter/HeatingCoilSpecialValueFormatter.java b/src/main/java/gregtech/nei/formatter/HeatingCoilSpecialValueFormatter.java
new file mode 100644
index 0000000000..f5c17a1163
--- /dev/null
+++ b/src/main/java/gregtech/nei/formatter/HeatingCoilSpecialValueFormatter.java
@@ -0,0 +1,30 @@
+package gregtech.nei.formatter;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import net.minecraft.util.StatCollector;
+
+import gregtech.api.enums.HeatingCoilLevel;
+import gregtech.api.util.GT_Utility;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public class HeatingCoilSpecialValueFormatter implements INEISpecialInfoFormatter {
+
+ public static final HeatingCoilSpecialValueFormatter INSTANCE = new HeatingCoilSpecialValueFormatter();
+
+ @Override
+ public List<String> format(RecipeDisplayInfo recipeInfo) {
+ int heat = recipeInfo.recipe.mSpecialValue;
+ return Collections.singletonList(
+ StatCollector.translateToLocalFormatted(
+ "GT5U.nei.heat_capacity",
+ GT_Utility.formatNumbers(heat),
+ HeatingCoilLevel.getDisplayNameFromHeat(heat, false)));
+ }
+}
diff --git a/src/main/java/gregtech/nei/formatter/INEISpecialInfoFormatter.java b/src/main/java/gregtech/nei/formatter/INEISpecialInfoFormatter.java
new file mode 100644
index 0000000000..21228240d4
--- /dev/null
+++ b/src/main/java/gregtech/nei/formatter/INEISpecialInfoFormatter.java
@@ -0,0 +1,24 @@
+package gregtech.nei.formatter;
+
+import java.util.List;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+/**
+ * Getter for description for {@link gregtech.api.util.GT_Recipe#mSpecialValue} etc. that will be drawn on NEI.
+ */
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+@FunctionalInterface
+public interface INEISpecialInfoFormatter {
+
+ /**
+ * @param recipeInfo Recipe info to draw description. You can retrieve special value with
+ * {@code recipeInfo.recipe.mSpecialValue}.
+ * @return List of strings containing info for special value etc.
+ */
+ List<String> format(RecipeDisplayInfo recipeInfo);
+}
diff --git a/src/main/java/gregtech/nei/formatter/SimpleSpecialValueFormatter.java b/src/main/java/gregtech/nei/formatter/SimpleSpecialValueFormatter.java
new file mode 100644
index 0000000000..8f2098c0a9
--- /dev/null
+++ b/src/main/java/gregtech/nei/formatter/SimpleSpecialValueFormatter.java
@@ -0,0 +1,49 @@
+package gregtech.nei.formatter;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import net.minecraft.util.StatCollector;
+
+import gregtech.api.util.GT_Utility;
+import gregtech.api.util.MethodsReturnNonnullByDefault;
+import gregtech.nei.RecipeDisplayInfo;
+
+/**
+ * Simple formatter for recipe's special value.
+ */
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+public class SimpleSpecialValueFormatter implements INEISpecialInfoFormatter {
+
+ @Nullable
+ private final String translationKey;
+ private final int multiplier;
+
+ /**
+ * @param translationKey Localization key to format
+ * @param multiplier Number to multiply to special value for display
+ */
+ public SimpleSpecialValueFormatter(@Nullable String translationKey, int multiplier) {
+ this.translationKey = translationKey;
+ this.multiplier = multiplier;
+ }
+
+ /**
+ * @param translationKey Localization key to format
+ */
+ public SimpleSpecialValueFormatter(@Nullable String translationKey) {
+ this(translationKey, 1);
+ }
+
+ @Override
+ public List<String> format(RecipeDisplayInfo recipeInfo) {
+ return Collections.singletonList(
+ StatCollector.translateToLocalFormatted(
+ translationKey,
+ GT_Utility.formatNumbers((long) recipeInfo.recipe.mSpecialValue * multiplier)));
+ }
+}