From b65ace37de4f585b8089ad413ee877b792da11ca Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Sat, 3 Aug 2024 23:21:44 +0200 Subject: Waterline rework (#2577) * Add barebones PurificationPlant class * Make simple 3x3 structure to form purification plant * Add base purification unit class and dummy sifter unit MTE * Make sifter unit form * Fix accidental wildcard import * Implement basic linking of units to controller using data stick * Make linking more robust, save bidirectional links, add scanner output * add linking range, error message and unregister old controller when re-linking * Add link status of purification units to waila body * Disable maintenance issues on purification plant units * spotless * Check structure of linked purification units in main controller * Remove all star imports * Small refactor to avoid updating status from main controller * spotless * Attempt to document current code * Convert some comments to javadoc * Implement basic processing cycle, sync it with linked purification units * Make water purification plant drain power * Calculate power drain from active units and remove controller power drain * spotless * Add very barebones recipemap * Fix recipemap name in lang file * spotless * Fix purification unit recipemap name * spotless * more sane amount of max fluid outputs * add some item outputs to sifter unit * Very simple recipe processing, may be buggy * spotless * Implement recipe failure * Implement void protection for purification units * spotless * buff item output odds slightly * Add WIP grade 1 structure * spotless * Store base success chance in recipe metadata and display it in NEI * Fill sifter plant with water * Add comment * Allow construction sifter unit in survival * Implement water boost * Fix water boost allowing output chance to go over 100% * Implement failed recipes outputting lower tier water * Fix typo * Fix deformed purification unit still drawing power * Slightly refactor recipe check so base class can read result * Create empty ModularUI container for purification plant * The great gui struggle part 1 * More gui struggles, we have a button now * Adjust button text and size * gui wars: the rise of the sync * gui wars: a new hope * fix the sync * is pengu old enough to know exceeder? * Fix being able to link the same unit multiple times * Sync status string to client * Sign sifter with my name * Show status somewhat properly * Adjust sifter base chance and structure * Fully implement sifter unit * More tooltip refactoring * Add structure info to sifter tooltip. * nitpicking tooltips * Adding sound to Purification Plant Main Unit. * fix star imports * Add basic coagulator unit, add recipemap for it * Write coagulator tooltip * comma nitpicking * more tooltip work * small refactor to purification plant controller * start work on custom recipemap frontend * Fully implement coagulator * Update structure requirements in tooltips * Move controller text in structure tooltips to be consistent * fix NPE on world load * Add base ph adjustment unit MTE * Add info to main controller and energy hatch check * Fixing tooltip of Main Controller & Energy/Exotic Hatch check. * Create full pH adjustment structure * disallow any voiding on purification unit * Small custom RecipeMap frontend for ph adjustment * Generate random initial pH value * Implement inserting NaOH and HCl to adjust pH * Add easter egg * Implement pH sensor hatch * Properly consume HCl and round pH value to 2 digits * Write ph adjustment unit tooltip * Tooltip nitpicking * Try to fix some structurelib hints * More trying to fix hints * Add industrial strength concrete casing block * Add water loop sound to the game * Document random initial pH in tooltip * Add glass material base * Fix spotless formatting in Textures docs because I cannot take it anymore * Add glass texture * Try adding transparent glass * Transparent glass working * Create pH resistant glass and update pH structure to use it * Create full structure for main purification plant * Create custom water purification casing block * Properly balance ferrous wastewater reprocessing and reduce input by a factor 10 * Add pH factor to NEI tooltip and fix coagulator structure * Structure tooltip for Purification Plant base * Add GT_Block_Glass2 and properly set maxMeta * Add Tinted Industrial Glass blocks * Fix BlockCasing9 not showing custom tooltip * Register tinted glass as EV glass * Add sterile water plant casing and revert tooltip change * Mention required water in sifter tooltip * Add more textures and casings * Add more textures, sounds and add structure info for pH adjustment * Rename sifter unit to clarifier * Rename coagulation unit to flocculation unit * Add activated carbon line * Fix unintended activated carbon recipe * Add activated carbon filter * Add polyaluminium chloride + solution * Add new custom textures by @BlueHero233 * Wip recipe page with new background for flocculation * Fix flocculation background image mostly * Finally aligned the slots * angery mumbles * Finish flocculation recipe page * All the recipe pages! * Add new reworked textures * Fix ph adjustment being t3 instead of t4 * Fix invisible casing * apply chembalance to polyaluminium chloride properly * Fix ferrous wastewater -> flocculation waste liquid * Move flocculation to grade 3 * create ozonation unit with placeholder blocks * add new blocks for ozonation with placeholder textures * Add water to ozonation structure * Create ozone gas material * Add ozone recipe * Add textures for ozone unit * Add sound loop for ozonation * fix * implement ozonation mechanics * Finalize ozonation tooltip * Create dummy plasma heater multi * Update textures for plasma heater * Add grade 5 recipemap * Add hatches to plasma heater multi * Add basic plasma heating unit variables * Implement plasma heating unit mechanics * Add plasma heater tooltip * Add structure info to plasma heater tooltip * fix ozonation tooltip, add frontend * Fix positioning on ozonation tooltip and fix plasma heater crash * Add UV treatment MTE and structure without textures * Revert accidental addition of debug dependencies * Add initial version of uv unit textures * update naquadria casing, add water color gradient * Some minor cleanup and added docs * Create lens housing bus * Add lens bus to UV treatment unit * Add lens indicator hatch * Merge GT_MetaGeneratedItem_03.java * Add lens indicator hatch * Add the lens cycle, uv treatment recipe map and fix eut of flocculation recipe * Implement lens swapping mechanic * Clean up first lens swap * Fix uv recipemap lang and move lens cycle to recipe * Write uv treatment tooltip * Add sounds for uv and plasma steps * Create empty degasifier class * Create temporary debug structure for degasifier * set temp casing index for degasifier * create degasifier control hatch * create slightly less temporary but still temporary structure for degasifier * Start impl of degasifier * fix fluid consumption and nbt loading of degasifier * Degasifier implementation should work now * Rename and reformat some things and start work on degasser tooltiop * give last bit much lower chance of being on to avoid cheesing * Finish degasifier tooltip * Integrate some deleno lore * hopefully fix all moved casing meta ids after merge * Create finalized degasser structure * Integrate more deleno lore * Add even more lore * Create placeholder particle catalysts and fetch particle items from gt++ * Fix wrong casing and recipemap localization * Create parallel config menu * refactor purification recipecheck slightly * implement parallel amount on water i/o and power * add tooltip info about parallel config * fix text * update block names in structure tooltips * create structure tooltip for degasser * create textureless quark catalyst items * add the purple glass * fix lore typos * fix some casing indices * remove concrete floor from water plant and reword tooltip * fix main plant structure and add placeholder structure for t8 step * fix structurecheck for main plant and add random catalyst generation for t8 * implement basic mechanics for particle extractor (wip) * Create plasma heater frontend * implement final mechanics and bugfixes for particle extractor * add recipes for re-aligning quark catalysts * add simple recipes for catalyst alignment * initial replacement of purified water in engraver recipes * add purified water to all wafer cutting recipes * fix purified water amounts * buff quark cyclotron recipe again * extract t8 unit casings into their own icons * Write initial tooltip for t8 module * add purified water to mask recipes * Add recipe comparator to show low tier purified water recipes first * add min casing check to waterline multis * buff ozone production * update t8 structure * make purified water optional again for naq wafers * Fix blockrenderer for purification plant * fix nei previews * fix nei * really fix nei this time * add t8 lore * fix hatch recipe locking blocking automation on some steps * try to solve weirdness with grade 3 recipe * fix issues with recipecheck * fix missing null check * make ph sensor use a strict inequality check * fix min casings on t5 * significantly nerf purified water usage for beamline masks * disable void protection for waterline * small adjustments to t6 unit * more small adjustments to t6 unit to prevent easy automation cheese * fix degasser redstone output and missing return statement * remove water QFT catalyst recipes --------- Co-authored-by: Tianyou Mei Co-authored-by: OlliedeLeeuw Co-authored-by: Ollie_de_Leeuw <154506304+OlliedeLeeuw@users.noreply.github.com> Co-authored-by: Martin Robertz --- .../maps/PurificationUnitClarifierFrontend.java | 72 ++++++++++++ .../maps/PurificationUnitFlocculatorFrontend.java | 99 ++++++++++++++++ .../maps/PurificationUnitOzonationFrontend.java | 51 +++++++++ .../maps/PurificationUnitPhAdjustmentFrontend.java | 79 +++++++++++++ .../maps/PurificationUnitPlasmaHeaterFrontend.java | 59 ++++++++++ .../maps/PurificationUnitRecipeMapFrontend.java | 124 +++++++++++++++++++++ 6 files changed, 484 insertions(+) create mode 100644 src/main/java/gregtech/api/recipe/maps/PurificationUnitClarifierFrontend.java create mode 100644 src/main/java/gregtech/api/recipe/maps/PurificationUnitFlocculatorFrontend.java create mode 100644 src/main/java/gregtech/api/recipe/maps/PurificationUnitOzonationFrontend.java create mode 100644 src/main/java/gregtech/api/recipe/maps/PurificationUnitPhAdjustmentFrontend.java create mode 100644 src/main/java/gregtech/api/recipe/maps/PurificationUnitPlasmaHeaterFrontend.java create mode 100644 src/main/java/gregtech/api/recipe/maps/PurificationUnitRecipeMapFrontend.java (limited to 'src/main/java/gregtech/api/recipe/maps') diff --git a/src/main/java/gregtech/api/recipe/maps/PurificationUnitClarifierFrontend.java b/src/main/java/gregtech/api/recipe/maps/PurificationUnitClarifierFrontend.java new file mode 100644 index 0000000000..c7dad7ea3a --- /dev/null +++ b/src/main/java/gregtech/api/recipe/maps/PurificationUnitClarifierFrontend.java @@ -0,0 +1,72 @@ +package gregtech.api.recipe.maps; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; + +import codechicken.nei.PositionedStack; +import gregtech.api.enums.ItemList; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.common.gui.modularui.UIHelper; +import gregtech.common.tileentities.machines.multi.purification.GT_MetaTileEntity_PurificationUnitClarifier; +import gregtech.nei.GT_NEI_DefaultHandler; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class PurificationUnitClarifierFrontend extends PurificationUnitRecipeMapFrontend { + + public PurificationUnitClarifierFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + 80, + uiPropertiesBuilder.logoPos(new Pos2d(160, 100)) + .progressBarTexture(new FallbackableUITexture(GT_UITextures.PROGRESSBAR_CLARIFIER)) + .logoPos(new Pos2d(152, 90)), + neiPropertiesBuilder.recipeBackgroundSize(new Size(170, 120))); + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(6, 7)); + return positions; + } + + @Override + public List getFluidOutputPositions(int fluidOutputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(154, 7)); + return positions; + } + + @Override + public List getItemInputPositions(int itemInputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(79, 43)); + return positions; + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return UIHelper.getGridPositions(itemOutputCount, 136, 43, 2, 2); + } + + @Override + public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + super.drawNEIOverlays(neiCachedRecipe); + + for (PositionedStack stack : neiCachedRecipe.mInputs) { + if (stack.item.isItemEqual(ItemList.ActivatedCarbonFilterMesh.get(1))) { + drawNEIOverlayText((int) (GT_MetaTileEntity_PurificationUnitClarifier.FILTER_DAMAGE_RATE) + "%", stack); + } + } + } +} diff --git a/src/main/java/gregtech/api/recipe/maps/PurificationUnitFlocculatorFrontend.java b/src/main/java/gregtech/api/recipe/maps/PurificationUnitFlocculatorFrontend.java new file mode 100644 index 0000000000..9366237b67 --- /dev/null +++ b/src/main/java/gregtech/api/recipe/maps/PurificationUnitFlocculatorFrontend.java @@ -0,0 +1,99 @@ +package gregtech.api.recipe.maps; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; + +import codechicken.nei.PositionedStack; +import gregtech.api.enums.Materials; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.common.gui.modularui.UIHelper; +import gregtech.common.tileentities.machines.multi.purification.GT_MetaTileEntity_PurificationUnitFlocculation; +import gregtech.nei.GT_NEI_DefaultHandler; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class PurificationUnitFlocculatorFrontend extends PurificationUnitRecipeMapFrontend { + + public PurificationUnitFlocculatorFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + 80, + uiPropertiesBuilder.logoPos(new Pos2d(160, 100)) + .progressBarTexture(new FallbackableUITexture(GT_UITextures.PROGRESSBAR_FLOCCULATION)) + .logoPos(new Pos2d(152, 100)), + neiPropertiesBuilder.recipeBackgroundSize(new Size(170, 120))); + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(9, 39)); + return positions; + } + + @Override + public List getFluidOutputPositions(int fluidOutputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(151, 39)); + return positions; + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return UIHelper.getGridPositions(itemOutputCount, 115, 80, 3, 1); + } + + @Override + @NotNull + public List handleNEIItemTooltip(ItemStack stack, List currentTip, + GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + if (stack + .isItemEqual(GT_Utility.getFluidDisplayStack(Materials.PolyAluminiumChloride.getFluid(1000L), false))) { + currentTip.add("Consumed during operation"); + currentTip.add( + "+" + GT_MetaTileEntity_PurificationUnitFlocculation.SUCCESS_PER_LEVEL + + "%/" + + GT_MetaTileEntity_PurificationUnitFlocculation.INPUT_CHEMICAL_PER_LEVEL + + "L"); + } else if (stack + .isItemEqual(GT_Utility.getFluidDisplayStack(Materials.FlocculationWasteLiquid.getFluid(1000L), false))) { + currentTip.add("Returned in amount equivalent to consumed flocculant."); + } + return super.handleNEIItemTooltip(stack, currentTip, neiCachedRecipe); + } + + @Override + public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + super.drawNEIOverlays(neiCachedRecipe); + + // Display flocculation chemical + neiCachedRecipe.mInputs.add( + new PositionedStack( + GT_Utility.getFluidDisplayStack(Materials.PolyAluminiumChloride.getFluid(100000L), true), + 5, + -1, + false)); + + // Display waste output + neiCachedRecipe.mOutputs.add( + new PositionedStack( + GT_Utility.getFluidDisplayStack(Materials.FlocculationWasteLiquid.getFluid(100000L), true), + 147, + 48, + false)); + } +} diff --git a/src/main/java/gregtech/api/recipe/maps/PurificationUnitOzonationFrontend.java b/src/main/java/gregtech/api/recipe/maps/PurificationUnitOzonationFrontend.java new file mode 100644 index 0000000000..cdfd41b78c --- /dev/null +++ b/src/main/java/gregtech/api/recipe/maps/PurificationUnitOzonationFrontend.java @@ -0,0 +1,51 @@ +package gregtech.api.recipe.maps; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; + +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.common.gui.modularui.UIHelper; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class PurificationUnitOzonationFrontend extends PurificationUnitRecipeMapFrontend { + + public PurificationUnitOzonationFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + 120, + uiPropertiesBuilder.logoPos(new Pos2d(160, 100)) + .progressBarTexture(new FallbackableUITexture(GT_UITextures.PROGRESSBAR_OZONATION)) + .logoPos(new Pos2d(152, 97)), + neiPropertiesBuilder.recipeBackgroundSize(new Size(170, 180))); + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(79, 100)); + positions.add(new Pos2d(27, 77)); + return positions; + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return UIHelper.getGridPositions(itemOutputCount, 131, 26, 2); + } + + @Override + public List getFluidOutputPositions(int fluidOutputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(131, 97)); + return positions; + } +} diff --git a/src/main/java/gregtech/api/recipe/maps/PurificationUnitPhAdjustmentFrontend.java b/src/main/java/gregtech/api/recipe/maps/PurificationUnitPhAdjustmentFrontend.java new file mode 100644 index 0000000000..7e9eded675 --- /dev/null +++ b/src/main/java/gregtech/api/recipe/maps/PurificationUnitPhAdjustmentFrontend.java @@ -0,0 +1,79 @@ +package gregtech.api.recipe.maps; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; + +import codechicken.nei.PositionedStack; +import gregtech.api.enums.Materials; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.common.tileentities.machines.multi.purification.GT_MetaTileEntity_PurificationUnitPhAdjustment; +import gregtech.nei.GT_NEI_DefaultHandler; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class PurificationUnitPhAdjustmentFrontend extends PurificationUnitRecipeMapFrontend { + + public PurificationUnitPhAdjustmentFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + 80, + uiPropertiesBuilder.logoPos(new Pos2d(160, 100)) + .progressBarTexture(new FallbackableUITexture(GT_UITextures.PROGRESSBAR_PH_NEUTRALIZATION)) + .logoPos(new Pos2d(152, 90)), + neiPropertiesBuilder.recipeBackgroundSize(new Size(170, 120))); + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(42, 44)); + return positions; + } + + @Override + public List getFluidOutputPositions(int fluidOutputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(116, 44)); + return positions; + } + + @Override + @NotNull + public List handleNEIItemTooltip(ItemStack stack, List currentTip, + GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + // Add pH adjustment values + if (stack.isItemEqual(Materials.SodiumHydroxide.getDust(1))) { + currentTip + .add("+" + GT_MetaTileEntity_PurificationUnitPhAdjustment.PH_PER_ALKALINE_DUST * 64 + " pH/stack"); + } else + if (stack.isItemEqual(GT_Utility.getFluidDisplayStack(Materials.HydrochloricAcid.getFluid(1000L), false))) { + currentTip.add(GT_MetaTileEntity_PurificationUnitPhAdjustment.PH_PER_10_ACID_LITER * 100 + " pH/1000L"); + } + return super.handleNEIItemTooltip(stack, currentTip, neiCachedRecipe); + } + + @Override + public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + neiCachedRecipe.mInputs.add(new PositionedStack(Materials.SodiumHydroxide.getDust(64), 3, 1, false)); + neiCachedRecipe.mInputs.add( + new PositionedStack( + GT_Utility.getFluidDisplayStack(Materials.HydrochloricAcid.getFluid(1000L), true), + 147, + 1, + false)); + } +} diff --git a/src/main/java/gregtech/api/recipe/maps/PurificationUnitPlasmaHeaterFrontend.java b/src/main/java/gregtech/api/recipe/maps/PurificationUnitPlasmaHeaterFrontend.java new file mode 100644 index 0000000000..5c63353b98 --- /dev/null +++ b/src/main/java/gregtech/api/recipe/maps/PurificationUnitPlasmaHeaterFrontend.java @@ -0,0 +1,59 @@ +package gregtech.api.recipe.maps; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.gtnewhorizons.modularui.api.drawable.FallbackableUITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; + +import codechicken.nei.PositionedStack; +import gregtech.api.enums.Materials; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.nei.GT_NEI_DefaultHandler; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class PurificationUnitPlasmaHeaterFrontend extends PurificationUnitRecipeMapFrontend { + + public PurificationUnitPlasmaHeaterFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + 120, + uiPropertiesBuilder.logoPos(new Pos2d(152, 90)) + .progressBarTexture(new FallbackableUITexture(GT_UITextures.PROGRESSBAR_PLASMA_HEATER)), + neiPropertiesBuilder.recipeBackgroundSize(new Size(170, 120))); + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(30, 83)); + return positions; + } + + @Override + public List getFluidOutputPositions(int fluidOutputCount) { + ArrayList positions = new ArrayList<>(); + positions.add(new Pos2d(111, 82)); + return positions; + } + + @Override + public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + neiCachedRecipe.mInputs.add( + new PositionedStack(GT_Utility.getFluidDisplayStack(Materials.Helium.getPlasma(10L), true), 26, 53, false)); + neiCachedRecipe.mInputs.add( + new PositionedStack( + GT_Utility.getFluidDisplayStack(Materials.SuperCoolant.getFluid(100L), true), + 107, + 52, + false)); + } +} diff --git a/src/main/java/gregtech/api/recipe/maps/PurificationUnitRecipeMapFrontend.java b/src/main/java/gregtech/api/recipe/maps/PurificationUnitRecipeMapFrontend.java new file mode 100644 index 0000000000..849c392cdb --- /dev/null +++ b/src/main/java/gregtech/api/recipe/maps/PurificationUnitRecipeMapFrontend.java @@ -0,0 +1,124 @@ +package gregtech.api.recipe.maps; + +import java.util.function.Supplier; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.apache.commons.lang3.tuple.Pair; + +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import gregtech.api.enums.SteamVariant; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.common.gui.modularui.UIHelper; + +// Makes some small changes to the default recipe frontend to display custom backgrounds and progress bars +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class PurificationUnitRecipeMapFrontend extends RecipeMapFrontend { + + private final int overlayHeight; + private static final Pos2d realProgressBarPos = new Pos2d(3, 3); + + public PurificationUnitRecipeMapFrontend(int overlayHeight, BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + uiPropertiesBuilder.progressBarSize(new Size(0, 0)) + .progressBarPos(new Pos2d(0, 0)), + neiPropertiesBuilder); + this.overlayHeight = overlayHeight; + } + + @Override + public void addProgressBar(ModularWindow.Builder builder, Supplier progressSupplier, Pos2d windowOffset) { + assert uiProperties.progressBarTexture != null; + UITexture texture = uiProperties.progressBarTexture.get(); + builder.widget( + new ProgressBar().setTexture(texture, 170) + .setDirection(uiProperties.progressBarDirection) + .setProgress(progressSupplier) + .setSynced(false, false) + .setPos(realProgressBarPos.add(windowOffset)) + .setSize(new Size(170, overlayHeight))); + } + + @Override + public ModularWindow.Builder createNEITemplate(IItemHandlerModifiable itemInputsInventory, + IItemHandlerModifiable itemOutputsInventory, IItemHandlerModifiable specialSlotInventory, + IItemHandlerModifiable fluidInputsInventory, IItemHandlerModifiable fluidOutputsInventory, + Supplier progressSupplier, Pos2d windowOffset) { + // Override regular createNEITemplate method, so we can remove the background texture with the ugly border. + ModularWindow.Builder builder = ModularWindow.builder(neiProperties.recipeBackgroundSize); + + // First draw progress bar in background + if (uiProperties.useProgressBar) { + addProgressBar(builder, progressSupplier, windowOffset); + } + + UIHelper.forEachSlots( + (i, backgrounds, pos) -> builder.widget( + SlotWidget.phantom(itemInputsInventory, i) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)), + (i, backgrounds, pos) -> builder.widget( + SlotWidget.phantom(itemOutputsInventory, i) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)), + (i, backgrounds, pos) -> { + if (uiProperties.useSpecialSlot) builder.widget( + SlotWidget.phantom(specialSlotInventory, 0) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)); + }, + (i, backgrounds, pos) -> builder.widget( + SlotWidget.phantom(fluidInputsInventory, i) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)), + (i, backgrounds, pos) -> builder.widget( + SlotWidget.phantom(fluidOutputsInventory, i) + .setBackground(backgrounds) + .setPos(pos) + .setSize(18, 18)), + ModularUITextures.ITEM_SLOT, + ModularUITextures.FLUID_SLOT, + uiProperties, + uiProperties.maxItemInputs, + uiProperties.maxItemOutputs, + uiProperties.maxFluidInputs, + uiProperties.maxFluidOutputs, + SteamVariant.NONE, + windowOffset); + + addGregTechLogo(builder, windowOffset); + + for (Pair> specialTexture : uiProperties.specialTextures) { + builder.widget( + new DrawableWidget().setDrawable(specialTexture.getLeft()) + .setSize( + specialTexture.getRight() + .getLeft()) + .setPos( + specialTexture.getRight() + .getRight() + .add(windowOffset))); + } + + return builder; + } +} -- cgit