From ee0775b94e9a4ded31fe095b1bcb311144e7b8f4 Mon Sep 17 00:00:00 2001 From: miozune Date: Thu, 30 Nov 2023 20:40:27 +0900 Subject: [PATCH] Migrate to new RecipeMap --- build.gradle | 4 +- dependencies.gradle | 10 +- .../nei/GasSiphonRecipeHandler.java | 6 +- .../gtnhintergalactic/nei/IMCForNEI.java | 85 ------ .../gtnhintergalactic/nei/NEIConfig.java | 34 --- .../gtnhintergalactic/nei/NEI_IG_Config.java | 65 +++++ .../nei/SpacePumpModuleRecipeHandler.java | 6 +- .../gtnhintergalactic/proxy/ClientProxy.java | 3 + .../gtnhintergalactic/proxy/CommonProxy.java | 2 - .../recipe/IGRecipeMaps.java | 41 +++ .../recipe/IG_RecipeAdder.java | 258 +----------------- .../recipe/IG_Recipe_Map.java | 129 --------- .../recipe/MachineRecipes.java | 14 +- .../recipe/maps/SpaceAssemblerFrontend.java | 95 +++++++ .../recipe/maps/SpaceMiningFrontend.java | 78 ++++++ .../recipe/maps/SpaceResearchFrontend.java | 84 ++++++ .../ModuleOverclockDescriber.java | 34 +++ .../TileEntityModuleAssembler.java | 48 +--- .../TileEntityModuleManager.java | 13 +- .../TileEntityModuleMiner.java | 89 ++---- .../TileEntityModuleResearch.java | 7 +- .../assets/gtnhintergalactic/lang/en_US.lang | 13 +- 22 files changed, 487 insertions(+), 631 deletions(-) delete mode 100644 src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/IMCForNEI.java delete mode 100644 src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/NEIConfig.java create mode 100644 src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/NEI_IG_Config.java create mode 100644 src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IGRecipeMaps.java delete mode 100644 src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IG_Recipe_Map.java create mode 100644 src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceAssemblerFrontend.java create mode 100644 src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceMiningFrontend.java create mode 100644 src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceResearchFrontend.java create mode 100644 src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/ModuleOverclockDescriber.java diff --git a/build.gradle b/build.gradle index f3a7fa2..4e31dc8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1699290261 +//version: 1700844281 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -302,7 +302,7 @@ if (apiPackage) { } if (accessTransformersFile) { - for (atFile in accessTransformersFile.split(",")) { + for (atFile in accessTransformersFile.split(" ")) { String targetFile = "src/main/resources/META-INF/" + atFile.trim() if (!getFile(targetFile).exists()) { throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile) diff --git a/dependencies.gradle b/dependencies.gradle index 8f67616..29bbe48 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,8 +1,8 @@ dependencies { - api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.73:dev') - api('com.github.GTNewHorizons:TecTech:5.3.13:dev') - api('com.github.GTNewHorizons:Galaxy-Space-GTNH:1.2.11-GTNH:dev') - api('com.github.GTNewHorizons:GoodGenerator:0.7.5:dev') + api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.92-pre:dev') + api('com.github.GTNewHorizons:TecTech:5.3.16-pre:dev') + api('com.github.GTNewHorizons:Galaxy-Space-GTNH:1.2.14-GTNH:dev') + api('com.github.GTNewHorizons:GoodGenerator:0.7.7-pre:dev') compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.22:dev") {transitive = false} - devOnlyNonPublishable('com.github.GTNewHorizons:GTplusplus:1.10.24:dev') + devOnlyNonPublishable('com.github.GTNewHorizons:GTplusplus:1.10.35-pre:dev') } diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/GasSiphonRecipeHandler.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/GasSiphonRecipeHandler.java index 7691624..3c2a7b9 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/GasSiphonRecipeHandler.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/GasSiphonRecipeHandler.java @@ -13,7 +13,6 @@ import com.gtnewhorizons.gtnhintergalactic.gui.IG_UITextures; import com.gtnewhorizons.gtnhintergalactic.recipe.GasSiphonRecipes; import com.gtnewhorizons.modularui.api.GlStateManager; -import com.gtnewhorizons.modularui.api.ModularUITextures; import com.gtnewhorizons.modularui.api.UIInfos; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.math.Pos2d; @@ -24,6 +23,7 @@ import codechicken.lib.gui.GuiDraw; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.TemplateRecipeHandler; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.util.GT_Utility; import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; @@ -39,7 +39,7 @@ public class GasSiphonRecipeHandler extends TemplateRecipeHandler { /** Modular window used to display the recipes */ protected final ModularWindow modularWindow; /** Offsets of the recipe window */ - private static final Pos2d WINDOW_OFFSET = new Pos2d(-3, -8); + private static final Pos2d WINDOW_OFFSET = new Pos2d(-2, -8); /** X coordinate of the category titles */ private static final int CATEGORY_TITLE_X = 30; @@ -58,7 +58,7 @@ public class GasSiphonRecipeHandler extends TemplateRecipeHandler { * Initialize the handler for gas siphons recipes */ public GasSiphonRecipeHandler() { - modularWindow = ModularWindow.builder(172, 82).setBackground(ModularUITextures.VANILLA_BACKGROUND) + modularWindow = ModularWindow.builder(170, 82).setBackground(GT_UITextures.BACKGROUND_NEI_SINGLE_RECIPE) .widget( new DrawableWidget().setDrawable(IG_UITextures.PICTURE_ELEVATOR_LOGO).setSize(17, 17) .setPos(new Pos2d(147, 52))) diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/IMCForNEI.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/IMCForNEI.java deleted file mode 100644 index 3a9d8be..0000000 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/IMCForNEI.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.gtnewhorizons.gtnhintergalactic.nei; - -import net.minecraft.nbt.NBTTagCompound; - -import com.gtnewhorizons.gtnhintergalactic.Tags; - -import cpw.mods.fml.common.event.FMLInterModComms; - -public class IMCForNEI { - - public static void IMCSender() { - sendHandler( - "com.gtnewhorizons.gtnhintergalactic.nei.SpacePumpModuleRecipeHandler", - "gregtech:gt.blockmachines:14010", - 160, - 90, - 3); - sendCatalyst( - "com.gtnewhorizons.gtnhintergalactic.nei.SpacePumpModuleRecipeHandler", - "gregtech:gt.blockmachines:14010"); - sendCatalyst( - "com.gtnewhorizons.gtnhintergalactic.nei.SpacePumpModuleRecipeHandler", - "gregtech:gt.blockmachines:14011"); - sendCatalyst( - "com.gtnewhorizons.gtnhintergalactic.nei.SpacePumpModuleRecipeHandler", - "gregtech:gt.blockmachines:14014"); - - sendHandler( - "com.gtnewhorizons.gtnhintergalactic.nei.GasSiphonRecipeHandler", - "gregtech:gt.blockmachines:14002", - 160, - 90, - 3); - sendCatalyst( - "com.gtnewhorizons.gtnhintergalactic.nei.GasSiphonRecipeHandler", - "gregtech:gt.blockmachines:14002"); - - sendHandler("gt.recipe.spaceMining", "gregtech:gt.blockmachines:14007"); - sendCatalyst("gt.recipe.spaceMining", "gregtech:gt.blockmachines:14007"); - sendCatalyst("gt.recipe.spaceMining", "gregtech:gt.blockmachines:14008"); - sendCatalyst("gt.recipe.spaceMining", "gregtech:gt.blockmachines:14009"); - - sendHandler("gt.recipe.spaceAssembler", "gregtech:gt.blockmachines:14004"); - sendCatalyst("gt.recipe.spaceAssembler", "gregtech:gt.blockmachines:14004"); - sendCatalyst("gt.recipe.spaceAssembler", "gregtech:gt.blockmachines:14005"); - sendCatalyst("gt.recipe.spaceAssembler", "gregtech:gt.blockmachines:14006"); - - sendHandler("gt.recipe.spaceResearch", "gregtech:gt.blockmachines:14013"); - sendCatalyst("gt.recipe.spaceResearch", "gregtech:gt.blockmachines:14013"); - - sendHandler("gt.recipe.fakespaceprojects", "gregtech:gt.blockmachines:14012", 160, 166, 1); - sendCatalyst("gt.recipe.fakespaceprojects", "gregtech:gt.blockmachines:14012"); - } - - private static void sendHandler(String name, String itemStack, int handlerWidth, int handlerHeight, - int recipePerPage) { - NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setString("handler", name); - aNBT.setString("modName", Tags.MODNAME); - aNBT.setString("modId", Tags.MODID); - aNBT.setBoolean("modRequired", true); - aNBT.setString("itemName", itemStack); - aNBT.setInteger("handlerHeight", handlerHeight); - aNBT.setInteger("handlerWidth", handlerWidth); - aNBT.setInteger("maxRecipesPerPage", recipePerPage); - aNBT.setInteger("yShift", 6); - FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT); - } - - private static void sendHandler(String name, String itemStack) { - sendHandler(name, itemStack, 160, 166, 2); - } - - private static void sendCatalyst(String name, String itemStack, int priority) { - NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setString("handlerID", name); - aNBT.setString("itemName", itemStack); - aNBT.setInteger("priority", priority); - FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT); - } - - private static void sendCatalyst(String name, String itemStack) { - sendCatalyst(name, itemStack, 0); - } -} diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/NEIConfig.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/NEIConfig.java deleted file mode 100644 index 51dd49e..0000000 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/NEIConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.gtnewhorizons.gtnhintergalactic.nei; - -import com.gtnewhorizons.gtnhintergalactic.Tags; -import com.gtnewhorizons.gtnhintergalactic.gui.IG_UITextures; - -import codechicken.nei.api.API; -import codechicken.nei.api.IConfigureNEI; -import gregtech.api.util.GT_Recipe; - -public class NEIConfig implements IConfigureNEI { - - public static boolean executed = false; - - @Override - public void loadConfig() { - API.registerRecipeHandler(new SpacePumpModuleRecipeHandler()); - API.registerUsageHandler(new SpacePumpModuleRecipeHandler()); - API.registerRecipeHandler(new GasSiphonRecipeHandler()); - API.registerUsageHandler(new GasSiphonRecipeHandler()); - // Inject elevator logo into GT5U recipe map - GT_Recipe.GT_Recipe_Map.sFakeSpaceProjectRecipes.setLogo(IG_UITextures.PICTURE_ELEVATOR_LOGO); - executed = true; - } - - @Override - public String getName() { - return "GTNH-Intergalactic NEI Plugin"; - } - - @Override - public String getVersion() { - return Tags.VERSION; - } -} diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/NEI_IG_Config.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/NEI_IG_Config.java new file mode 100644 index 0000000..48be058 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/NEI_IG_Config.java @@ -0,0 +1,65 @@ +package com.gtnewhorizons.gtnhintergalactic.nei; + +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import com.gtnewhorizons.gtnhintergalactic.Tags; +import com.gtnewhorizons.gtnhintergalactic.item.IGItems; + +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; +import codechicken.nei.event.NEIRegisterHandlerInfosEvent; +import codechicken.nei.recipe.HandlerInfo; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class NEI_IG_Config implements IConfigureNEI { + + public static boolean executed = false; + + @Override + public void loadConfig() { + API.registerRecipeHandler(new SpacePumpModuleRecipeHandler()); + API.registerUsageHandler(new SpacePumpModuleRecipeHandler()); + API.registerRecipeHandler(new GasSiphonRecipeHandler()); + API.registerUsageHandler(new GasSiphonRecipeHandler()); + + for (ItemStack pump : Arrays.asList( + IGItems.SpaceElevatorModulePumpT1, + IGItems.SpaceElevatorModulePumpT2, + IGItems.SpaceElevatorModulePumpT3)) { + API.addRecipeCatalyst(pump, "com.gtnewhorizons.gtnhintergalactic.nei.SpacePumpModuleRecipeHandler"); + } + API.addRecipeCatalyst( + IGItems.PlanetaryGasSiphon, + "com.gtnewhorizons.gtnhintergalactic.nei.GasSiphonRecipeHandler"); + + executed = true; + } + + @SubscribeEvent + public void registerHandlerInfo(NEIRegisterHandlerInfosEvent event) { + event.registerHandlerInfo( + new HandlerInfo.Builder( + "com.gtnewhorizons.gtnhintergalactic.nei.SpacePumpModuleRecipeHandler", + Tags.MODNAME, + Tags.MODID).setDisplayStack(IGItems.SpaceElevatorModulePumpT1).setShiftY(6).setWidth(160) + .setHeight(90).setMaxRecipesPerPage(3).build()); + event.registerHandlerInfo( + new HandlerInfo.Builder( + "com.gtnewhorizons.gtnhintergalactic.nei.GasSiphonRecipeHandler", + Tags.MODNAME, + Tags.MODID).setDisplayStack(IGItems.PlanetaryGasSiphon).setShiftY(6).setWidth(160).setHeight(90) + .setMaxRecipesPerPage(3).build()); + } + + @Override + public String getName() { + return "GTNH-Intergalactic NEI Plugin"; + } + + @Override + public String getVersion() { + return Tags.VERSION; + } +} diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/SpacePumpModuleRecipeHandler.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/SpacePumpModuleRecipeHandler.java index 98574f4..d95a75e 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/SpacePumpModuleRecipeHandler.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/nei/SpacePumpModuleRecipeHandler.java @@ -15,7 +15,6 @@ import com.gtnewhorizons.gtnhintergalactic.gui.IG_UITextures; import com.gtnewhorizons.gtnhintergalactic.recipe.SpacePumpingRecipes; import com.gtnewhorizons.modularui.api.GlStateManager; -import com.gtnewhorizons.modularui.api.ModularUITextures; import com.gtnewhorizons.modularui.api.UIInfos; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.math.Pos2d; @@ -26,6 +25,7 @@ import codechicken.lib.gui.GuiDraw; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.TemplateRecipeHandler; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.util.GT_Utility; /** @@ -40,7 +40,7 @@ public class SpacePumpModuleRecipeHandler extends TemplateRecipeHandler { /** Modular window used to display the recipes */ protected final ModularWindow modularWindow; /** Offsets of the recipe window */ - private static final Pos2d WINDOW_OFFSET = new Pos2d(-3, -8); + private static final Pos2d WINDOW_OFFSET = new Pos2d(-2, -8); /** X coordinate of the category titles */ private static final int CATEGORY_TITLE_X = 30; @@ -59,7 +59,7 @@ public class SpacePumpModuleRecipeHandler extends TemplateRecipeHandler { * Initialize the handler for space pumping recipes */ public SpacePumpModuleRecipeHandler() { - modularWindow = ModularWindow.builder(172, 82).setBackground(ModularUITextures.VANILLA_BACKGROUND) + modularWindow = ModularWindow.builder(170, 82).setBackground(GT_UITextures.BACKGROUND_NEI_SINGLE_RECIPE) .widget( new DrawableWidget().setDrawable(IG_UITextures.PICTURE_ELEVATOR_LOGO).setSize(17, 17) .setPos(new Pos2d(147, 52))) diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/proxy/ClientProxy.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/proxy/ClientProxy.java index 225dd9a..c27fcaf 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/proxy/ClientProxy.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/proxy/ClientProxy.java @@ -1,10 +1,12 @@ package com.gtnewhorizons.gtnhintergalactic.proxy; import net.minecraft.util.IIcon; +import net.minecraftforge.common.MinecraftForge; import com.gtnewhorizons.gtnhintergalactic.block.BlockSpaceElevatorCable; import com.gtnewhorizons.gtnhintergalactic.client.IGTextures; import com.gtnewhorizons.gtnhintergalactic.client.TooltipUtil; +import com.gtnewhorizons.gtnhintergalactic.nei.NEI_IG_Config; import com.gtnewhorizons.gtnhintergalactic.render.RenderSpaceElevatorCable; import com.gtnewhorizons.gtnhintergalactic.tile.TileEntitySpaceElevatorCable; import com.mitchej123.hodgepodge.textures.IPatchedTextureAtlasSprite; @@ -52,6 +54,7 @@ public void init(FMLInitializationEvent event) { ClientRegistry .bindTileEntitySpecialRenderer(TileEntitySpaceElevatorCable.class, new RenderSpaceElevatorCable()); new IGTextures().run(); + MinecraftForge.EVENT_BUS.register(new NEI_IG_Config()); } /** diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/proxy/CommonProxy.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/proxy/CommonProxy.java index 147fa3b..573c48b 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/proxy/CommonProxy.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/proxy/CommonProxy.java @@ -7,7 +7,6 @@ import com.gtnewhorizons.gtnhintergalactic.item.IGItems; import com.gtnewhorizons.gtnhintergalactic.loader.MachineLoader; import com.gtnewhorizons.gtnhintergalactic.loader.RecipeLoader; -import com.gtnewhorizons.gtnhintergalactic.nei.IMCForNEI; import com.gtnewhorizons.gtnhintergalactic.recipe.IG_RecipeAdder; import com.gtnewhorizons.gtnhintergalactic.recipe.MachineRecipes; import com.gtnewhorizons.gtnhintergalactic.recipe.ResultNoSpaceProject; @@ -37,7 +36,6 @@ public void preInit(FMLPreInitializationEvent event) { // load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed) public void init(FMLInitializationEvent event) { - IMCForNEI.IMCSender(); if (Textures.BlockIcons.casingTexturePages[32] == null) { Textures.BlockIcons.casingTexturePages[32] = new ITexture[128]; } diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IGRecipeMaps.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IGRecipeMaps.java new file mode 100644 index 0000000..4689e25 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IGRecipeMaps.java @@ -0,0 +1,41 @@ +package com.gtnewhorizons.gtnhintergalactic.recipe; + +import java.util.Comparator; + +import com.gtnewhorizons.gtnhintergalactic.gui.IG_UITextures; +import com.gtnewhorizons.gtnhintergalactic.recipe.maps.SpaceAssemblerFrontend; +import com.gtnewhorizons.gtnhintergalactic.recipe.maps.SpaceMiningFrontend; +import com.gtnewhorizons.gtnhintergalactic.recipe.maps.SpaceResearchFrontend; + +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.util.GT_Recipe; + +public class IGRecipeMaps { + + /** Recipe map for recipes in the Space Research Module */ + public static final RecipeMap spaceResearchRecipes = RecipeMapBuilder + .of("gt.recipe.spaceResearch").maxIO(7, 1, 3, 0).minInputs(1, 0).logo(IG_UITextures.PICTURE_ELEVATOR_LOGO) + .logoSize(18, 18).neiTransferRect(110, 35, 18, 18).progressBarPos(110, 35) + .frontend(SpaceResearchFrontend::new).build(); + /** Recipe map for recipes in the Space Assembler Module */ + public static final RecipeMap spaceAssemblerRecipes = RecipeMapBuilder + .of("gt.recipe.spaceAssembler").maxIO(16, 1, 4, 0).minInputs(1, 0).logo(IG_UITextures.PICTURE_ELEVATOR_LOGO) + .logoSize(18, 18).neiTransferRect(124, 8, 16, 16) + .neiRecipeComparator( + Comparator.comparing(recipe -> recipe.mSpecialValue) + .thenComparing(GT_Recipe::compareTo)) + .neiTransferRect(88, 8, 18, 72).neiTransferRect(124, 8, 18, 72).useCustomFilterForNEI() + .frontend(SpaceAssemblerFrontend::new).build(); + /** Recipe map for recipes in the Space Mining Module */ + public static final RecipeMap spaceMiningRecipes = RecipeMapBuilder.of("gt.recipe.spaceMining") + .maxIO(5, 16, 2, 0).minInputs(1, 0) + .neiRecipeComparator( + Comparator.comparing(recipe -> recipe.mSpecialValue) + .thenComparing(GT_Recipe::compareTo)) + .logo(IG_UITextures.PICTURE_ELEVATOR_LOGO).logoPos(151, 58).logoSize(18, 18) + .neiRecipeBackgroundSize(170, 78).neiTransferRect(46, 6, 23, 63).dontUseProgressBar() + .addSpecialTexture(46, 6, 23, 63, IG_UITextures.PROGRESSBAR_SPACE_MINING_MODULE_ARROW) + .useCustomFilterForNEI().frontend(SpaceMiningFrontend::new).build(); +} diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IG_RecipeAdder.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IG_RecipeAdder.java index 0ab7699..90c5e9d 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IG_RecipeAdder.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IG_RecipeAdder.java @@ -1,33 +1,15 @@ package com.gtnewhorizons.gtnhintergalactic.recipe; -import java.awt.Rectangle; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.function.Supplier; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import com.gtnewhorizons.gtnhintergalactic.gui.IG_UITextures; -import com.gtnewhorizons.modularui.api.math.Pos2d; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.common.widget.DrawableWidget; -import com.gtnewhorizons.modularui.common.widget.ProgressBar; - import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; import gregtech.common.GT_RecipeAdder; -import gregtech.common.gui.modularui.UIHelper; -import gregtech.common.misc.spaceprojects.SpaceProjectManager; -import gregtech.nei.NEIRecipeInfo; -import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; /** * GT recipe adder of GTNH-Intergalactic @@ -71,7 +53,7 @@ public static boolean addSpaceResearchRecipe(ItemStack[] aItemInputs, FluidStack aFluidInputs = nullFluid; } - return instance.sSpaceResearchRecipes.add( + IGRecipeMaps.spaceResearchRecipes.add( new IG_Recipe( false, aItemInputs, @@ -84,8 +66,8 @@ public static boolean addSpaceResearchRecipe(ItemStack[] aItemInputs, FluidStack EUt, computationRequiredPerSec, neededSpaceProject, - neededSpaceProjectLocation)) - != null; + neededSpaceProjectLocation)); + return true; } /** @@ -111,7 +93,7 @@ public static boolean addSpaceAssemblerRecipe(ItemStack[] aItemInputs, FluidStac aFluidInputs = nullFluid; } - return instance.sSpaceAssemblerRecipes.add( + IGRecipeMaps.spaceAssemblerRecipes.add( new IG_Recipe( false, aItemInputs, @@ -124,8 +106,8 @@ public static boolean addSpaceAssemblerRecipe(ItemStack[] aItemInputs, FluidStac EUt, requiredModuleTier, neededSpaceProject, - neededSpaceProjectLocation)) - != null; + neededSpaceProjectLocation)); + return true; } /** @@ -191,7 +173,7 @@ public static boolean addSpaceMiningRecipe(ItemStack[] aItemInputs, FluidStack[] outputs[i] = GT_OreDictUnificator.get(orePrefixes, ores[i], 64); } - instance.sSpaceMiningRecipes.add( + IGRecipeMaps.spaceMiningRecipes.add( new IG_Recipe.IG_SpaceMiningRecipe( false, aItemInputs, @@ -247,7 +229,7 @@ public static boolean addSpaceMiningRecipe(ItemStack[] aItemInputs, FluidStack[] aFluidInputs = nullFluid; } - instance.sSpaceMiningRecipes.add( + IGRecipeMaps.spaceMiningRecipes.add( new IG_Recipe.IG_SpaceMiningRecipe( false, aItemInputs, @@ -266,228 +248,4 @@ public static boolean addSpaceMiningRecipe(ItemStack[] aItemInputs, FluidStack[] return true; } - - /** Recipe map for recipes in the Space Research Module */ - public IG_Recipe_Map sSpaceResearchRecipes = (IG_Recipe_Map) new IG_Recipe_Map( - new HashSet<>(32), - "gt.recipe.spaceResearch", - GCCoreUtil.translate("ig.nei.spaceresearch.name"), - null, - "gregtech:textures/gui/FakeAssemblyline", - 7, - 1, - 1, - 0, - 1, - GCCoreUtil.translate("ig.nei.spacemining.computationPrefix") + " ", - 1, - " " + GCCoreUtil.translate("ig.nei.spacemining.computationSuffix"), - true, - true) { - - @Override - public List getItemOutputPositions(int itemOutputCount) { - return Collections.singletonList(new Pos2d(142, 35)); - } - - @Override - public List getItemInputPositions(int itemInputCount) { - List inputPositions = new ArrayList<>(); - inputPositions.add(new Pos2d(80, 35)); - inputPositions.add(new Pos2d(62, 8)); - inputPositions.add(new Pos2d(80, 8)); - inputPositions.add(new Pos2d(98, 8)); - inputPositions.add(new Pos2d(62, 60)); - inputPositions.add(new Pos2d(80, 60)); - inputPositions.add(new Pos2d(98, 60)); - return inputPositions; - } - - @Override - public List getFluidInputPositions(int fluidInputCount) { - return UIHelper.getGridPositions(fluidInputCount, 34, 17, 1); - } - }.setUsualFluidInputCount(3).setLogo(IG_UITextures.PICTURE_ELEVATOR_LOGO).setLogoSize(18, 18) - .setNEITransferRect(new Rectangle(110, 35, 18, 18)).setProgressBarPos(110, 35) - .setNEISpecialInfoFormatter((recipeInfo, applyPrefixAndSuffix) -> { - List specialInfo = new ArrayList<>(); - specialInfo.add(applyPrefixAndSuffix.apply(recipeInfo.recipe.mSpecialValue)); - if (recipeInfo.recipe instanceof IG_Recipe) { - IG_Recipe recipe = (IG_Recipe) recipeInfo.recipe; - String neededProject = recipe.getNeededSpaceProject(); - String neededProjectLocation = recipe.getNeededSpaceProjectLocation(); - if (neededProject != null && !neededProject.equals("")) { - specialInfo.add( - String.format( - GCCoreUtil.translate("ig.nei.spaceassembler.project"), - SpaceProjectManager.getProject(neededProject).getLocalizedName())); - specialInfo.add( - String.format( - GCCoreUtil.translate("ig.nei.spaceassembler.projectAt"), - neededProjectLocation == null || neededProjectLocation.equals("") - ? GCCoreUtil.translate("ig.nei.spaceassembler.projectAnyLocation") - : GCCoreUtil.translate( - SpaceProjectManager.getLocation(neededProjectLocation) - .getUnlocalizedName()))); - } - } - return specialInfo; - }); - - /** Recipe map for recipes in the Space Assembler Module */ - public IG_Recipe_Map sSpaceAssemblerRecipes = (IG_Recipe_Map) new IG_Recipe_Map( - new HashSet<>(32), - "gt.recipe.spaceAssembler", - GCCoreUtil.translate("ig.nei.spaceassembler.name"), - null, - "gregtech:textures/gui/FakeAssemblyline", - 16, - 1, - 1, - 0, - 1, - GCCoreUtil.translate("ig.nei.spacemining.specialValue.0"), - 1, - GCCoreUtil.translate("ig.nei.spacemining.specialValue.1"), - true, - true) { - - @Override - public List getItemInputPositions(int itemInputCount) { - return UIHelper.getGridPositions(itemInputCount, 16, 8, 4); - } - - @Override - public List getItemOutputPositions(int itemOutputCount) { - return Collections.singletonList(new Pos2d(142, 8)); - } - - @Override - public List getFluidInputPositions(int fluidInputCount) { - return UIHelper.getGridPositions(fluidInputCount, 106, 8, 1); - } - - @Override - public void addProgressBarUI(ModularWindow.Builder builder, Supplier progressSupplier, - Pos2d windowOffset) { - int bar1Width = 17; - int bar2Width = 18; - builder.widget( - new ProgressBar().setTexture(GT_UITextures.PROGRESSBAR_ASSEMBLY_LINE_1, 17) - .setDirection(ProgressBar.Direction.RIGHT) - .setProgress(() -> progressSupplier.get() * ((float) (bar1Width + bar2Width) / bar1Width)) - .setSynced(false, false).setPos(new Pos2d(88, 8).add(windowOffset)).setSize(bar1Width, 72)); - builder.widget( - new ProgressBar().setTexture(GT_UITextures.PROGRESSBAR_ASSEMBLY_LINE_2, 18) - .setDirection(ProgressBar.Direction.RIGHT) - .setProgress( - () -> (progressSupplier.get() - ((float) bar1Width / (bar1Width + bar2Width))) - * ((float) (bar1Width + bar2Width) / bar2Width)) - .setSynced(false, false).setPos(new Pos2d(124, 8).add(windowOffset)) - .setSize(bar2Width, 72)); - } - }.setUsualFluidInputCount(4).setLogo(IG_UITextures.PICTURE_ELEVATOR_LOGO).setLogoSize(18, 18) - .setNEITransferRect(new Rectangle(124, 8, 16, 16)).useComparatorForNEI(true) - .setNEISpecialInfoFormatter((recipeInfo, applyPrefixAndSuffix) -> { - List specialInfo = new ArrayList<>(); - specialInfo.add(applyPrefixAndSuffix.apply(recipeInfo.recipe.mSpecialValue)); - if (recipeInfo.recipe instanceof IG_Recipe) { - IG_Recipe recipe = (IG_Recipe) recipeInfo.recipe; - String neededProject = recipe.getNeededSpaceProject(); - String neededProjectLocation = recipe.getNeededSpaceProjectLocation(); - if (neededProject != null && !neededProject.equals("")) { - specialInfo.add( - String.format( - GCCoreUtil.translate("ig.nei.spaceassembler.project"), - SpaceProjectManager.getProject(neededProject).getLocalizedName())); - specialInfo.add( - String.format( - GCCoreUtil.translate("ig.nei.spaceassembler.projectAt"), - neededProjectLocation == null || neededProjectLocation.equals("") - ? GCCoreUtil.translate("ig.nei.spaceassembler.projectAnyLocation") - : GCCoreUtil.translate( - SpaceProjectManager.getLocation(neededProjectLocation) - .getUnlocalizedName()))); - } - } - return specialInfo; - }); - - /** Recipe map for recipes in the Space Mining Module */ - public IG_Recipe_Map sSpaceMiningRecipes = (IG_Recipe_Map) new IG_Recipe_Map( - new HashSet<>(32), - "gt.recipe.spaceMining", - GCCoreUtil.translate("ig.nei.spacemining.name"), - null, - "gregtech:textures/gui/FakeSpaceMiningModule", - 5, - 16, - 1, - 0, - 1, - GCCoreUtil.translate("ig.nei.spacemining.specialValue.0"), - 1, - GCCoreUtil.translate("ig.nei.spacemining.specialValue.1"), - true, - true) { - - @Override - public List getItemInputPositions(int itemInputCount) { - List results = new ArrayList<>(); - // assume drones are present on first input - results.add(new Pos2d(143, 15)); - results.addAll(UIHelper.getGridPositions(itemInputCount - 1, 10, 6, 2)); - return results; - } - - @Override - public List getItemOutputPositions(int itemOutputCount) { - return UIHelper.getGridPositions(itemOutputCount, 69, 6, 4); - } - - @Override - public List getFluidInputPositions(int fluidInputCount) { - return UIHelper.getGridPositions(fluidInputCount, 10, 51, fluidInputCount); - } - - @Override - public void addProgressBarUI(ModularWindow.Builder builder, Supplier progressSupplier, - Pos2d windowOffset) { - builder.widget( - new DrawableWidget().setDrawable(IG_UITextures.PROGRESSBAR_SPACE_MINING_MODULE_ARROW) - .setPos(new Pos2d(46, 6).add(windowOffset)).setSize(23, 63)); - } - - @Override - protected void drawNEISpecialInfo(NEIRecipeInfo recipeInfo) { - recipeInfo.yPos -= 1; - super.drawNEISpecialInfo(recipeInfo); - } - }.setUsualFluidInputCount(2).useComparatorForNEI(true).setLogo(IG_UITextures.PICTURE_ELEVATOR_LOGO) - .setLogoPos(151, 58).setLogoSize(18, 18).setNEIBackgroundSize(172, 78) - .setNEITransferRect(new Rectangle(46, 6, 23, 63)) - .setNEISpecialInfoFormatter((recipeInfo, applyPrefixAndSuffix) -> { - List result = new ArrayList<>(); - result.add(applyPrefixAndSuffix.apply(recipeInfo.recipe.mSpecialValue)); - if (recipeInfo.recipe instanceof IG_Recipe.IG_SpaceMiningRecipe) { - IG_Recipe.IG_SpaceMiningRecipe miningRecipe = (IG_Recipe.IG_SpaceMiningRecipe) recipeInfo.recipe; - result.add( - GCCoreUtil.translate("ig.nei.spacemining.distance") + " " - + miningRecipe.minDistance - + "-" - + miningRecipe.maxDistance); - result.add( - GCCoreUtil.translate("ig.nei.spacemining.size") + " " - + miningRecipe.minSize - + "-" - + miningRecipe.maxSize); - result.add( - GCCoreUtil.translate("ig.nei.spacemining.computationPrefix") + " " - + GT_Utility.formatNumbers(miningRecipe.computation) - + " " - + GCCoreUtil.translate("ig.nei.spacemining.computationSuffix")); - result.add(GCCoreUtil.translate("ig.nei.spacemining.weight") + " " + miningRecipe.recipeWeight); - } - return result; - }); } diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IG_Recipe_Map.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IG_Recipe_Map.java deleted file mode 100644 index ff20d4e..0000000 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/IG_Recipe_Map.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.gtnewhorizons.gtnhintergalactic.recipe; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; - -/** - * GT recipes maps of GTNH-Intergalactic - * - * @author minecraft7771 - */ -public class IG_Recipe_Map extends GT_Recipe.GT_Recipe_Map { - - public IG_Recipe_Map(Collection aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, - String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, - int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, - String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { - super( - aRecipeList, - aUnlocalizedName, - aLocalName, - aNEIName, - aNEIGUIPath, - aUsualInputCount, - aUsualOutputCount, - aMinimalInputItems, - aMinimalInputFluids, - aAmperage, - aNEISpecialValuePre, - aNEISpecialValueMultiplier, - aNEISpecialValuePost, - aShowVoltageAmperageInNEI, - aNEIAllowed); - } - - public List findRecipes(IHasWorldObjectAndCoords aTileEntity, - IG_Recipe.IG_SpaceMiningRecipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, - FluidStack[] aFluids, ItemStack aSpecialSlot, int distance, int moduleTier, ItemStack... aInputs) { - // Search algorithm copied from findRecipe, just fitted to add all found recipes - - if (mRecipeList.isEmpty()) return null; - - if (GregTech_API.sPostloadFinished) { - if (mMinimalInputFluids > 0) { - if (aFluids == null) return null; - int tAmount = 0; - for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; - if (tAmount < mMinimalInputFluids) return null; - } - if (mMinimalInputItems > 0) { - if (aInputs == null) return null; - int tAmount = 0; - for (ItemStack aInput : aInputs) if (aInput != null) ++tAmount; - if (tAmount < mMinimalInputItems) return null; - } - } - - List recipes = new ArrayList<>(); - if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); - - if (aRecipe != null && !aRecipe.mFakeRecipe - && aRecipe.mCanBeBuffered - && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - if (aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt - && aRecipe.minDistance <= distance - && aRecipe.maxDistance >= distance - && aRecipe.mSpecialValue <= moduleTier) { - recipes.add(aRecipe); - } - } else { - if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) if (tStack != null) { - Collection tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); - if (tRecipes != null) for (GT_Recipe recipe : tRecipes) { - IG_Recipe.IG_SpaceMiningRecipe tRecipe = (IG_Recipe.IG_SpaceMiningRecipe) recipe; - if (!tRecipe.mFakeRecipe && tRecipe - .isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - if (tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt - && tRecipe.minDistance <= distance - && tRecipe.maxDistance >= distance - && tRecipe.mSpecialValue <= moduleTier) { - recipes.add(tRecipe); - } - } - } - - tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack, true)); - if (tRecipes != null) for (GT_Recipe recipe : tRecipes) { - IG_Recipe.IG_SpaceMiningRecipe tRecipe = (IG_Recipe.IG_SpaceMiningRecipe) recipe; - if (!tRecipe.mFakeRecipe && tRecipe - .isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - if (tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt - && tRecipe.minDistance <= distance - && tRecipe.maxDistance >= distance - && tRecipe.mSpecialValue <= moduleTier) { - recipes.add(tRecipe); - } - } - } - } - - if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids) if (aFluid != null) { - Collection tRecipes = mRecipeFluidMap.get(aFluid.getFluid().getName()); - if (tRecipes != null) for (GT_Recipe recipe : tRecipes) { - IG_Recipe.IG_SpaceMiningRecipe tRecipe = (IG_Recipe.IG_SpaceMiningRecipe) recipe; - if (!tRecipe.mFakeRecipe && tRecipe - .isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - if (tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt - && tRecipe.minDistance <= distance - && tRecipe.maxDistance >= distance - && tRecipe.mSpecialValue <= moduleTier) { - recipes.add(tRecipe); - } - } - } - } - } - return recipes; - } -} diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/MachineRecipes.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/MachineRecipes.java index 9c634c0..f91cc78 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/MachineRecipes.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/MachineRecipes.java @@ -2,7 +2,7 @@ import static gregtech.api.enums.GT_Values.RA; import static gregtech.api.enums.TickTime.MINUTE; -import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -135,7 +135,7 @@ public void run() { GT_OreDictUnificator.get(OrePrefixes.wireGt16, Materials.Graphene, 64)) .itemOutputs(new ItemStack(IGItems.SpaceElevatorItems, 1, 0)) .fluidInputs(Materials.AdvancedGlue.getFluid(720)).duration(1 * MINUTE).eut(TierEU.RECIPE_ZPM) - .requiresCleanRoom().noOptimize().addTo(sAssemblerRecipes); + .requiresCleanRoom().noOptimize().addTo(assemblerRecipes); // Space Elevator Cable TT_recipeAdder.addResearchableAssemblylineRecipe( @@ -352,7 +352,7 @@ public void run() { metaStableOgScrew_64, GT_OreDictUnificator.get(OrePrefixes.plateDouble, MaterialsUEVplus.TranscendentMetal, 16)) .itemOutputs(IGItems.SpaceElevatorModulePumpT2).fluidInputs(new FluidStack(solderUEV, 4608)) - .duration(2 * MINUTE).eut(TierEU.RECIPE_UIV).noOptimize().addTo(sAssemblerRecipes); + .duration(2 * MINUTE).eut(TierEU.RECIPE_UIV).noOptimize().addTo(assemblerRecipes); // Pump Module MK-III TT_recipeAdder.addResearchableAssemblylineRecipe( @@ -383,7 +383,7 @@ public void run() { GT_OreDictUnificator.get(OrePrefixes.screw, MaterialsUEVplus.WhiteDwarfMatter, 64), GT_OreDictUnificator.get(OrePrefixes.plateDouble, MaterialsUEVplus.Eternity, 16)) .itemOutputs(IGItems.SpaceElevatorModulePumpT3).fluidInputs(new FluidStack(solderUEV, 9216)) - .duration(2 * MINUTE).eut(TierEU.RECIPE_UIV).noOptimize().addTo(sAssemblerRecipes); + .duration(2 * MINUTE).eut(TierEU.RECIPE_UIV).noOptimize().addTo(assemblerRecipes); // Assembler Module MK-I TT_recipeAdder.addResearchableAssemblylineRecipe( @@ -568,7 +568,7 @@ highComputationStationT5_32, new ItemStack(quantumCircuit, 16), ItemList.Sensor_LV.get(8)) .itemOutputs(new ItemStack(IGItems.MiningDrones, 1, ItemMiningDrones.DroneTiers.LV.ordinal())) .fluidInputs(Materials.SolderingAlloy.getMolten(720)).duration(1 * MINUTE).eut(TierEU.RECIPE_LV) - .addTo(sAssemblerRecipes); + .addTo(assemblerRecipes); // MV RA.stdBuilder() @@ -582,7 +582,7 @@ highComputationStationT5_32, new ItemStack(quantumCircuit, 16), ItemList.Sensor_MV.get(8)) .itemOutputs(new ItemStack(IGItems.MiningDrones, 1, ItemMiningDrones.DroneTiers.MV.ordinal())) .fluidInputs(Materials.SolderingAlloy.getMolten(1440)).duration(1 * MINUTE).eut(TierEU.RECIPE_MV) - .addTo(sAssemblerRecipes); + .addTo(assemblerRecipes); // HV RA.stdBuilder() @@ -596,7 +596,7 @@ highComputationStationT5_32, new ItemStack(quantumCircuit, 16), ItemList.Sensor_HV.get(8)) .itemOutputs(new ItemStack(IGItems.MiningDrones, 1, ItemMiningDrones.DroneTiers.HV.ordinal())) .fluidInputs(Materials.SolderingAlloy.getMolten(1440)).duration(1 * MINUTE).eut(TierEU.RECIPE_HV) - .addTo(sAssemblerRecipes); + .addTo(assemblerRecipes); // EV TT_recipeAdder.addResearchableAssemblylineRecipe( diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceAssemblerFrontend.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceAssemblerFrontend.java new file mode 100644 index 0000000..ba6fbfc --- /dev/null +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceAssemblerFrontend.java @@ -0,0 +1,95 @@ +package com.gtnewhorizons.gtnhintergalactic.recipe.maps; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.Supplier; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.gtnewhorizons.gtnhintergalactic.recipe.IG_Recipe; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; + +import gregtech.api.gui.modularui.GT_UITextures; +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; +import gregtech.common.misc.spaceprojects.SpaceProjectManager; +import gregtech.nei.RecipeDisplayInfo; +import gregtech.nei.formatter.INEISpecialInfoFormatter; +import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class SpaceAssemblerFrontend extends RecipeMapFrontend { + + public SpaceAssemblerFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + uiPropertiesBuilder, + neiPropertiesBuilder.neiSpecialInfoFormatter(new SpaceAssemblerSpecialValueFormatter())); + } + + @Override + public List getItemInputPositions(int itemInputCount) { + return UIHelper.getGridPositions(itemInputCount, 16, 8, 4); + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return Collections.singletonList(new Pos2d(142, 8)); + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + return UIHelper.getGridPositions(fluidInputCount, 106, 8, 1); + } + + @Override + public void addProgressBar(ModularWindow.Builder builder, Supplier progressSupplier, Pos2d windowOffset) { + int bar1Width = 17; + int bar2Width = 18; + List> splitProgress = splitProgress(progressSupplier, bar1Width, bar2Width); + builder.widget( + new ProgressBar().setTexture(GT_UITextures.PROGRESSBAR_ASSEMBLY_LINE_1, 17) + .setDirection(ProgressBar.Direction.RIGHT).setProgress(splitProgress.get(0)) + .setSynced(false, false).setPos(new Pos2d(88, 8).add(windowOffset)).setSize(bar1Width, 72)); + builder.widget( + new ProgressBar().setTexture(GT_UITextures.PROGRESSBAR_ASSEMBLY_LINE_2, 18) + .setDirection(ProgressBar.Direction.RIGHT).setProgress(splitProgress.get(1)) + .setSynced(false, false).setPos(new Pos2d(124, 8).add(windowOffset)).setSize(bar2Width, 72)); + } + + private static class SpaceAssemblerSpecialValueFormatter implements INEISpecialInfoFormatter { + + @Override + public List format(RecipeDisplayInfo recipeInfo) { + List specialInfo = new ArrayList<>(); + specialInfo.add(GCCoreUtil.translateWithFormat("ig.nei.module", recipeInfo.recipe.mSpecialValue)); + if (recipeInfo.recipe instanceof IG_Recipe recipe) { + String neededProject = recipe.getNeededSpaceProject(); + String neededProjectLocation = recipe.getNeededSpaceProjectLocation(); + if (neededProject != null && !neededProject.isEmpty()) { + specialInfo.add( + String.format( + GCCoreUtil.translate("ig.nei.spaceassembler.project"), + SpaceProjectManager.getProject(neededProject).getLocalizedName())); + specialInfo.add( + String.format( + GCCoreUtil.translate("ig.nei.spaceassembler.projectAt"), + neededProjectLocation == null || neededProjectLocation.isEmpty() + ? GCCoreUtil.translate("ig.nei.spaceassembler.projectAnyLocation") + : GCCoreUtil.translate( + SpaceProjectManager.getLocation(neededProjectLocation) + .getUnlocalizedName()))); + } + } + return specialInfo; + } + } + +} diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceMiningFrontend.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceMiningFrontend.java new file mode 100644 index 0000000..a99abd9 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceMiningFrontend.java @@ -0,0 +1,78 @@ +package com.gtnewhorizons.gtnhintergalactic.recipe.maps; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.gtnewhorizons.gtnhintergalactic.recipe.IG_Recipe; +import com.gtnewhorizons.modularui.api.math.Pos2d; + +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.common.gui.modularui.UIHelper; +import gregtech.nei.RecipeDisplayInfo; +import gregtech.nei.formatter.INEISpecialInfoFormatter; +import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class SpaceMiningFrontend extends RecipeMapFrontend { + + public SpaceMiningFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + uiPropertiesBuilder, + neiPropertiesBuilder.neiSpecialInfoFormatter(new SpaceMiningSpecialValueFormatter())); + } + + @Override + public List getItemInputPositions(int itemInputCount) { + List results = new ArrayList<>(); + // assume drones are present on first input + results.add(new Pos2d(143, 15)); + results.addAll(UIHelper.getGridPositions(itemInputCount - 1, 10, 6, 2)); + return results; + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return UIHelper.getGridPositions(itemOutputCount, 69, 6, 4); + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + return UIHelper.getGridPositions(fluidInputCount, 10, 51, fluidInputCount); + } + + private static class SpaceMiningSpecialValueFormatter implements INEISpecialInfoFormatter { + + @Override + public List format(RecipeDisplayInfo recipeInfo) { + List result = new ArrayList<>(); + result.add(GCCoreUtil.translateWithFormat("ig.nei.module", recipeInfo.recipe.mSpecialValue)); + if (recipeInfo.recipe instanceof IG_Recipe.IG_SpaceMiningRecipe miningRecipe) { + result.add( + GCCoreUtil.translate("ig.nei.spacemining.distance") + " " + + miningRecipe.minDistance + + "-" + + miningRecipe.maxDistance); + result.add( + GCCoreUtil.translate("ig.nei.spacemining.size") + " " + + miningRecipe.minSize + + "-" + + miningRecipe.maxSize); + result.add( + GCCoreUtil.translateWithFormat( + "tt.nei.research.min_computation", + GT_Utility.formatNumbers(miningRecipe.computation))); + result.add(GCCoreUtil.translate("ig.nei.spacemining.weight") + " " + miningRecipe.recipeWeight); + } + return result; + } + } + +} diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceResearchFrontend.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceResearchFrontend.java new file mode 100644 index 0000000..a3e6274 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/recipe/maps/SpaceResearchFrontend.java @@ -0,0 +1,84 @@ +package com.gtnewhorizons.gtnhintergalactic.recipe.maps; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.gtnewhorizons.gtnhintergalactic.recipe.IG_Recipe; +import com.gtnewhorizons.modularui.api.math.Pos2d; + +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; +import gregtech.common.misc.spaceprojects.SpaceProjectManager; +import gregtech.nei.RecipeDisplayInfo; +import gregtech.nei.formatter.INEISpecialInfoFormatter; +import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class SpaceResearchFrontend extends RecipeMapFrontend { + + public SpaceResearchFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + uiPropertiesBuilder, + neiPropertiesBuilder.neiSpecialInfoFormatter(new SpaceResearchSpecialValueFormatter())); + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return Collections.singletonList(new Pos2d(142, 35)); + } + + @Override + public List getItemInputPositions(int itemInputCount) { + List inputPositions = new ArrayList<>(); + inputPositions.add(new Pos2d(80, 35)); + inputPositions.add(new Pos2d(62, 8)); + inputPositions.add(new Pos2d(80, 8)); + inputPositions.add(new Pos2d(98, 8)); + inputPositions.add(new Pos2d(62, 60)); + inputPositions.add(new Pos2d(80, 60)); + inputPositions.add(new Pos2d(98, 60)); + return inputPositions; + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + return UIHelper.getGridPositions(fluidInputCount, 34, 17, 1); + } + + private static class SpaceResearchSpecialValueFormatter implements INEISpecialInfoFormatter { + + @Override + public List format(RecipeDisplayInfo recipeInfo) { + List specialInfo = new ArrayList<>(); + specialInfo.add( + GCCoreUtil.translateWithFormat("tt.nei.research.min_computation", recipeInfo.recipe.mSpecialValue)); + if (recipeInfo.recipe instanceof IG_Recipe recipe) { + String neededProject = recipe.getNeededSpaceProject(); + String neededProjectLocation = recipe.getNeededSpaceProjectLocation(); + if (neededProject != null && !neededProject.isEmpty()) { + specialInfo.add( + String.format( + GCCoreUtil.translate("ig.nei.spaceassembler.project"), + SpaceProjectManager.getProject(neededProject).getLocalizedName())); + specialInfo.add( + String.format( + GCCoreUtil.translate("ig.nei.spaceassembler.projectAt"), + neededProjectLocation == null || neededProjectLocation.isEmpty() + ? GCCoreUtil.translate("ig.nei.spaceassembler.projectAnyLocation") + : GCCoreUtil.translate( + SpaceProjectManager.getLocation(neededProjectLocation) + .getUnlocalizedName()))); + } + } + return specialInfo; + } + } +} diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/ModuleOverclockDescriber.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/ModuleOverclockDescriber.java new file mode 100644 index 0000000..daa9f79 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/ModuleOverclockDescriber.java @@ -0,0 +1,34 @@ +package com.gtnewhorizons.gtnhintergalactic.tile.multi.elevatormodules; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.enums.GT_Values; +import gregtech.api.objects.overclockdescriber.EUNoOverclockDescriber; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.MethodsReturnNonnullByDefault; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class ModuleOverclockDescriber extends EUNoOverclockDescriber { + + private final int moduleTier; + + public ModuleOverclockDescriber(byte tier, int moduleTier) { + super(tier, 1); + this.moduleTier = moduleTier; + } + + @Nonnull + @Override + public String getTierString() { + return GT_Values.TIER_COLORS[tier] + "MK " + moduleTier + EnumChatFormatting.RESET; + } + + @Override + public boolean canHandle(GT_Recipe recipe) { + return super.canHandle(recipe) && this.moduleTier >= recipe.mSpecialValue; + } +} diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleAssembler.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleAssembler.java index 9ce289b..69f5cd0 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleAssembler.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleAssembler.java @@ -16,26 +16,26 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import com.gtnewhorizons.gtnhintergalactic.Tags; +import com.gtnewhorizons.gtnhintergalactic.recipe.IGRecipeMaps; import com.gtnewhorizons.gtnhintergalactic.recipe.IG_Recipe; -import com.gtnewhorizons.gtnhintergalactic.recipe.IG_RecipeAdder; import com.gtnewhorizons.gtnhintergalactic.recipe.ResultNoSpaceProject; import com.gtnewhorizons.gtnhintergalactic.tile.multi.elevator.ElevatorUtil; import com.gtnewhorizons.gtnhintergalactic.tile.multi.elevator.TileEntitySpaceElevator; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IOverclockDescriptionProvider; import gregtech.api.logic.ProcessingLogic; +import gregtech.api.objects.overclockdescriber.OverclockDescriber; +import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; -import gregtech.common.power.BasicMachineEUPower; -import gregtech.common.power.Power; import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; /** @@ -43,7 +43,7 @@ * * @author minecraft7771 */ -public abstract class TileEntityModuleAssembler extends TileEntityModuleBase { +public abstract class TileEntityModuleAssembler extends TileEntityModuleBase implements IOverclockDescriptionProvider { /** Name of the parallel setting */ private static final INameFunction PARALLEL_SETTING_NAME = (base, p) -> GCCoreUtil @@ -53,7 +53,7 @@ public abstract class TileEntityModuleAssembler extends TileEntityModuleBase { .fromLimitsInclusiveOuterBoundary(p.get(), 0, 1, 100, base.getMaxParallels()); /** Power object used for displaying in NEI */ - protected final Power power; + protected final OverclockDescriber overclockDescriber; /** Input parameters */ Parameters.Group.ParameterIn parallelSetting; @@ -71,7 +71,7 @@ public abstract class TileEntityModuleAssembler extends TileEntityModuleBase { public TileEntityModuleAssembler(int aID, String aName, String aNameRegional, int tTier, int tModuleTier, int tMinMotorTier, int bufferSizeMultiplier) { super(aID, aName, aNameRegional, tTier, tModuleTier, tMinMotorTier, bufferSizeMultiplier); - power = new AssemblerPower((byte) tTier, tModuleTier); + overclockDescriber = new ModuleOverclockDescriber((byte) tTier, tModuleTier); } /** @@ -86,7 +86,7 @@ public TileEntityModuleAssembler(int aID, String aName, String aNameRegional, in public TileEntityModuleAssembler(String aName, int tTier, int tModuleTier, int tMinMotorTier, int bufferSizeMultiplier) { super(aName, tTier, tModuleTier, tMinMotorTier, bufferSizeMultiplier); - power = new AssemblerPower((byte) tTier, tModuleTier); + overclockDescriber = new ModuleOverclockDescriber((byte) tTier, tModuleTier); } /** @@ -98,16 +98,16 @@ public TileEntityModuleAssembler(String aName, int tTier, int tModuleTier, int t * @return Power object used for displaying in NEI */ @Override - public Power getPower() { - return power; + public OverclockDescriber getOverclockDescriber() { + return overclockDescriber; } /** * @return The recipe map of this machine */ @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return IG_RecipeAdder.instance.sSpaceAssemblerRecipes; + public RecipeMap getRecipeMap() { + return IGRecipeMaps.spaceAssemblerRecipes; } /** @@ -204,30 +204,6 @@ public boolean protectsExcessFluid() { return !eSafeVoid; } - /** - * Power object used to display the assembler in NEI - */ - private static class AssemblerPower extends BasicMachineEUPower { - - /** - * Create a new power object for assembler modules - * - * @param tier Voltage tier of the miner - * @param moduleTier Module tier of the miner - */ - public AssemblerPower(byte tier, int moduleTier) { - super(tier, 1, moduleTier); - } - - /** - * @return Tiered string which will be displayed, if this module tier is selected - */ - @Override - public String getTierString() { - return GT_Values.TIER_COLORS[tier] + "MK " + specialValue + EnumChatFormatting.RESET; - } - } - /** * Space Assembler project module T1 of the Space Elevator * diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleManager.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleManager.java index 64c81cc..1769b75 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleManager.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleManager.java @@ -45,6 +45,8 @@ import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.recipe.check.SimpleCheckRecipeResult; @@ -148,6 +150,11 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new TileEntityModuleManager(mName); } + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.spaceProjectFakeRecipes; + } + @Override public @NotNull CheckRecipeResult checkProcessing_EM() { if (projectWorkingOn == null) { @@ -816,7 +823,7 @@ private void generateUpgrades(MultiChildWidget projectDetails) { private void generateUpgradeCost(MultiChildWidget projectDetails) { final DynamicPositionedColumn activeUpgradeItemsAndFluids = new DynamicPositionedColumn(); final DynamicPositionedColumn activeUpgradeCosts = new DynamicPositionedColumn(); - for (int i = 0; i < GT_Recipe.GT_Recipe_Map.sFakeSpaceProjectRecipes.mUsualInputCount; i++) { + for (int i = 0; i < RecipeMaps.spaceProjectFakeRecipes.getFrontend().getUIProperties().maxItemInputs; i++) { int index = i; activeUpgradeItemsAndFluids.addChild( new ItemDrawable(() -> selectedUpgrade != null ? selectedUpgrade.getItemCostPerStage(index) : null) @@ -840,7 +847,7 @@ private void generateUpgradeCost(MultiChildWidget projectDetails) { widget -> selectedUpgrade != null && selectedUpgrade.getItemCostPerStage(index) != null)); } - for (int i = 0; i < GT_Recipe.GT_Recipe_Map.sFakeSpaceProjectRecipes.getUsualFluidInputCount(); i++) { + for (int i = 0; i < RecipeMaps.spaceProjectFakeRecipes.getFrontend().getUIProperties().maxFluidInputs; i++) { int index = i; activeUpgradeItemsAndFluids.addChild( new FluidDrawable() @@ -860,7 +867,7 @@ private void generateUpgradeCost(MultiChildWidget projectDetails) { widget -> selectedUpgrade != null && selectedUpgrade.getFluidCostPerStage(index) != null)); } - for (int i = 0; i < GT_Recipe.GT_Recipe_Map.sFakeSpaceProjectRecipes.mUsualInputCount; i++) { + for (int i = 0; i < RecipeMaps.spaceProjectFakeRecipes.getFrontend().getUIProperties().maxItemInputs; i++) { int index = i; activeUpgradeCosts.addChild( TextWidget.dynamicString( diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleMiner.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleMiner.java index ff08a0c..4ca64e3 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleMiner.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleMiner.java @@ -8,6 +8,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.stream.Collectors; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -30,8 +31,8 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import com.gtnewhorizons.gtnhintergalactic.Tags; import com.gtnewhorizons.gtnhintergalactic.gui.IG_UITextures; +import com.gtnewhorizons.gtnhintergalactic.recipe.IGRecipeMaps; import com.gtnewhorizons.gtnhintergalactic.recipe.IG_Recipe; -import com.gtnewhorizons.gtnhintergalactic.recipe.IG_RecipeAdder; import com.gtnewhorizons.gtnhintergalactic.spaceprojects.ProjectAsteroidOutpost; import com.gtnewhorizons.gtnhintergalactic.tile.multi.elevator.TileEntitySpaceElevator; import com.gtnewhorizons.modularui.api.drawable.IDrawable; @@ -55,7 +56,10 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IOverclockDescriptionProvider; import gregtech.api.objects.XSTR; +import gregtech.api.objects.overclockdescriber.OverclockDescriber; +import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.recipe.check.SimpleCheckRecipeResult; @@ -64,11 +68,9 @@ import gregtech.common.misc.spaceprojects.SpaceProjectManager; import gregtech.common.misc.spaceprojects.enums.SolarSystem; import gregtech.common.misc.spaceprojects.interfaces.ISpaceProject; -import gregtech.common.power.BasicMachineEUPower; -import gregtech.common.power.Power; import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; -public abstract class TileEntityModuleMiner extends TileEntityModuleBase { +public abstract class TileEntityModuleMiner extends TileEntityModuleBase implements IOverclockDescriptionProvider { /** Base chance to get a bonus stack from space mining, will be multiplied with other factors */ protected static int BONUS_STACK_BASE_CHANCE = 5000; @@ -151,7 +153,7 @@ public abstract class TileEntityModuleMiner extends TileEntityModuleBase { // endregion /** Power object used for displaying in NEI */ - protected final Power power; + protected final OverclockDescriber overclockDescriber; /** Asteroid outpost that the player can additionally build */ protected ProjectAsteroidOutpost asteroidOutpost; @@ -176,7 +178,7 @@ public abstract class TileEntityModuleMiner extends TileEntityModuleBase { public TileEntityModuleMiner(int aID, String aName, String aNameRegional, int tTier, int tModuleTier, int tMinMotorTier) { super(aID, aName, aNameRegional, tTier, tModuleTier, tMinMotorTier); - power = new MinerPower((byte) tTier, tModuleTier); + overclockDescriber = new ModuleOverclockDescriber((byte) tTier, tModuleTier); } /** @@ -189,15 +191,12 @@ public TileEntityModuleMiner(int aID, String aName, String aNameRegional, int tT */ public TileEntityModuleMiner(String aName, int tTier, int tModuleTier, int tMinMotorTier) { super(aName, tTier, tModuleTier, tMinMotorTier); - power = new MinerPower((byte) tTier, tModuleTier); + overclockDescriber = new ModuleOverclockDescriber((byte) tTier, tModuleTier); } - /** - * @return Power object used for displaying in NEI - */ @Override - public Power getPower() { - return power; + public OverclockDescriber getOverclockDescriber() { + return overclockDescriber; } /** @@ -229,6 +228,11 @@ public void saveNBTData(NBTTagCompound aNBT) { } } + @Override + public RecipeMap getRecipeMap() { + return IGRecipeMaps.spaceMiningRecipes; + } + /** * Check if any recipe can be started with the given inputs * @@ -291,20 +295,18 @@ public CheckRecipeResult process(ItemStack[] inputs, FluidStack[] fluidInputs, i // Get all asteroid pools that this drone can pull from long tVoltage = getMaxInputVoltage(); - List recipes = IG_RecipeAdder.instance.sSpaceMiningRecipes.findRecipes( - getBaseMetaTileEntity(), - null, - false, - false, - tVoltage, - fluidInputs, - null, - (int) distanceDisplay.get(), - tModuleTier, - inputs); + int distance = (int) distanceDisplay.get(); + List recipes = IGRecipeMaps.spaceMiningRecipes.findRecipeQuery().items(inputs) + .fluids(fluidInputs).voltage(tVoltage).findAll() + .filter(IG_Recipe.IG_SpaceMiningRecipe.class::isInstance) + .map(IG_Recipe.IG_SpaceMiningRecipe.class::cast) + .filter( + recipe -> recipe.minDistance <= distance && recipe.maxDistance >= distance + && recipe.mSpecialValue <= tModuleTier) + .collect(Collectors.toList()); // Return if no recipe was found - if (recipes == null || recipes.size() <= 0) { + if (recipes.isEmpty()) { return CheckRecipeResultRegistry.NO_RECIPE; } @@ -342,7 +344,7 @@ public CheckRecipeResult process(ItemStack[] inputs, FluidStack[] fluidInputs, i // Check how many parallels we can actually do, return if none GT_ParallelHelper helper = new GT_ParallelHelper().setMaxParallel(maxParallels).setRecipe(tRecipe) .setFluidInputs(fluidInputs).setItemInputs(inputs).setAvailableEUt(GT_Values.V[tTier]) - .setMachine(this, false, false).enableConsumption().build(); + .setMachine(this, false, false).setConsumption(true).build(); int parallels = helper.getCurrentParallel(); if (parallels <= 0) { return CheckRecipeResultRegistry.NO_RECIPE; @@ -737,43 +739,6 @@ public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStac return true; } - /** - * Power object used to display the miners in NEI - */ - private static class MinerPower extends BasicMachineEUPower { - - /** - * Create a new power object for mining modules - * - * @param tier Voltage tier of the miner - * @param moduleTier Module tier of the miner - */ - public MinerPower(byte tier, int moduleTier) { - super(tier, 1, moduleTier); - } - - /** - * Calculate the power usage for a given recipe with the specific miner tier - * - * @param euPerTick EU consumption of the recipe - * @param duration Duration of the recipe - */ - @Override - public void computePowerUsageAndDuration(int euPerTick, int duration) { - originalVoltage = computeVoltageForEuRate(euPerTick); - recipeEuPerTick = euPerTick; - recipeDuration = duration; - } - - /** - * @return Tiered string which will be displayed, if this module tier is selected - */ - @Override - public String getTierString() { - return GT_Values.TIER_COLORS[tier] + "MK " + specialValue + EnumChatFormatting.RESET; - } - } - /** * Space Miner project module T1 of the Space Elevator * diff --git a/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleResearch.java b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleResearch.java index cae99ee..1cf0c96 100644 --- a/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleResearch.java +++ b/src/main/java/com/gtnewhorizons/gtnhintergalactic/tile/multi/elevatormodules/TileEntityModuleResearch.java @@ -8,14 +8,15 @@ import org.jetbrains.annotations.NotNull; import com.gtnewhorizons.gtnhintergalactic.Tags; +import com.gtnewhorizons.gtnhintergalactic.recipe.IGRecipeMaps; import com.gtnewhorizons.gtnhintergalactic.recipe.IG_Recipe; -import com.gtnewhorizons.gtnhintergalactic.recipe.IG_RecipeAdder; import com.gtnewhorizons.gtnhintergalactic.recipe.ResultNoSpaceProject; import com.gtnewhorizons.gtnhintergalactic.tile.multi.elevator.ElevatorUtil; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -96,8 +97,8 @@ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { * @return The recipe map of this machine */ @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return IG_RecipeAdder.instance.sSpaceResearchRecipes; + public RecipeMap getRecipeMap() { + return IGRecipeMaps.spaceResearchRecipes; } /** diff --git a/src/main/resources/assets/gtnhintergalactic/lang/en_US.lang b/src/main/resources/assets/gtnhintergalactic/lang/en_US.lang index 9d02f8a..18fa1ff 100644 --- a/src/main/resources/assets/gtnhintergalactic/lang/en_US.lang +++ b/src/main/resources/assets/gtnhintergalactic/lang/en_US.lang @@ -246,19 +246,18 @@ gt.blockmachines.multimachine.project.ig.research.t1.name=Space Research Module gt.blockmachines.multimachine.project.ig.research.desc0=Module that allows you to research stellar objects gt.blockmachines.multimachine.project.ig.research.desc1=Don't look directly into the sun +# RecipeMaps +gt.recipe.spaceMining=Space Mining +gt.recipe.spaceAssembler=Space Assembler +gt.recipe.spaceResearch=Space Research + # NEI -ig.nei.spacemining.name=Space Mining -ig.nei.spaceassembler.name=Space Assembler -ig.nei.spaceresearch.name=Space Research ig.nei.spaceassembler.project=Needs %s ig.nei.spaceassembler.projectAt=at %s ig.nei.spaceassembler.projectAnyLocation=any location -ig.nei.spacemining.specialValue.0=Needs MK- -ig.nei.spacemining.specialValue.1= Module +ig.nei.module=Needs MK-%s Module ig.nei.spacemining.distance=Distance: ig.nei.spacemining.size=Size: -ig.nei.spacemining.computationPrefix=Min Computation: -ig.nei.spacemining.computationSuffix=/s ig.nei.spacemining.weight=Weight: ig.nei.elevatorpump.name=Space Pumping Module ig.nei.elevatorpump.planettype=Planet