From 7564ddb03bd84ee91213025a62ec5d35ad34c4ba Mon Sep 17 00:00:00 2001 From: miozune Date: Fri, 10 Nov 2023 16:12:05 +0900 Subject: [PATCH] Migrate to new RecipeMap --- .gitignore | 11 +- dependencies.gradle | 2 +- .../com/github/technus/tectech/TecTech.java | 4 +- .../technus/tectech/loader/MainLoader.java | 3 +- .../github/technus/tectech/nei/IMCForNEI.java | 45 -- .../technus/tectech/nei/NEI_TT_Config.java | 35 -- .../nei/TT_NEI_EyeOfHarmonyHandler.java | 33 -- .../tectech/nei/TT_NEI_ResearchHandler.java | 358 ---------------- .../tectech/nei/TT_NEI_ScannerHandler.java | 358 ---------------- .../tectech/recipe/EyeOfHarmonyFrontend.java | 202 +++++++++ .../recipe/EyeOfHarmonyRecipeStorage.java | 4 +- .../recipe/ResearchStationFrontend.java | 94 ++++ .../technus/tectech/recipe/TT_recipe.java | 403 ------------------ .../tectech/recipe/TT_recipeAdder.java | 13 +- .../tectech/recipe/TecTechRecipeMaps.java | 49 +++ .../tectech/thing/gui/TecTechUITextures.java | 8 + .../GT_MetaTileEntity_EM_EyeOfHarmony.java | 8 + .../multi/GT_MetaTileEntity_EM_research.java | 75 +--- .../multi/GT_MetaTileEntity_TM_microwave.java | 3 +- .../GT_MetaTileEntity_MultiblockBase_EM.java | 9 - .../gui/multimachines/ResearchFake.png | Bin 1972 -> 0 bytes .../resources/assets/tectech/lang/en_US.lang | 12 + .../textures/gui/picture/rack_large.png | Bin 166 -> 332 bytes .../gui/progressbar/research_station_1.png | Bin 0 -> 114 bytes .../gui/progressbar/research_station_2.png | Bin 0 -> 172 bytes .../gui/progressbar/research_station_3.png | Bin 0 -> 281 bytes 26 files changed, 403 insertions(+), 1326 deletions(-) delete mode 100644 src/main/java/com/github/technus/tectech/nei/IMCForNEI.java delete mode 100644 src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java delete mode 100644 src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java delete mode 100644 src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java delete mode 100644 src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyFrontend.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/ResearchStationFrontend.java delete mode 100644 src/main/java/com/github/technus/tectech/recipe/TT_recipe.java create mode 100644 src/main/java/com/github/technus/tectech/recipe/TecTechRecipeMaps.java delete mode 100644 src/main/resources/assets/gregtech/textures/gui/multimachines/ResearchFake.png create mode 100644 src/main/resources/assets/tectech/textures/gui/progressbar/research_station_1.png create mode 100644 src/main/resources/assets/tectech/textures/gui/progressbar/research_station_2.png create mode 100644 src/main/resources/assets/tectech/textures/gui/progressbar/research_station_3.png diff --git a/.gitignore b/.gitignore index 3274a536d..27a8ae0f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .gradle .settings /.idea/ +/.vscode/ /run/ /build/ /eclipse/ @@ -25,7 +26,13 @@ whitelist.json *.iml *.ipr *.iws -src/main/resources/mixins.*.json +src/main/resources/mixins.*([!.]).json *.bat -.vscode/settings.json +*.DS_Store +!gradlew.bat .factorypath +addon.local.gradle +addon.local.gradle.kts +addon.late.local.gradle +addon.late.local.gradle.kts +layout.json \ No newline at end of file diff --git a/dependencies.gradle b/dependencies.gradle index 82674050a..7e2763753 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ dependencies { shadowImplementation('com.github.GTNewHorizons:AVRcore:1.0.1') - api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.90:dev') + api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.92-pre:dev') api('com.github.GTNewHorizons:Yamcl:0.5.86:dev') implementation('com.github.GTNewHorizons:GTNEIOrePlugin:1.1.3:dev') diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 292ebeb7e..0845e0273 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -9,9 +9,9 @@ import com.github.technus.tectech.loader.TecTechConfig; import com.github.technus.tectech.loader.gui.CreativeTabTecTech; import com.github.technus.tectech.mechanics.enderStorage.EnderWorldSavedData; -import com.github.technus.tectech.nei.IMCForNEI; import com.github.technus.tectech.proxy.CommonProxy; import com.github.technus.tectech.recipe.EyeOfHarmonyRecipeStorage; +import com.github.technus.tectech.recipe.TecTechRecipeMaps; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; @@ -85,6 +85,7 @@ public void PreLoad(FMLPreInitializationEvent PreEvent) { FMLCommonHandler.instance().bus().register(enderWorldSavedData); MinecraftForge.EVENT_BUS.register(enderWorldSavedData); + TecTechRecipeMaps.init(); MainLoader.preLoad(); } @@ -95,7 +96,6 @@ public void Load(FMLInitializationEvent event) { MainLoader.load(); MainLoader.addAfterGregTechPostLoadRunner(); - IMCForNEI.IMCSender(); } @Mod.EventHandler diff --git a/src/main/java/com/github/technus/tectech/loader/MainLoader.java b/src/main/java/com/github/technus/tectech/loader/MainLoader.java index d4e436157..6ee6988ce 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -25,6 +25,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; +import gregtech.api.recipe.RecipeMaps; import gregtech.api.util.GT_Recipe; @SuppressWarnings("deprecation") @@ -143,7 +144,7 @@ private static void FixBrokenFusionRecipes() { } } } - for (GT_Recipe r : GT_Recipe.GT_Recipe_Map.sFusionRecipes.mRecipeList) { + for (GT_Recipe r : RecipeMaps.fusionRecipes.getAllRecipes()) { Fluid fluid = binds.get(r.mFluidOutputs[0].getFluid()); if (fluid != null) { if (DEBUG_MODE) { diff --git a/src/main/java/com/github/technus/tectech/nei/IMCForNEI.java b/src/main/java/com/github/technus/tectech/nei/IMCForNEI.java deleted file mode 100644 index 033882609..000000000 --- a/src/main/java/com/github/technus/tectech/nei/IMCForNEI.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.technus.tectech.nei; - -import static com.github.technus.tectech.Reference.MODID; -import static gregtech.api.enums.Mods.NotEnoughItems; - -import net.minecraft.nbt.NBTTagCompound; - -import cpw.mods.fml.common.event.FMLInterModComms; - -public class IMCForNEI { - - public static void IMCSender() { - if (!NotEnoughItems.isModLoaded()) { - return; - } - sendHandler("gt.recipe.eyeofharmony", "gregtech:gt.blockmachines:15410", 1); - sendCatalyst("gt.recipe.eyeofharmony", "gregtech:gt.blockmachines:15410"); - } - - private static void sendHandler(String aName, String aBlock, int aMaxRecipesPerPage) { - NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setString("handler", aName); - aNBT.setString("modName", MODID); - aNBT.setString("modId", MODID); - aNBT.setBoolean("modRequired", true); - aNBT.setString("itemName", aBlock); - aNBT.setInteger("handlerHeight", 135); - aNBT.setInteger("handlerWidth", 166); - aNBT.setInteger("maxRecipesPerPage", aMaxRecipesPerPage); - aNBT.setInteger("yShift", 6); - FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT); - } - - private static void sendCatalyst(String aName, String aStack, int aPriority) { - NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setString("handlerID", aName); - aNBT.setString("itemName", aStack); - aNBT.setInteger("priority", aPriority); - FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT); - } - - private static void sendCatalyst(String aName, String aStack) { - sendCatalyst(aName, aStack, 0); - } -} diff --git a/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java b/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java deleted file mode 100644 index 1523302a2..000000000 --- a/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.github.technus.tectech.nei; - -import com.github.technus.tectech.recipe.TT_recipe; - -import codechicken.nei.api.IConfigureNEI; -import cpw.mods.fml.common.FMLCommonHandler; - -public class NEI_TT_Config implements IConfigureNEI { // must be NEI*Config - - public static boolean sIsAdded = true; - public static TT_NEI_ResearchHandler TT_RH; - public static TT_NEI_ScannerHandler TT_SH; - public static TT_NEI_EyeOfHarmonyHandler TT_EOH; - - @Override - public void loadConfig() { - sIsAdded = false; - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { - TT_RH = new TT_NEI_ResearchHandler(TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes); - TT_SH = new TT_NEI_ScannerHandler(TT_recipe.GT_Recipe_MapTT.sScannableFakeRecipes); - TT_EOH = new TT_NEI_EyeOfHarmonyHandler(TT_recipe.GT_Recipe_MapTT.sEyeofHarmonyRecipes); - } - sIsAdded = true; - } - - @Override - public String getName() { - return "TecTech NEI Plugin"; - } - - @Override - public String getVersion() { - return "(1.0)"; - } -} diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java deleted file mode 100644 index 7d8e98244..000000000 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_EyeOfHarmonyHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.github.technus.tectech.nei; - -import static com.github.technus.tectech.Reference.MODID; - -import codechicken.nei.recipe.GuiCraftingRecipe; -import codechicken.nei.recipe.GuiUsageRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; -import cpw.mods.fml.common.event.FMLInterModComms; -import gregtech.api.enums.GT_Values; -import gregtech.api.util.GT_Recipe; -import gregtech.nei.GT_NEI_DefaultHandler; - -public class TT_NEI_EyeOfHarmonyHandler extends GT_NEI_DefaultHandler { - - public TT_NEI_EyeOfHarmonyHandler(final GT_Recipe.GT_Recipe_Map tMap) { - super(tMap); - if (!NEI_TT_Config.sIsAdded) { - - FMLInterModComms.sendRuntimeMessage( - GT_Values.GT, - "NEIPlugins", - "register-crafting-handler", - MODID + "@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); - GuiCraftingRecipe.craftinghandlers.add(this); - GuiUsageRecipe.usagehandlers.add(this); - } - } - - @Override - public TemplateRecipeHandler newInstance() { - return new TT_NEI_EyeOfHarmonyHandler(this.mRecipeMap); - } -} diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java deleted file mode 100644 index e87350b2b..000000000 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java +++ /dev/null @@ -1,358 +0,0 @@ -package com.github.technus.tectech.nei; - -import static com.github.technus.tectech.recipe.TT_recipeAdder.nullItem; -import static gregtech.api.enums.ItemList.Display_Fluid; - -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - -import com.github.technus.tectech.Reference; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.recipe.TT_recipe; - -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.ItemList; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiCraftingRecipe; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.GuiUsageRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; -import cpw.mods.fml.common.event.FMLInterModComms; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.objects.ItemData; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; - -public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { - - protected final TT_recipe.GT_Recipe_MapTT mRecipeMap; - - public TT_NEI_ResearchHandler(TT_recipe.GT_Recipe_MapTT aRecipeMap) { - mRecipeMap = aRecipeMap; - transferRects.add( - new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); - if (!NEI_TT_Config.sIsAdded) { - FMLInterModComms.sendRuntimeMessage( - TecTech.instance, - "NEIPlugins", - "register-crafting-handler", - Reference.MODID + '@' + getRecipeName() + '@' + getOverlayIdentifier()); - GuiCraftingRecipe.craftinghandlers.add(this); - GuiUsageRecipe.usagehandlers.add(this); - } - } - - public List getSortedRecipes() { - List result = new ArrayList<>(mRecipeMap.mRecipeList); - Collections.sort(result); - return result; - } - - public static void drawText(int aX, int aY, String aString, int aColor) { - Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); - } - - @Override - public TemplateRecipeHandler newInstance() { - NEI_TT_Config.TT_RH = new TT_NEI_ResearchHandler(mRecipeMap); - return NEI_TT_Config.TT_RH; - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOverlayIdentifier())) { - for (GT_Recipe tRecipe : getSortedRecipes()) { - if (!tRecipe.mHidden) { - arecipes.add(new CachedDefaultRecipe(tRecipe)); - } - } - } else { - super.loadCraftingRecipes(outputId, results); - } - } - - @Override - public void loadCraftingRecipes(ItemStack aResult) { - ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); - - ArrayList tResults = new ArrayList<>(); - tResults.add(aResult); - tResults.add(GT_OreDictUnificator.get(true, aResult)); - if (tPrefixMaterial != null && !tPrefixMaterial.mBlackListed - && !tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty()) { - for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { - tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); - } - } - FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); - if (tFluid != null) { - tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); - for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry - .getRegisteredFluidContainerData()) { - if (tData.fluid.isFluidEqual(tFluid)) { - tResults.add(GT_Utility.copy(tData.filledContainer)); - } - } - } - for (GT_Recipe tRecipe : getSortedRecipes()) { - if (!tRecipe.mHidden) { - CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); - for (ItemStack tStack : tResults) { - if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { - arecipes.add(tNEIRecipe); - break; - } - } - } - } - } - - @Override - public void loadUsageRecipes(ItemStack aInput) { - ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); - - ArrayList tInputs = new ArrayList<>(); - tInputs.add(aInput); - tInputs.add(GT_OreDictUnificator.get(false, aInput)); - if (tPrefixMaterial != null && !tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty()) { - for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { - tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); - } - } - FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); - if (tFluid != null) { - tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); - for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry - .getRegisteredFluidContainerData()) { - if (tData.fluid.isFluidEqual(tFluid)) { - tInputs.add(GT_Utility.copy(tData.filledContainer)); - } - } - } - for (GT_Recipe tRecipe : getSortedRecipes()) { - if (!tRecipe.mHidden) { - CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); - for (ItemStack tStack : tInputs) { - if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { - arecipes.add(tNEIRecipe); - break; - } - } - } - } - } - - @Override - public String getOverlayIdentifier() { - return mRecipeMap.mNEIName; - } - - @Override - public void drawBackground(int recipe) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public String getRecipeName() { - return GT_LanguageManager.getTranslation(mRecipeMap.mUnlocalizedName); - } - - @Override - public String getGuiTexture() { - return mRecipeMap.mNEIGUIPath; - } - - @Override - public List handleItemTooltip(GuiRecipe gui, ItemStack aStack, List currenttip, - int aRecipeIndex) { - TemplateRecipeHandler.CachedRecipe tObject = arecipes.get(aRecipeIndex); - if (tObject instanceof CachedDefaultRecipe tRecipe) { - for (PositionedStack tStack : tRecipe.mOutputs) { - if (aStack == tStack.item) { - if (!(tStack instanceof FixedPositionedStack) || ((FixedPositionedStack) tStack).mChance <= 0 - || ((FixedPositionedStack) tStack).mChance == 10000) { - break; - } - currenttip.add( - trans("150", "Chance: ") + ((FixedPositionedStack) tStack).mChance / 100 - + '.' - + (((FixedPositionedStack) tStack).mChance % 100 < 10 - ? "0" + ((FixedPositionedStack) tStack).mChance % 100 - : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) - + '%'); - break; - } - } - for (PositionedStack tStack : tRecipe.mInputs) { - if (aStack == tStack.item) { - if (Display_Fluid.isStackEqual(tStack.item, true, true) || tStack.item.stackSize != 0) { - break; - } - currenttip.add(trans("151", "Does not get consumed in the process")); - break; - } - } - } - return currenttip; - } - - @Override - public void drawExtras(int aRecipeIndex) { - int tEUt = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mEUt; - int computation = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mDuration; - String[] recipeDesc = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); - if (recipeDesc == null) { - int tSpecial = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; - short ampere = (short) (tSpecial & 0xFFFF), minComputationPerSec = (short) (tSpecial >>> 16); - if (tEUt != 0) { - drawText( - 10, - 73, - trans("152.1", "Max EU: ") + GT_Utility.formatNumbers( - (1 + (computation - minComputationPerSec) / minComputationPerSec) * (long) tEUt - * ampere - * 20) - + " EU", - -16777216); - drawText( - 10, - 83, - trans("153", "Usage: ") + GT_Utility.formatNumbers((long) tEUt * ampere) + " EU/t", - -16777216); - if (mRecipeMap.mShowVoltageAmperageInNEI) { - drawText(10, 93, trans("154", "Voltage: ") + GT_Utility.formatNumbers(tEUt) + " EU", -16777216); - drawText(10, 103, trans("155", "Amperage: ") + GT_Utility.formatNumbers(ampere), -16777216); - } else { - drawText(10, 93, trans("156", "Voltage: unspecified"), -16777216); - drawText(10, 103, trans("157", "Amperage: unspecified"), -16777216); - } - } - drawText(10, 113, "Computation: " + GT_Utility.formatNumbers(computation), -16777216); - drawText(10, 123, "Min Computation: " + GT_Utility.formatNumbers(minComputationPerSec) + " /s", -16777216); - } else { - int i = 0; - for (String descLine : recipeDesc) { - drawText(10, 73 + 10 * i, descLine, -16777216); - i++; - } - } - } - - public static class FixedPositionedStack extends PositionedStack { - - public final int mChance; - public boolean permutated = false; - - public FixedPositionedStack(Object object, int x, int y) { - this(object, x, y, 0); - } - - public FixedPositionedStack(Object object, int x, int y, int aChance) { - super(object, x, y, true); - mChance = aChance; - } - - @Override - public void generatePermutations() { - if (permutated) { - return; - } - ArrayList tDisplayStacks = new ArrayList<>(); - for (ItemStack tStack : items) { - if (GT_Utility.isStackValid(tStack)) { - if (tStack.getItemDamage() == 32767) { - List permutations = ItemList.itemMap.get(tStack.getItem()); - if (!permutations.isEmpty()) { - ItemStack stack; - for (Iterator iterator = permutations.iterator(); iterator - .hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, stack))) { - stack = iterator.next(); - } - } else { - ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); - base.stackTagCompound = tStack.stackTagCompound; - tDisplayStacks.add(base); - } - } else { - tDisplayStacks.add(GT_Utility.copy(tStack)); - } - } - } - items = tDisplayStacks.toArray(nullItem); - if (items.length == 0) { - items = new ItemStack[] { new ItemStack(Blocks.fire) }; - } - permutated = true; - setPermutationToRender(0); - } - } - - public class CachedDefaultRecipe extends TemplateRecipeHandler.CachedRecipe { - - public final GT_Recipe mRecipe; - public final List mOutputs; - public final List mInputs; - - public CachedDefaultRecipe(GT_Recipe aRecipe) { - mRecipe = aRecipe; - - mOutputs = new ArrayList<>(); - mInputs = new ArrayList<>(); - - int tStartIndex = 0; - if (aRecipe.getRepresentativeInput(tStartIndex) != null) { - mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14 + 9)); - } - if (aRecipe.mSpecialItems != null) { - mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); - } - if (aRecipe.getOutput(tStartIndex) != null) { - mOutputs.add( - new FixedPositionedStack( - aRecipe.getOutput(tStartIndex), - 102, - 14 + 9, - aRecipe.getOutputChance(tStartIndex))); - } - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 10, mInputs); - } - - @Override - public PositionedStack getResult() { - return null; - } - - @Override - public List getOtherStacks() { - return mOutputs; - } - } - - public String trans(String aKey, String aEnglish) { - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); - } -} diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java deleted file mode 100644 index 04558efad..000000000 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java +++ /dev/null @@ -1,358 +0,0 @@ -package com.github.technus.tectech.nei; - -import static com.github.technus.tectech.recipe.TT_recipeAdder.nullItem; -import static gregtech.api.enums.ItemList.Display_Fluid; - -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - -import com.github.technus.tectech.Reference; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.recipe.TT_recipe; - -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.ItemList; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiCraftingRecipe; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.GuiUsageRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; -import cpw.mods.fml.common.event.FMLInterModComms; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.objects.ItemData; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; - -public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { - - protected final TT_recipe.GT_Recipe_MapTT mRecipeMap; - - public TT_NEI_ScannerHandler(TT_recipe.GT_Recipe_MapTT aRecipeMap) { - mRecipeMap = aRecipeMap; - transferRects.add(new RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); - if (!NEI_TT_Config.sIsAdded) { - FMLInterModComms.sendRuntimeMessage( - TecTech.instance, - "NEIPlugins", - "register-crafting-handler", - Reference.MODID + '@' + getRecipeName() + '@' + getOverlayIdentifier()); - GuiCraftingRecipe.craftinghandlers.add(this); - GuiUsageRecipe.usagehandlers.add(this); - } - } - - public List getSortedRecipes() { - List result = new ArrayList<>(mRecipeMap.mRecipeList); - Collections.sort(result); - return result; - } - - public static void drawText(int aX, int aY, String aString, int aColor) { - Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); - } - - @Override - public TemplateRecipeHandler newInstance() { - NEI_TT_Config.TT_SH = new TT_NEI_ScannerHandler(mRecipeMap); - return NEI_TT_Config.TT_SH; - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOverlayIdentifier())) { - for (GT_Recipe tRecipe : getSortedRecipes()) { - if (!tRecipe.mHidden) { - arecipes.add(new CachedDefaultRecipe(tRecipe)); - } - } - } else { - super.loadCraftingRecipes(outputId, results); - } - } - - @Override - public void loadCraftingRecipes(ItemStack aResult) { - ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); - - ArrayList tResults = new ArrayList<>(); - tResults.add(aResult); - tResults.add(GT_OreDictUnificator.get(true, aResult)); - if (tPrefixMaterial != null && !tPrefixMaterial.mBlackListed - && !tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty()) { - for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { - tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); - } - } - FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); - if (tFluid != null) { - tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); - for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry - .getRegisteredFluidContainerData()) { - if (tData.fluid.isFluidEqual(tFluid)) { - tResults.add(GT_Utility.copy(tData.filledContainer)); - } - } - } - for (GT_Recipe tRecipe : getSortedRecipes()) { - if (!tRecipe.mHidden) { - CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); - for (ItemStack tStack : tResults) { - if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { - arecipes.add(tNEIRecipe); - break; - } - } - } - } - } - - @Override - public void loadUsageRecipes(ItemStack aInput) { - ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); - - ArrayList tInputs = new ArrayList<>(); - tInputs.add(aInput); - tInputs.add(GT_OreDictUnificator.get(false, aInput)); - if (tPrefixMaterial != null && !tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty()) { - for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { - tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); - } - } - FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); - if (tFluid != null) { - tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); - for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry - .getRegisteredFluidContainerData()) { - if (tData.fluid.isFluidEqual(tFluid)) { - tInputs.add(GT_Utility.copy(tData.filledContainer)); - } - } - } - for (GT_Recipe tRecipe : getSortedRecipes()) { - if (!tRecipe.mHidden) { - CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); - for (ItemStack tStack : tInputs) { - if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { - arecipes.add(tNEIRecipe); - break; - } - } - } - } - } - - @Override - public String getOverlayIdentifier() { - return mRecipeMap.mNEIName; - } - - @Override - public void drawBackground(int recipe) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); - } - - @Override - public int recipiesPerPage() { - return 1; - } - - @Override - public String getRecipeName() { - return GT_LanguageManager.getTranslation(mRecipeMap.mUnlocalizedName); - } - - @Override - public String getGuiTexture() { - // return "gregtech:textures/gui/" + this.mRecipeMap.mUnlocalizedName + ".png"; - return mRecipeMap.mNEIGUIPath; - } - - @Override - public List handleItemTooltip(GuiRecipe gui, ItemStack aStack, List currenttip, - int aRecipeIndex) { - TemplateRecipeHandler.CachedRecipe tObject = arecipes.get(aRecipeIndex); - if (tObject instanceof CachedDefaultRecipe tRecipe) { - for (PositionedStack tStack : tRecipe.mOutputs) { - if (aStack == tStack.item) { - if (!(tStack instanceof FixedPositionedStack) || ((FixedPositionedStack) tStack).mChance <= 0 - || ((FixedPositionedStack) tStack).mChance == 10000) { - break; - } - currenttip.add( - trans("150", "Chance: ") + ((FixedPositionedStack) tStack).mChance / 100 - + '.' - + (((FixedPositionedStack) tStack).mChance % 100 < 10 - ? "0" + ((FixedPositionedStack) tStack).mChance % 100 - : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) - + '%'); - break; - } - } - for (PositionedStack tStack : tRecipe.mInputs) { - if (aStack == tStack.item) { - if (Display_Fluid.isStackEqual(tStack.item, true, true) || tStack.item.stackSize != 0) { - break; - } - currenttip.add(trans("151", "Does not get consumed in the process")); - break; - } - } - } - return currenttip; - } - - @Override - public void drawExtras(int aRecipeIndex) { - int tEUt = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mEUt; - int computation = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mDuration; - String[] recipeDesc = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); - if (recipeDesc == null) { - int tSpecial = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; - short ampere = (short) (tSpecial & 0xFFFF), minComputationPerSec = (short) (tSpecial >>> 16); - if (tEUt != 0) { - drawText( - 10, - 73, - trans("152.1", "Max EU: ") + GT_Utility.formatNumbers( - (1 + (computation - minComputationPerSec) / minComputationPerSec) * (long) tEUt - * ampere - * 20) - + " EU", - -16777216); - drawText( - 10, - 83, - trans("153", "Usage: ") + GT_Utility.formatNumbers((long) tEUt * ampere) + " EU/t", - -16777216); - if (mRecipeMap.mShowVoltageAmperageInNEI) { - drawText(10, 93, trans("154", "Voltage: ") + GT_Utility.formatNumbers(tEUt) + " EU", -16777216); - drawText(10, 103, trans("155", "Amperage: ") + GT_Utility.formatNumbers(ampere), -16777216); - } else { - drawText(10, 93, trans("156", "Voltage: unspecified"), -16777216); - drawText(10, 103, trans("157", "Amperage: unspecified"), -16777216); - } - } - drawText(10, 113, "Computation: " + GT_Utility.formatNumbers(computation), -16777216); - drawText(10, 123, "Min Computation: " + GT_Utility.formatNumbers(minComputationPerSec) + " /s", -16777216); - } else { - int i = 0; - for (String descLine : recipeDesc) { - drawText(10, 73 + 10 * i, descLine, -16777216); - i++; - } - } - } - - public static class FixedPositionedStack extends PositionedStack { - - public final int mChance; - public boolean permutated = false; - - public FixedPositionedStack(Object object, int x, int y) { - this(object, x, y, 0); - } - - public FixedPositionedStack(Object object, int x, int y, int aChance) { - super(object, x, y, true); - mChance = aChance; - } - - @Override - public void generatePermutations() { - if (permutated) { - return; - } - ArrayList tDisplayStacks = new ArrayList<>(); - for (ItemStack tStack : items) { - if (GT_Utility.isStackValid(tStack)) { - if (tStack.getItemDamage() == 32767) { - List permutations = ItemList.itemMap.get(tStack.getItem()); - if (!permutations.isEmpty()) { - ItemStack stack; - for (Iterator iterator = permutations.iterator(); iterator - .hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, stack))) { - stack = iterator.next(); - } - } else { - ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); - base.stackTagCompound = tStack.stackTagCompound; - tDisplayStacks.add(base); - } - } else { - tDisplayStacks.add(GT_Utility.copy(tStack)); - } - } - } - items = tDisplayStacks.toArray(nullItem); - if (items.length == 0) { - items = new ItemStack[] { new ItemStack(Blocks.fire) }; - } - permutated = true; - setPermutationToRender(0); - } - } - - public class CachedDefaultRecipe extends TemplateRecipeHandler.CachedRecipe { - - public final GT_Recipe mRecipe; - public final List mOutputs; - public final List mInputs; - - public CachedDefaultRecipe(GT_Recipe aRecipe) { - mRecipe = aRecipe; - - mOutputs = new ArrayList<>(); - mInputs = new ArrayList<>(); - - int tStartIndex = 0; - if (aRecipe.getRepresentativeInput(tStartIndex) != null) { - mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14 + 9)); - } - if (aRecipe.mSpecialItems != null) { - mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); - } - if (aRecipe.getOutput(tStartIndex) != null) { - mOutputs.add( - new FixedPositionedStack( - aRecipe.getOutput(tStartIndex), - 102, - 14 + 9, - aRecipe.getOutputChance(tStartIndex))); - } - } - - @Override - public List getIngredients() { - return getCycledIngredients(cycleticks / 10, mInputs); - } - - @Override - public PositionedStack getResult() { - return null; - } - - @Override - public List getOtherStacks() { - return mOutputs; - } - } - - public String trans(String aKey, String aEnglish) { - return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); - } -} diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyFrontend.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyFrontend.java new file mode 100644 index 000000000..b2070f22b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyFrontend.java @@ -0,0 +1,202 @@ +package com.github.technus.tectech.recipe; + +import static com.github.technus.tectech.util.CommonValues.EOH_TIER_FANCY_NAMES; +import static com.google.common.math.LongMath.pow; +import static gregtech.api.util.GT_Utility.formatNumbers; +import static java.lang.Math.min; +import static net.minecraft.util.EnumChatFormatting.BOLD; +import static net.minecraft.util.EnumChatFormatting.DARK_RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; + +import appeng.util.ReadableNumberConverter; +import codechicken.nei.PositionedStack; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.common.gui.modularui.UIHelper; +import gregtech.nei.GT_NEI_DefaultHandler; +import gregtech.nei.RecipeDisplayInfo; +import gregtech.nei.formatter.INEISpecialInfoFormatter; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class EyeOfHarmonyFrontend extends RecipeMapFrontend { + + private static final int xDirMaxCount = 9; + private static final int itemRows = 9, fluidRows = 2; + public static final int maxItemInputs = 1, maxItemOutputs = xDirMaxCount * itemRows, maxFluidInputs = 0, + maxFluidOutputs = xDirMaxCount * fluidRows; + private static final int yOrigin = 8; + private static final long TRILLION = pow(10, 12); + + public EyeOfHarmonyFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + uiPropertiesBuilder.logoPos(new Pos2d(8, yOrigin)), + neiPropertiesBuilder.recipeBackgroundSize(new Size(170, 117 + (itemRows + fluidRows - 4) * 18)) + .neiSpecialInfoFormatter(new EyeOfHarmonySpecialValueFormatter())); + } + + @Override + public List getItemInputPositions(int itemInputCount) { + return UIHelper.getGridPositions(itemInputCount, 79, yOrigin, 1, 1); + } + + public static final int maxItemsToRender = 80; + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return UIHelper.getGridPositions(min(itemOutputCount, maxItemsToRender + 1), 7, yOrigin + 36, xDirMaxCount, 12); + } + + @Override + public List getFluidInputPositions(int fluidInputCount) { + return UIHelper.getGridPositions(fluidInputCount, 0, 0, 0, 0); + } + + @Override + public List getFluidOutputPositions(int fluidOutputCount) { + return UIHelper.getGridPositions(fluidOutputCount, 7, yOrigin + 13 * 17 - 7 - 16, xDirMaxCount, 3); + } + + @Override + public List handleNEIItemTooltip(ItemStack stack, List currentTip, + GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + super.handleNEIItemTooltip(stack, currentTip, neiCachedRecipe); + EyeOfHarmonyRecipe currentRecipe = (EyeOfHarmonyRecipe) neiCachedRecipe.mRecipe.mSpecialItems; + + // Draw tooltip on planet item. + if (stack.isItemEqual(currentRecipe.getRecipeTriggerItem())) { + currentTip.add( + EnumChatFormatting.GRAY + translateToLocalFormatted( + "tt.nei.eoh.total_items", + formatNumbers(currentRecipe.getSumOfItems()))); + return currentTip; + } + + // Draw tooltip on other items. + double percentage = currentRecipe.getItemStackToProbabilityMap().getOrDefault(stack, -1.0); + + if (percentage != -1.0) { + currentTip.add(EnumChatFormatting.GRAY + translateToLocalFormatted("tt.nei.eoh.solid_mass", percentage)); + currentTip.add( + EnumChatFormatting.GRAY + translateToLocalFormatted( + "tt.nei.eoh.item_count", + formatNumbers(currentRecipe.getItemStackToTrueStackSizeMap().get(stack)))); + } + + return currentTip; + } + + @Override + public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { + EyeOfHarmonyRecipe EOHRecipe = (EyeOfHarmonyRecipe) neiCachedRecipe.mRecipe.mSpecialItems; + for (PositionedStack stack : neiCachedRecipe.mInputs) { + if (stack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { + if (stack.item.isItemEqual(EOHRecipe.getRecipeTriggerItem())) { + drawNEIOverlayText(translateToLocal("NC"), stack); + } + } + } + for (PositionedStack stack : neiCachedRecipe.mOutputs) { + if (stack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { + if (EOHRecipe.getItemStackToTrueStackSizeMap().containsKey(stack.item)) { + long stackSize = EOHRecipe.getItemStackToTrueStackSizeMap().get(stack.item); + String displayString; + if (stackSize > 9999) { + displayString = ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize); + } else { + displayString = String.valueOf(stackSize); + } + + drawNEIOverlayText(displayString, stack, 0xffffff, 0.5f, true, Alignment.BottomRight); + } + } + } + } + + private static class EyeOfHarmonySpecialValueFormatter implements INEISpecialInfoFormatter { + + @Override + public List format(RecipeDisplayInfo recipeInfo) { + EyeOfHarmonyRecipe recipe = (EyeOfHarmonyRecipe) recipeInfo.recipe.mSpecialItems; + List result = new ArrayList<>(); + + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.Hydrogen.In", "Hydrogen") + ": " + + formatNumbers(recipe.getHydrogenRequirement()) + + " L"); + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.Helium.In", "Helium") + ": " + + formatNumbers(recipe.getHydrogenRequirement()) + + " L"); + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.SpacetimeTier", "Spacetime Tier") + ": " + + EOH_TIER_FANCY_NAMES[(int) recipe.getSpacetimeCasingTierRequired()]); + + if (recipe.getEUOutput() < TRILLION) { + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.Out", "EU Output") + ": " + + formatNumbers(recipe.getEUOutput()) + + " EU"); + } else { + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.Out", "EU Output") + ": " + + ReadableNumberConverter.INSTANCE.toWideReadableForm(recipe.getEUOutput()) + + " EU"); + } + + if (recipe.getEUOutput() < TRILLION) { + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.In", "EU Input") + ": " + + formatNumbers(recipe.getEUStartCost()) + + " EU"); + } else { + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.In", "EU Input") + ": " + + ReadableNumberConverter.INSTANCE.toWideReadableForm(recipe.getEUStartCost()) + + " EU"); + } + + result.add( + GT_LanguageManager.addStringLocalization("EOH.Recipe.BaseRecipeChance", "Base Recipe Chance") + ": " + + formatNumbers(100 * recipe.getBaseRecipeSuccessChance()) + + "%"); + result.add( + GT_LanguageManager + .addStringLocalization("EOH.Recipe.RecipeEnergyEfficiency", "Recipe Energy Efficiency") + + ": " + + formatNumbers(100 * recipe.getRecipeEnergyEfficiency()) + + "%"); + + if (recipe.getOutputItems().size() > maxItemsToRender) { + result.add( + "" + DARK_RED + + BOLD + + GT_LanguageManager.addStringLocalization("EOH.Recipe.Warning.0", "Warning") + + RESET + + ": " + + GT_LanguageManager + .addStringLocalization("EOH.Recipe.Warning.1", "Not all items displayed.")); + } + + return result; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java index 8aa801e15..1ef3955a0 100644 --- a/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java +++ b/src/main/java/com/github/technus/tectech/recipe/EyeOfHarmonyRecipeStorage.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.recipe; import static com.github.technus.tectech.recipe.EyeOfHarmonyRecipe.processHelper; -import static com.github.technus.tectech.recipe.TT_recipe.GT_Recipe_MapTT.sEyeofHarmonyRecipes; +import static com.github.technus.tectech.recipe.TecTechRecipeMaps.eyeOfHarmonyRecipes; import static java.lang.Math.pow; import java.util.ArrayList; @@ -109,7 +109,7 @@ public EyeOfHarmonyRecipeStorage() { ItemStack planetItem = recipe.getRecipeTriggerItem().copy(); planetItem.stackSize = 0; - sEyeofHarmonyRecipes.addRecipe( + eyeOfHarmonyRecipes.addRecipe( false, new ItemStack[] { planetItem }, outputItems.toArray(new ItemStack[0]), diff --git a/src/main/java/com/github/technus/tectech/recipe/ResearchStationFrontend.java b/src/main/java/com/github/technus/tectech/recipe/ResearchStationFrontend.java new file mode 100644 index 000000000..130a75c0c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/ResearchStationFrontend.java @@ -0,0 +1,94 @@ +package com.github.technus.tectech.recipe; + +import static gregtech.api.util.GT_Utility.trans; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.Collections; +import java.util.List; +import java.util.function.Supplier; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; + +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.nei.RecipeDisplayInfo; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class ResearchStationFrontend extends RecipeMapFrontend { + + public ResearchStationFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super(uiPropertiesBuilder, neiPropertiesBuilder); + } + + @Override + public List getItemInputPositions(int itemInputCount) { + return Collections.singletonList(new Pos2d(52, 33)); + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return Collections.singletonList(new Pos2d(106, 33)); + } + + @Override + public Pos2d getSpecialItemPosition() { + return new Pos2d(124, 62); + } + + @Override + protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) { + long eut = recipeInfo.recipe.mEUt; + int computation = recipeInfo.recipe.mDuration; + short ampere = (short) (recipeInfo.recipe.mSpecialValue & 0xFFFF); + short minComputationPerSec = (short) (recipeInfo.recipe.mSpecialValue >>> 16); + recipeInfo.drawText( + translateToLocalFormatted( + "tt.nei.research.max_eu", + GT_Utility.formatNumbers( + (1 + (computation - minComputationPerSec) / minComputationPerSec) * eut + * ampere + * 20))); + recipeInfo.drawText(trans("153", "Usage: ") + GT_Utility.formatNumbers(eut * ampere) + " EU/t"); + recipeInfo.drawText(trans("154", "Voltage: ") + GT_Utility.formatNumbers(eut) + " EU/t"); + recipeInfo.drawText(trans("155", "Amperage: ") + GT_Utility.formatNumbers(ampere)); + recipeInfo.drawText( + translateToLocalFormatted("tt.nei.research.computation", GT_Utility.formatNumbers(computation))); + recipeInfo.drawText( + translateToLocalFormatted( + "tt.nei.research.min_computation", + GT_Utility.formatNumbers(minComputationPerSec))); + } + + @Override + protected void drawDurationInfo(RecipeDisplayInfo recipeInfo) {} + + @Override + public void addProgressBar(ModularWindow.Builder builder, Supplier progressSupplier, Pos2d windowOffset) { + int bar1Width = 25; + int bar2Width = 11; + int bar3Height = 18; + List> splitProgress = splitProgress(progressSupplier, bar1Width, bar2Width, bar3Height); + builder.widget( + new ProgressBar().setTexture(TecTechUITextures.PROGRESSBAR_RESEARCH_STATION_1, bar1Width) + .setDirection(ProgressBar.Direction.RIGHT).setProgress(splitProgress.get(0)) + .setSynced(false, false).setPos(new Pos2d(81, 40).add(windowOffset)).setSize(bar1Width, 5)); + builder.widget( + new ProgressBar().setTexture(TecTechUITextures.PROGRESSBAR_RESEARCH_STATION_2, bar2Width) + .setDirection(ProgressBar.Direction.RIGHT).setProgress(splitProgress.get(1)) + .setSynced(false, false).setPos(new Pos2d(124, 40).add(windowOffset)).setSize(bar2Width, 5)); + builder.widget( + new ProgressBar().setTexture(TecTechUITextures.PROGRESSBAR_RESEARCH_STATION_3, bar3Height) + .setDirection(ProgressBar.Direction.DOWN).setProgress(splitProgress.get(2)) + .setSynced(false, false).setPos(new Pos2d(128, 44).add(windowOffset)).setSize(10, bar3Height)); + } +} diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java deleted file mode 100644 index e044dccac..000000000 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java +++ /dev/null @@ -1,403 +0,0 @@ -package com.github.technus.tectech.recipe; - -import static com.github.technus.tectech.util.CommonValues.EOH_TIER_FANCY_NAMES; -import static com.google.common.math.LongMath.pow; -import static gregtech.api.util.GT_Utility.formatNumbers; -import static java.lang.Math.min; -import static net.minecraft.util.EnumChatFormatting.BOLD; -import static net.minecraft.util.EnumChatFormatting.DARK_RED; -import static net.minecraft.util.EnumChatFormatting.RESET; -import static net.minecraft.util.StatCollector.translateToLocal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.function.Supplier; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.fluids.FluidStack; - -import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; -import com.gtnewhorizons.modularui.api.math.Alignment; -import com.gtnewhorizons.modularui.api.math.Pos2d; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.common.widget.ProgressBar; - -import appeng.util.ReadableNumberConverter; -import codechicken.nei.PositionedStack; -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Recipe; -import gregtech.common.gui.modularui.UIHelper; -import gregtech.nei.GT_NEI_DefaultHandler; -import gregtech.nei.NEIRecipeInfo; - -@SuppressWarnings("SpellCheckingInspection") -public class TT_recipe extends GT_Recipe { - - public static final String E_RECIPE_ID = "eRecipeID"; - - public TT_recipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, - FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - super( - aOptimize, - aInputs, - aOutputs, - aSpecialItems, - aChances, - aFluidInputs, - aFluidOutputs, - aDuration, - aEUt, - aSpecialValue); - } - - public static class TT_Recipe_Map { - - public static TT_Recipe_Map sCrafterRecipes = new TT_Recipe_Map<>(); - public static TT_Recipe_Map sMachineRecipes = new TT_Recipe_Map<>(); - - private final HashMap mRecipeMap; - - public TT_Recipe_Map() { - mRecipeMap = new HashMap<>(16); - } - - public T findRecipe(String identifier) { - return mRecipeMap.get(identifier); - } - - public T findRecipe(ItemStack dataHandler) { - if (dataHandler == null || dataHandler.stackTagCompound == null) { - return null; - } - return mRecipeMap.get(dataHandler.stackTagCompound.getString(E_RECIPE_ID)); - } - - public void add(T recipe) { - GameRegistry.UniqueIdentifier uid = GameRegistry.findUniqueIdentifierFor(recipe.mOutputs[0].getItem()); - mRecipeMap.put(uid + ":" + recipe.mOutputs[0].getItemDamage(), recipe); - } - - public Collection recipeList() { - return mRecipeMap.values(); - } - } - - public static class GT_Recipe_MapTT extends GT_Recipe.GT_Recipe_Map { - - public static final GT_Recipe_Map sEyeofHarmonyRecipes = new Eye_Of_Harmony_Recipe_Map( - new HashSet<>(250), - "gt.recipe.eyeofharmony", - "Eye of Harmony", - null, - "gregtech:textures/gui/basicmachines/Extractor", - 1, - 9 * 9, - 1, - 0, - 1, - "", - 1, - "", - true, - false) // Custom NEI handler means this must be false. - .setProgressBar(GT_UITextures.PROGRESSBAR_HAMMER, ProgressBar.Direction.DOWN) - .setProgressBarPos(78, 24 + 2).setUsualFluidOutputCount(18).setLogoPos(10, 10); - - public static GT_Recipe_MapTT sResearchableFakeRecipes = new GT_Recipe_MapTT( - new HashSet<>(32), - "gt.recipe.researchStation", - "Research station", - null, - "gregtech:textures/gui/multimachines/ResearchFake", - 1, - 1, - 1, - 0, - 1, - "", - 1, - "", - true, - false); // nei to false - using custom handler - public static GT_Recipe_MapTT sScannableFakeRecipes = new GT_Recipe_MapTT( - new HashSet<>(32), - "gt.recipe.em_scanner", - "EM Scanner Research", - null, - "gregtech:textures/gui/multimachines/ResearchFake", - 1, - 1, - 1, - 0, - 1, - "", - 1, - "", - true, - false); - public static ArrayList sAssemblylineRecipes = new ArrayList<>(); - - public GT_Recipe_MapTT(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 static class TT_assLineRecipe extends GT_Recipe { - - public final ItemStack mResearchItem; - - public TT_assLineRecipe(boolean aOptimize, ItemStack researchItem, ItemStack[] aInputs, ItemStack[] aOutputs, - Object aSpecialItems, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { - super( - aOptimize, - aInputs, - aOutputs, - aSpecialItems, - null, - aFluidInputs, - null, - aDuration, - aEUt, - aSpecialValue); - mResearchItem = researchItem; - } - - } - - public static class Eye_Of_Harmony_Recipe_Map extends GT_Recipe_Map { - - private static final int xDirMaxCount = 9; - private static final int yOrigin = 8; - private static final long TRILLION = pow(10, 12); - - public Eye_Of_Harmony_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); - useModularUI(true); - setLogoPos(8, yOrigin); - setNEISpecialInfoFormatter((recipeInfo, applyPrefixAndSuffix) -> { - EyeOfHarmonyRecipe recipe = (EyeOfHarmonyRecipe) recipeInfo.recipe.mSpecialItems; - List result = new ArrayList<>(); - - result.add( - GT_LanguageManager.addStringLocalization("EOH.Recipe.Hydrogen.In", "Hydrogen") + ": " - + formatNumbers(recipe.getHydrogenRequirement()) - + " L"); - result.add( - GT_LanguageManager.addStringLocalization("EOH.Recipe.Helium.In", "Helium") + ": " - + formatNumbers(recipe.getHydrogenRequirement()) - + " L"); - result.add( - GT_LanguageManager.addStringLocalization("EOH.Recipe.SpacetimeTier", "Spacetime Tier") + ": " - + EOH_TIER_FANCY_NAMES[(int) recipe.getSpacetimeCasingTierRequired()]); - - if (recipe.getEUOutput() < TRILLION) { - result.add( - GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.Out", "EU Output") + ": " - + formatNumbers(recipe.getEUOutput()) - + " EU"); - } else { - result.add( - GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.Out", "EU Output") + ": " - + ReadableNumberConverter.INSTANCE.toWideReadableForm(recipe.getEUOutput()) - + " EU"); - } - - if (recipe.getEUOutput() < TRILLION) { - result.add( - GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.In", "EU Input") + ": " - + formatNumbers(recipe.getEUStartCost()) - + " EU"); - } else { - result.add( - GT_LanguageManager.addStringLocalization("EOH.Recipe.EU.In", "EU Input") + ": " - + ReadableNumberConverter.INSTANCE.toWideReadableForm(recipe.getEUStartCost()) - + " EU"); - } - - result.add( - GT_LanguageManager.addStringLocalization("EOH.Recipe.BaseRecipeChance", "Base Recipe Chance") - + ": " - + formatNumbers(100 * recipe.getBaseRecipeSuccessChance()) - + "%"); - result.add( - GT_LanguageManager - .addStringLocalization("EOH.Recipe.RecipeEnergyEfficiency", "Recipe Energy Efficiency") - + ": " - + formatNumbers(100 * recipe.getRecipeEnergyEfficiency()) - + "%"); - - if (recipe.getOutputItems().size() > maxItemsToRender) { - result.add( - "" + DARK_RED - + BOLD - + GT_LanguageManager.addStringLocalization("EOH.Recipe.Warning.0", "Warning") - + RESET - + ": " - + GT_LanguageManager - .addStringLocalization("EOH.Recipe.Warning.1", "Not all items displayed.")); - } - - return result; - }); - } - - @Override - public boolean usesSpecialSlot() { - return false; - } - - @Override - public List getItemInputPositions(int itemInputCount) { - return UIHelper.getGridPositions(itemInputCount, 79, yOrigin, 1, 1); - } - - public static final int maxItemsToRender = 80; - - @Override - public List getItemOutputPositions(int itemOutputCount) { - return UIHelper - .getGridPositions(min(itemOutputCount, maxItemsToRender + 1), 7, yOrigin + 36, xDirMaxCount, 12); - } - - @Override - public List getFluidInputPositions(int fluidInputCount) { - return UIHelper.getGridPositions(fluidInputCount, 0, 0, 0, 0); - } - - @Override - public List getFluidOutputPositions(int fluidOutputCount) { - return UIHelper.getGridPositions(fluidOutputCount, 7, yOrigin + 13 * 17 - 7 - 16, xDirMaxCount, 3); - } - - @Override - public ModularWindow.Builder createNEITemplate(IItemHandlerModifiable itemInputsInventory, - IItemHandlerModifiable itemOutputsInventory, IItemHandlerModifiable specialSlotInventory, - IItemHandlerModifiable fluidInputsInventory, IItemHandlerModifiable fluidOutputsInventory, - Supplier progressSupplier, Pos2d windowOffset) { - // Delay setter so that calls to #setUsualFluidInputCount and #setUsualFluidOutputCount are considered - setNEIBackgroundSize(172, 117 + (Math.max(getItemRowCount() + getFluidRowCount() - 4, 0)) * 18); - return super.createNEITemplate( - itemInputsInventory, - itemOutputsInventory, - specialSlotInventory, - fluidInputsInventory, - fluidOutputsInventory, - progressSupplier, - windowOffset); - } - - private int getItemRowCount() { - return (Math.max(mUsualInputCount, mUsualOutputCount) - 1) / xDirMaxCount + 1; - } - - private int getFluidRowCount() { - return (Math.max(getUsualFluidInputCount(), getUsualFluidOutputCount()) - 1) / xDirMaxCount + 1; - } - - @Override - protected void drawNEIText(NEIRecipeInfo recipeInfo, String text, int yShift) { - drawNEIText(recipeInfo, text, 7, yShift); - } - - @Override - public List handleNEIItemTooltip(ItemStack stack, List currentTip, - GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { - super.handleNEIItemTooltip(stack, currentTip, neiCachedRecipe); - if (stack == null) return currentTip; - - EyeOfHarmonyRecipe currentRecipe = (EyeOfHarmonyRecipe) neiCachedRecipe.mRecipe.mSpecialItems; - - // Draw tooltip on planet item. - if (stack.isItemEqual(currentRecipe.getRecipeTriggerItem())) { - currentTip.add( - EnumChatFormatting.GRAY + translateToLocal("Total Items: ") - + formatNumbers(currentRecipe.getSumOfItems())); - return currentTip; - } - - // Draw tooltip on other items. - double percentage = currentRecipe.getItemStackToProbabilityMap().getOrDefault(stack, -1.0); - - if (percentage != -1.0) { - currentTip.add( - EnumChatFormatting.GRAY + translateToLocal("Percentage of Solid Mass: ") + percentage + "%"); - currentTip.add( - EnumChatFormatting.GRAY + translateToLocal("Item Count: ") - + formatNumbers(currentRecipe.getItemStackToTrueStackSizeMap().get(stack))); - } - - return currentTip; - } - - @Override - public void drawNEIOverlays(GT_NEI_DefaultHandler.CachedDefaultRecipe neiCachedRecipe) { - EyeOfHarmonyRecipe EOHRecipe = (EyeOfHarmonyRecipe) neiCachedRecipe.mRecipe.mSpecialItems; - for (PositionedStack stack : neiCachedRecipe.mInputs) { - if (stack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { - if (stack.item.isItemEqual(EOHRecipe.getRecipeTriggerItem())) { - drawNEIOverlayText(translateToLocal("NC"), stack); - } - } - } - for (PositionedStack stack : neiCachedRecipe.mOutputs) { - if (stack instanceof GT_NEI_DefaultHandler.FixedPositionedStack) { - if (EOHRecipe.getItemStackToTrueStackSizeMap().containsKey(stack.item)) { - long stackSize = EOHRecipe.getItemStackToTrueStackSizeMap().get(stack.item); - String displayString; - if (stackSize > 9999) { - displayString = ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize); - } else { - displayString = String.valueOf(stackSize); - } - - drawNEIOverlayText(displayString, stack, 0xffffff, 0.5f, true, Alignment.BottomRight); - } - } - } - } - } -} diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java index 083897cc2..366ee0ebb 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java @@ -14,6 +14,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; +import gregtech.api.recipe.RecipeMaps; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; @@ -48,7 +49,7 @@ public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, } researchAmperage = GT_Utility.clamp(researchAmperage, 1, Short.MAX_VALUE); computationRequiredPerSec = GT_Utility.clamp(computationRequiredPerSec, 1, Short.MAX_VALUE); - TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe( + TecTechRecipeMaps.researchStationFakeRecipes.addFakeRecipe( false, new ItemStack[] { aResearchItem }, new ItemStack[] { aOutput }, @@ -58,7 +59,7 @@ public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, totalComputationRequired, researchEUt, researchAmperage | computationRequiredPerSec << 16); - GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe( + RecipeMaps.assemblylineVisualRecipes.addFakeRecipe( false, aInputs, new ItemStack[] { aOutput }, @@ -78,7 +79,7 @@ public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, aOutput, assDuration, assEUt)); - TT_recipe.GT_Recipe_MapTT.sAssemblylineRecipes.add( + TecTechRecipeMaps.researchableALRecipeList.add( new GT_Recipe.GT_Recipe_AssemblyLine( aResearchItem, totalComputationRequired / computationRequiredPerSec, @@ -179,7 +180,7 @@ public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, tPersistentHash = tPersistentHash * 31 + researchEUt; tPersistentHash = tPersistentHash * 31 + assDuration; tPersistentHash = tPersistentHash * 31 + assEUt; - TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe( + TecTechRecipeMaps.researchStationFakeRecipes.addFakeRecipe( false, new ItemStack[] { aResearchItem }, new ItemStack[] { aOutput }, @@ -189,7 +190,7 @@ public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, totalComputationRequired, researchEUt, researchAmperage | computationRequiredPerSec << 16); - GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe( + RecipeMaps.assemblylineVisualRecipes.addFakeRecipe( false, tInputs, new ItemStack[] { aOutput }, @@ -222,7 +223,7 @@ public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, assEUt, tAlts); recipeTT.setPersistentHash(tPersistentHash); - TT_recipe.GT_Recipe_MapTT.sAssemblylineRecipes.add(recipeTT); + TecTechRecipeMaps.researchableALRecipeList.add(recipeTT); return true; } diff --git a/src/main/java/com/github/technus/tectech/recipe/TecTechRecipeMaps.java b/src/main/java/com/github/technus/tectech/recipe/TecTechRecipeMaps.java new file mode 100644 index 000000000..da60084e3 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/recipe/TecTechRecipeMaps.java @@ -0,0 +1,49 @@ +package com.github.technus.tectech.recipe; + +import java.util.ArrayList; +import java.util.List; + +import com.github.technus.tectech.thing.CustomItemList; +import com.github.technus.tectech.thing.gui.TecTechUITextures; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; + +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.util.GT_Recipe; + +public class TecTechRecipeMaps { + + public static void init() {} + + public static final List researchableALRecipeList = new ArrayList<>(); + + public static final RecipeMap eyeOfHarmonyRecipes = RecipeMapBuilder.of("gt.recipe.eyeofharmony") + .maxIO( + EyeOfHarmonyFrontend.maxItemInputs, + EyeOfHarmonyFrontend.maxItemOutputs, + EyeOfHarmonyFrontend.maxFluidInputs, + EyeOfHarmonyFrontend.maxFluidOutputs) + .minInputs(1, 0).progressBar(GT_UITextures.PROGRESSBAR_HAMMER, ProgressBar.Direction.DOWN) + .progressBarPos(78, 24 + 2).logoPos(10, 10) + .neiHandlerInfo( + builder -> builder.setDisplayStack(CustomItemList.Machine_Multi_EyeOfHarmony.get(1)) + .setMaxRecipesPerPage(1)) + .frontend(EyeOfHarmonyFrontend::new).build(); + public static final RecipeMap researchStationFakeRecipes = RecipeMapBuilder + .of("gt.recipe.researchStation").maxIO(1, 1, 0, 0).useSpecialSlot() + .slotOverlays((index, isFluid, isOutput, isSpecial) -> { + if (isSpecial) { + return GT_UITextures.OVERLAY_SLOT_DATA_ORB; + } + if (isOutput) { + return TecTechUITextures.OVERLAY_SLOT_MESH; + } + return GT_UITextures.OVERLAY_SLOT_MICROSCOPE; + }).addSpecialTexture(19, 12, 84, 60, TecTechUITextures.PICTURE_HEAT_SINK) + .addSpecialTexture(41, 22, 40, 40, TecTechUITextures.PICTURE_RACK_LARGE) + .logo(TecTechUITextures.PICTURE_TECTECH_LOGO).logoSize(18, 18).logoPos(151, 63) + .neiTransferRect(81, 33, 25, 18).neiTransferRect(124, 33, 18, 29).frontend(ResearchStationFrontend::new) + .neiHandlerInfo(builder -> builder.setDisplayStack(CustomItemList.Machine_Multi_Research.get(1))).build(); +} diff --git a/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java b/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java index 5f61ad59a..95dc85429 100644 --- a/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java +++ b/src/main/java/com/github/technus/tectech/thing/gui/TecTechUITextures.java @@ -8,6 +8,7 @@ import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; import com.gtnewhorizons.modularui.api.drawable.UITexture; +@SuppressWarnings("SimplifyStreamApiCallChains") public class TecTechUITextures { public static final AdaptableUITexture BACKGROUND_SCREEN_BLUE = AdaptableUITexture @@ -64,6 +65,13 @@ public class TecTechUITextures { public static final UITexture OVERLAY_SLOT_RACK = UITexture.fullImage(MODID, "gui/overlay_slot/rack"); public static final UITexture OVERLAY_SLOT_MESH = UITexture.fullImage(MODID, "gui/overlay_slot/mesh"); + public static final UITexture PROGRESSBAR_RESEARCH_STATION_1 = UITexture + .fullImage(MODID, "gui/progressbar/research_station_1"); + public static final UITexture PROGRESSBAR_RESEARCH_STATION_2 = UITexture + .fullImage(MODID, "gui/progressbar/research_station_2"); + public static final UITexture PROGRESSBAR_RESEARCH_STATION_3 = UITexture + .fullImage(MODID, "gui/progressbar/research_station_3"); + public static final UITexture PICTURE_TECTECH_LOGO = UITexture.fullImage(MODID, "gui/picture/tectech_logo"); public static final UITexture PICTURE_TECTECH_LOGO_DARK = UITexture .fullImage(MODID, "gui/picture/tectech_logo_dark"); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java index 9cb0a0c99..b4819e11f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_EyeOfHarmony.java @@ -41,6 +41,7 @@ import org.jetbrains.annotations.NotNull; import com.github.technus.tectech.recipe.EyeOfHarmonyRecipe; +import com.github.technus.tectech.recipe.TecTechRecipeMaps; import com.github.technus.tectech.thing.block.TileEyeOfHarmony; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; @@ -66,6 +67,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.recipe.check.SimpleCheckRecipeResult; @@ -1091,6 +1093,12 @@ private void drainFluidFromHatchesAndStoreInternally() { } } + @Override + public RecipeMap getRecipeMap() { + // Only for visual + return TecTechRecipeMaps.eyeOfHarmonyRecipes; + } + private EyeOfHarmonyRecipe currentRecipe; // Counter for lag prevention. diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java index b6e5c1629..d7a4efb19 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java @@ -1,6 +1,5 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import static com.github.technus.tectech.recipe.TT_recipe.E_RECIPE_ID; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; @@ -37,7 +36,7 @@ import org.apache.commons.lang3.reflect.FieldUtils; import org.jetbrains.annotations.NotNull; -import com.github.technus.tectech.recipe.TT_recipe; +import com.github.technus.tectech.recipe.TecTechRecipeMaps; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Holder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; @@ -47,7 +46,6 @@ import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IHatchElement; @@ -80,7 +78,6 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB // region variables private final ArrayList eHolders = new ArrayList<>(); private GT_Recipe.GT_Recipe_AssemblyLine tRecipe; - private TT_recipe.TT_assLineRecipe aRecipe; private String machineType; private static final String assembly = "Assembly line"; private ItemStack holdItem; @@ -308,7 +305,7 @@ private void makeStick2() { } private boolean iterateRecipes() { - for (GT_Recipe ttRecipe : TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.mRecipeList) { + for (GT_Recipe ttRecipe : TecTechRecipeMaps.researchStationFakeRecipes.getAllRecipes()) { if (GT_Utility.areStacksEqual(ttRecipe.mInputs[0], holdItem, true)) { computationRequired = computationRemaining = ttRecipe.mDuration * 20L; mMaxProgresstime = 20; @@ -350,11 +347,10 @@ public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStac protected CheckRecipeResult checkProcessing_EM() { ItemStack controllerStack = getControllerSlot(); tRecipe = null; - aRecipe = null; if (!eHolders.isEmpty() && eHolders.get(0).mInventory[0] != null) { holdItem = eHolders.get(0).mInventory[0].copy(); if (ItemList.Tool_DataStick.isStackEqual(controllerStack, false, true)) { - for (GT_Recipe.GT_Recipe_AssemblyLine assRecipe : TT_recipe.GT_Recipe_MapTT.sAssemblylineRecipes) { + for (GT_Recipe.GT_Recipe_AssemblyLine assRecipe : TecTechRecipeMaps.researchableALRecipeList) { if (GT_Utility.areStacksEqual(assRecipe.mResearchItem, holdItem, true)) { machineType = assembly; tRecipe = assRecipe; @@ -362,23 +358,6 @@ protected CheckRecipeResult checkProcessing_EM() { if (iterateRecipes()) return SimpleCheckRecipeResult.ofSuccess("researching"); } } - } else if (ItemList.Tool_DataOrb.isStackEqual(controllerStack, false, true)) { - for (TT_recipe.TT_assLineRecipe assRecipeTT : TT_recipe.TT_Recipe_Map.sMachineRecipes.recipeList()) { - if (GT_Utility.areStacksEqual(assRecipeTT.mResearchItem, holdItem, true)) { - aRecipe = assRecipeTT; - machineType = machine; - // if found - if (iterateRecipes()) return SimpleCheckRecipeResult.ofSuccess("researching"); - } - } - for (TT_recipe.TT_assLineRecipe assRecipeTT : TT_recipe.TT_Recipe_Map.sCrafterRecipes.recipeList()) { - if (GT_Utility.areStacksEqual(assRecipeTT.mResearchItem, holdItem, true)) { - aRecipe = assRecipeTT; - machineType = crafter; - // if found - if (iterateRecipes()) return SimpleCheckRecipeResult.ofSuccess("researching"); - } - } } else { return CheckRecipeResultRegistry.NO_DATA_STICKS; } @@ -406,33 +385,10 @@ public void outputAfterRecipe_EM() { makeStick(); } } - } else if (aRecipe != null && ItemList.Tool_DataOrb.isStackEqual(mInventory[1], false, true)) { - eHolders.get(0).getBaseMetaTileEntity().setActive(false); - eHolders.get(0).mInventory[0] = null; - - mInventory[1].setStackDisplayName( - GT_LanguageManager.getTranslation(aRecipe.mOutputs[0].getDisplayName()) + ' ' - + machineType - + " Construction Data"); - NBTTagCompound tNBT = mInventory[1].getTagCompound(); // code above makes it not null - - tNBT.setString("eMachineType", machineType); - GameRegistry.UniqueIdentifier uid = GameRegistry.findUniqueIdentifierFor(aRecipe.mOutputs[0].getItem()); - tNBT.setString(E_RECIPE_ID, uid + ":" + aRecipe.mOutputs[0].getItemDamage()); - tNBT.setString( - "author", - EnumChatFormatting.BLUE + "Tec" - + EnumChatFormatting.DARK_BLUE - + "Tech" - + EnumChatFormatting.WHITE - + ' ' - + machineType - + " Recipe Generator"); } } computationRequired = computationRemaining = 0; tRecipe = null; - aRecipe = null; holdItem = null; } @@ -622,7 +578,6 @@ public void stopMachine() { } computationRequired = computationRemaining = 0; tRecipe = null; - aRecipe = null; holdItem = null; } @@ -630,39 +585,19 @@ public void stopMachine() { public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) { if (aBaseMetaTileEntity.isServerSide()) { if (computationRemaining > 0) { - aRecipe = null; tRecipe = null; if (holdItem != null) { if (ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true)) { - for (GT_Recipe.GT_Recipe_AssemblyLine tRecipe : TT_recipe.GT_Recipe_MapTT.sAssemblylineRecipes) { + for (GT_Recipe.GT_Recipe_AssemblyLine tRecipe : TecTechRecipeMaps.researchableALRecipeList) { if (GT_Utility.areStacksEqual(tRecipe.mResearchItem, holdItem, true)) { this.tRecipe = tRecipe; machineType = assembly; break; } } - } else if (ItemList.Tool_DataOrb.isStackEqual(mInventory[1], false, true)) { - for (TT_recipe.TT_assLineRecipe assRecipeTT : TT_recipe.TT_Recipe_Map.sMachineRecipes - .recipeList()) { - if (GT_Utility.areStacksEqual(assRecipeTT.mResearchItem, holdItem, true)) { - aRecipe = assRecipeTT; - machineType = machine; - break; - } - } - if (aRecipe == null) { - for (TT_recipe.TT_assLineRecipe assRecipeTT : TT_recipe.TT_Recipe_Map.sCrafterRecipes - .recipeList()) { - if (GT_Utility.areStacksEqual(assRecipeTT.mResearchItem, holdItem, true)) { - aRecipe = assRecipeTT; - machineType = crafter; - break; - } - } - } } } - if (tRecipe == null && aRecipe == null) { + if (tRecipe == null) { holdItem = null; computationRequired = computationRemaining = 0; mMaxProgresstime = 0; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index 291bdd169..e366327b6 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -42,6 +42,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.RecipeMaps; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -179,7 +180,7 @@ public void outputAfterRecipe_EM() { if (entity instanceof Entity) { if (tickedStuff.add((Entity) entity)) { if (inside && entity instanceof EntityItem) { - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMicrowaveRecipes.findRecipe( + GT_Recipe tRecipe = RecipeMaps.microwaveRecipes.findRecipe( mte, null, true, diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index 43b47b0a0..02df6ea5e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -90,7 +90,6 @@ import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_HatchElementBuilder; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.IGT_HatchAdder; import gregtech.common.GT_Pollution; @@ -849,14 +848,6 @@ public void loadNBTData(NBTTagCompound aNBT) { } } - /** - * If you want to use GT recipe maps. - */ - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - /** * Override if needed but usually call super method at start! On machine stop - NOT called directly when soft * hammered to offline state! - it SHOULD cause a full stop like power failure does diff --git a/src/main/resources/assets/gregtech/textures/gui/multimachines/ResearchFake.png b/src/main/resources/assets/gregtech/textures/gui/multimachines/ResearchFake.png deleted file mode 100644 index b80e150877fd23366a2b17451cdde8506c020084..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1972 zcmcIkdpOi-8-9PknaqR+pNYaSeQDZEYYMeA%}<+9k;4@s z45gXuhA1O7X1Ww@&W9MG`pnvL7`x?c7(2H8r~cZ1_IM6k|>TPWmxjnUvtd`uh403kw`y;p6@>BP=YIr(p?0e|rPBUo@2l^MP&6>HVSEI#vrg7a zA>Y840htXMk32y{E-5Dhu#Mbvn(lOng}w4ZKA+zf2?8ncZ{$(-a9#+C*g3lYj9baA zFg-gX+$}jMB&(NeUU&)>B&&$|W>{kzz&m z`eR#inurB;E7WKSC%T*?fFCO?mxGwQzN%k*#3YRQ0rNKK>Le8@9H3| z=%^zjXJA$-N}#A-d}xbMNrfoJDb<&{6c%mjoj@2RsW2$5Kg)l9r=_Z2c-QNG)r%1G z7ru4Dcz==U%ln425S;E{3CwFqS9WWKr`5K)l(mFK3>91e?f zs4_2beP(W5-fJk^FFx}&=2EBw<6(l<>Xl&U{sgVv_bMEvMH=Oh1z1(pVA(z;?>w$U z$!uUw&7P2nbI#dmK#*kf6^Dfb-P#`ZdAE9m7fh7%2CiH?eWj>JNcOCu#36to7-%sr z$XK9yV9zZ^ZnIX*z71OxMXx5I(Ex?#?opU*L>EtC${Q~JD(eZ7(CmM};<*Q}40zwq4mcR$;@)Zu4*vehUoA9WoM#(5I3FL}+zAt(^_)Js zrrSU$_TmXzD@d)=jlojr$wCp8UxoQ&YD%vuw1TTE8kDEVrZ$A;%e;Enr>mvVZO5{k zi`uY{22x{x=uK6v6;y7>nJpo@=$Bp2Y@3??)Z?(@V=s!q`-XO)!K8eq1NW|d?ya$E zGD()0jDC4pJQB*=4j{=3XP&?oyJtR=ir5hl@a{56yL!fltK3IHM*tXEdy$r&A2)^` zg*01=Boq5ST(>zlw#zAKnKsZQ##FaITq&Zz7!<>Z@#G}wR-lu_RyhiV*Q=%mb(LrV zl~(>scEvD4m#uo=z73)B;BhqLM+=KeUz`rEHs#-UO zwSk0i$~1-T=73wcYo~*)dyz=X_^jUQIcU!FiA`E+mJi!_gWFpQ3P6I3i=Y$=*t;oZ+MtA~ zhdnvkAQEFGHYl2Rd5DW2pJ(`)j4>I5%6pHWd7gijQdpJ+Ip?7~gn%0WXsuzb1%ToF z1^~>A5#3rV1cjgw6oO~_WQ@s5DQK<1%rBjYrcWGS%$!@kcYpXKAtHG1-wGH)K#cL6 z8f=kst~#Gmx{pt*K_WUtYYSC|K2q}^CHRb9sV)S|a4DsSIp^G+Xg7l8uiZkHVY?9g zA7)S82)2Y9s*Af3-0Rjol0vZT%A*&;6K;u^(Tpc>JkYOogivVE|1-@A<9 zcAp!zi(?r;B4q#NoFW40&A?1sE>wyfeL#v58^QT7gCpmY9CKFCTJq^o-Ab zd4IWjze?`8liR0!TD{fi*n@ksUuEmcHC&StWSsDh|A1wCPd^8%Xh?t~R^os7guUO- a-r+VX^%TjQknY0(1fH&bE-dSu5}E)PpEnQy diff --git a/src/main/resources/assets/tectech/textures/gui/progressbar/research_station_1.png b/src/main/resources/assets/tectech/textures/gui/progressbar/research_station_1.png new file mode 100644 index 0000000000000000000000000000000000000000..e1c451f81a96fd55337fec425137ffce9f0f58d6 GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^l0eMG!3HE9SAPuyQkI@Bjv*T7lT#8Bew=qmK9H1` zcg~^M+sVl(Baid(|Ns9p2%rVfAT#8*}sd*MNpF Nc)I$ztaD0e0s#KpBd7oX literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/tectech/textures/gui/progressbar/research_station_2.png b/src/main/resources/assets/tectech/textures/gui/progressbar/research_station_2.png new file mode 100644 index 0000000000000000000000000000000000000000..974a02f281aaf6fe0511b34ab6d9d635cabdd74e GIT binary patch literal 172 zcmeAS@N?(olHy`uVBq!ia0vp^+(695!3HFgJ}hYlQpKJwjv*44r}m%bJ)*$FdOWbo zXug?76Vr<(=5Q^hU7zNe-QxEAHdm+8>*1rK#$rIp^N*wKvZcoQvJ`_~nSjS1R2LsdH^C4@4ehW&CF(9SJ3E*NNSsY*&YCZs&jAKG2W<=naw`0VWf2idDP2%01rQNT{ms1h>Thv<6{<#!zWRvhm63=brF2+@l#;25PLI%t feAKWnsIfc&fbGsRLUlt300000NkvXXu0mjf#uj&u literal 0 HcmV?d00001