From 3b834d6cebae287cd9bbeddd4f157338da6e1ea5 Mon Sep 17 00:00:00 2001 From: Maxim Date: Thu, 16 Feb 2023 10:14:49 +0100 Subject: Fusion NEI support (#1742) * Added optional special value to Power and getter for power into IMTE * Added FusionPower to properly display available fusion recipes and OC * spotlessApply (#1743) Co-authored-by: GitHub GTNH Actions <> * Moved compare flag to recipe map * Missed a new constructor * Added user request * Addressed reviews * Typo * Update src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java Co-authored-by: miozune * Removed wrong bracket from git online commit --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: miozune --- .../api/interfaces/metatileentity/IMetaTileEntity.java | 8 ++++++++ .../implementations/GT_MetaTileEntity_BasicMachine.java | 3 ++- src/main/java/gregtech/api/util/GT_Recipe.java | 14 +++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java index 66c85be547..849b82565e 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java @@ -33,6 +33,7 @@ import gregtech.api.interfaces.tileentity.IMachineBlockUpdateable; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Util; +import gregtech.common.power.Power; /** * Warning, this Interface has just been made to be able to add multiple kinds of MetaTileEntities (Cables, Pipes, @@ -353,6 +354,13 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand */ String getSpecialVoltageToolTip(); + /** + * @return Power object used for displaying in NEI + */ + default Power getPower() { + return null; + } + /** * Icon of the Texture. If this returns null then it falls back to getTextureIndex. * diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 501e78ccec..62d6868286 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -751,7 +751,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B /** * Calcualtes overclocked ness using long integers - * + * * @param aEUt - recipe EUt * @param aDuration - recipe Duration */ @@ -1238,6 +1238,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } } + @Override public Power getPower() { return mPower; } diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 524976adc9..824d97a382 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -1636,7 +1636,8 @@ public class GT_Recipe implements Comparable { " EU", true, true).setProgressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) - .setUsualFluidInputCount(2).setNEISpecialInfoFormatter(FusionSpecialValueFormatter.INSTANCE); + .useComparatorForNEI(true).setUsualFluidInputCount(2) + .setNEISpecialInfoFormatter(FusionSpecialValueFormatter.INSTANCE); public static final GT_Recipe_Map sComplexFusionRecipes = new GT_Recipe_Map_ComplexFusion( new HashSet<>(50), "gt.recipe.complexfusionreactor", @@ -2616,6 +2617,12 @@ public class GT_Recipe implements Comparable { private INEISpecialInfoFormatter neiSpecialInfoFormatter; + /** + * Flag if a comparator should be used to search the recipe in NEI (which is defined in {@link Power}). Else + * only the voltage will be used to find recipes + */ + public boolean useComparatorForNEI; + /** * Initialises a new type of Recipe Handler. * @@ -2700,6 +2707,11 @@ public class GT_Recipe implements Comparable { return this; } + public GT_Recipe_Map useComparatorForNEI(boolean use) { + this.useComparatorForNEI = use; + return this; + } + public GT_Recipe_Map useModularUI(boolean use) { this.useModularUI = use; return this; -- cgit