diff options
author | Alkalus <Draknyte1@hotmail.com> | 2020-04-14 18:46:45 +0100 |
---|---|---|
committer | Alkalus <Draknyte1@hotmail.com> | 2020-04-14 18:46:45 +0100 |
commit | e42c71394ca8e9b82a47ca8b35aad2d19ff16ac3 (patch) | |
tree | 6f2b69d8bd057961d7e595e68f441720d4b75e0a /src | |
parent | 87ab3c0ab5f1b682295e2a010cc88cf4ae7db51c (diff) | |
download | GT5-Unofficial-e42c71394ca8e9b82a47ca8b35aad2d19ff16ac3.tar.gz GT5-Unofficial-e42c71394ca8e9b82a47ca8b35aad2d19ff16ac3.tar.bz2 GT5-Unofficial-e42c71394ca8e9b82a47ca8b35aad2d19ff16ac3.zip |
$ Fixed GTPP recipe maps being mapped to to the GT_Recipe_Map.sMappings list. Prevents BartWorks from touching my recipes.
Diffstat (limited to 'src')
-rw-r--r-- | src/Java/gregtech/api/util/Recipe_GT.java | 60 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/GTplusplus.java | 18 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/nei/GTPP_NEI_CustomMapHandler.java | 828 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/nei/GTPP_NEI_DefaultHandler.java | 829 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/nei/GTPP_NEI_DefaultHandlerEx.java | 829 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/nei/NEI_GT_Config.java | 23 |
6 files changed, 2551 insertions, 36 deletions
diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index d8cbb6525e..7bed2ee4ec 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -119,6 +119,10 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ for (final Gregtech_Recipe_Map tMapEntry : Gregtech_Recipe_Map.sMappings) { tMapEntry.reInit(); } + for (final GTPP_Recipe_Map tMapEntry : GTPP_Recipe_Map.sMappingsEx) { + tMapEntry.reInit(); + } + } @Override @@ -235,6 +239,18 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ return true; } + + public static class GTPP_Recipe_Map extends GT_Recipe_Map { + + public static final Collection<GTPP_Recipe_Map> sMappingsEx = new ArrayList<>(); + + public GTPP_Recipe_Map(Collection<GT_Recipe> 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); + GT_Recipe_Map.sMappings.remove(this); + GTPP_Recipe_Map.sMappingsEx.add(this); + } + + } public static class Gregtech_Recipe_Map { /** @@ -242,30 +258,30 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ */ public static final Collection<Gregtech_Recipe_Map> sMappings = new ArrayList<>(); //public static final GT_Recipe_Map sChemicalBathRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.chemicalbath", "Chemical Bath", null, RES_PATH_GUI + "basicmachines/ChemicalBath", 1, 3, 1, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sCokeOvenRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.cokeoven", "Coke Oven", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 2, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sMatterFab2Recipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.matterfab2", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Default", 9, 9, 0, 0, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map sCokeOvenRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.cokeoven", "Coke Oven", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 2, 1, 0, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map sMatterFab2Recipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.matterfab2", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Default", 9, 9, 0, 0, 1, E, 1, E, true, true); //public static final Gregtech_Recipe_Map sMatterFabRecipes = new Gregtech_Recipe_Map(new HashSet<GregtechRecipe>(200), "gt.recipe.matterfab", "Matter Fabricator", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 3, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map_Fuel sRocketFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.rocketenginefuel", "Rocket Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 3000, " EU", true, true); - public static final GT_Recipe_Map sGeoThermalFuels = new GT_Recipe_Map(new HashSet<GT_Recipe>(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map sChemicalDehydratorRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.chemicaldehydrator", "Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sVacuumFurnaceRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(500), "gt.recipe.vacfurnace", "Vacuum Furnace", null, "gregtech:textures/gui/basicmachines/Default", 6, 6, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); - public static final GT_Recipe_Map sAlloyBlastSmelterRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.alloyblastsmelter", "Alloy Blast Smelter", null, RES_PATH_GUI + "basicmachines/BlastSmelter", 9, 9, 1, 0, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sSteamTurbineFuels = new GT_Recipe_Map(new HashSet<GT_Recipe>(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GTPP_Recipe_Map sGeoThermalFuels = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GTPP_Recipe_Map sChemicalDehydratorRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.chemicaldehydrator", "Dehydrator", null, RES_PATH_GUI + "basicmachines/Dehydrator", 2, 9, 0, 0, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map sVacuumFurnaceRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(500), "gt.recipe.vacfurnace", "Vacuum Furnace", null, "gregtech:textures/gui/basicmachines/Default", 6, 6, 1, 0, 1, "Heat Capacity: ", 1, " K", false, true); + public static final GTPP_Recipe_Map sAlloyBlastSmelterRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.alloyblastsmelter", "Alloy Blast Smelter", null, RES_PATH_GUI + "basicmachines/BlastSmelter", 9, 9, 1, 0, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map sSteamTurbineFuels = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(10), "gt.recipe.geothermalfuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); //LFTR recipes - public static final GT_Recipe_Map sLiquidFluorineThoriumReactorRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.lftr", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); - public static final GT_Recipe_Map sLiquidFluorineThoriumReactorRecipesEx = new GT_Recipe_Map(new NoConflictGTRecipeMap(), "gt.recipe.lftr.2", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); + public static final GTPP_Recipe_Map sLiquidFluorineThoriumReactorRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.lftr", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); + public static final GTPP_Recipe_Map sLiquidFluorineThoriumReactorRecipesEx = new GTPP_Recipe_Map(new NoConflictGTRecipeMap(), "gt.recipe.lftr.2", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); // Ore Milling Map - public static final GT_Recipe_Map sOreMillRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.oremill", "Milling", null, RES_PATH_GUI + "basicmachines/LFTR", 3, 4, 1, 0, 1, E, 1, E, true, false); + public static final GTPP_Recipe_Map sOreMillRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.oremill", "Milling", null, RES_PATH_GUI + "basicmachines/LFTR", 3, 4, 1, 0, 1, E, 1, E, true, false); //Fission Fuel Plant Recipes - //public static final GT_Recipe_Map sFissionFuelProcessing = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.fissionfuel", "Fission Fuel Processing", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 9, 1, E, 1, E, true, true); + //public static final GTPP_Recipe_Map sFissionFuelProcessing = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.fissionfuel", "Fission Fuel Processing", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 9, 1, E, 1, E, true, true); //Basic Washer Map - public static final GT_Recipe_Map sSimpleWasherRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(3), "gt.recipe.simplewasher", "Simple Dust Washer", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 1, 0, 0, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map sSimpleWasherRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(3), "gt.recipe.simplewasher", "Simple Dust Washer", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 1, 1, 0, 0, 1, E, 1, E, true, true); public static final Gregtech_Recipe_Map sChemicalPlantRecipes = new Gregtech_Recipe_Map( new HashSet<Recipe_GT>(100), @@ -282,7 +298,7 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ 1, E, true, - true); + false); //RTG Fuel Map @@ -296,15 +312,15 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ "Fuel Value: ", 1000, " EU", true, false); //Cyclotron recipe map - public static final GT_Recipe_Map sCyclotronRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.cyclotron", "COMET - Compact Cyclotron", null, RES_PATH_GUI + "basicmachines/BlastSmelter", 2, 16, 0, 0, 1, E, 1, E, true, true); + public static final GTPP_Recipe_Map sCyclotronRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(200), "gt.recipe.cyclotron", "COMET - Compact Cyclotron", null, RES_PATH_GUI + "basicmachines/BlastSmelter", 2, 16, 0, 0, 1, E, 1, E, true, true); //Advanced Mixer - public static final GT_Recipe_Map sAdvancedMixerRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(1000), "gt.recipe.advanced.mixer", + public static final GTPP_Recipe_Map sAdvancedMixerRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(1000), "gt.recipe.advanced.mixer", "Advanced Material Combiner", null, "gregtech:textures/gui/basicmachines/MixerAdvanced", 4, 4, 1, 0, 2, "", 1, "", true, true); //Mini Fusion - public static final GT_Recipe_Map sSlowFusionRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.slowfusionreactor", + public static final GTPP_Recipe_Map sSlowFusionRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.slowfusionreactor", "Mimir - Slow Fusion", null, "gregtech:textures/gui/basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); @@ -313,20 +329,20 @@ public class Recipe_GT extends GT_Recipe implements IComparableRecipe{ public static final GT_Recipe_Map sComponentAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<GT_Recipe>(300), "gt.recipe.componentassembler", "Component Assembler", null, RES_PATH_GUI + "basicmachines/Assembler", 6, 1, 1, 0, 1, E, 1, E, true, true); //Special Maps for Multis - public static final GT_Recipe_Map sFishPondRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(3), "gt.recipe.fishpond", "Zhuhai - Fishing Port", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 1, 0, 0, 1, "Requires Circuit: ", 1, ".", true, true); + public static final GTPP_Recipe_Map sFishPondRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(3), "gt.recipe.fishpond", "Zhuhai - Fishing Port", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 1, 0, 0, 1, "Requires Circuit: ", 1, ".", true, true); public static final Gregtech_Recipe_Map sMultiblockCentrifugeRecipes = new GT_Recipe_Map_LargeCentrifuge(); public static final Gregtech_Recipe_Map sMultiblockElectrolyzerRecipes = new GT_Recipe_Map_LargeElectrolyzer(); public static final Gregtech_Recipe_Map sAdvFreezerRecipes = new GT_Recipe_Map_AdvancedVacuumFreezer(); - public static final GT_Recipe_Map sAdvFreezerRecipes_GT = new GT_Recipe_Map(new HashSet<GT_Recipe>(2000), "gt.recipe.temp", "temp", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 0, 0, 0, 0, "", 0, "", false, false); - public static final GT_Recipe_Map sMultiblockCentrifugeRecipes_GT = new GT_Recipe_Map(new HashSet<GT_Recipe>(2000), "gt.recipe.temp2", "temp2", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 0, 0, 0, 0, "", 0, "", false, false); - public static final GT_Recipe_Map sMultiblockElectrolyzerRecipes_GT = new GT_Recipe_Map(new HashSet<GT_Recipe>(2000), "gt.recipe.temp3", "temp3", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 0, 0, 0, 0, "", 0, "", false, false); - public static final GT_Recipe_Map sChemicalPlant_GT = new GT_Recipe_Map(new HashSet<GT_Recipe>(2000), "gt.recipe.temp4", "temp4", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 0, 0, 0, 0, "", 0, "", false, false); + public static final GTPP_Recipe_Map sAdvFreezerRecipes_GT = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(2000), "gt.recipe.temp", "temp", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 0, 0, 0, 0, "", 0, "", false, false); + public static final GTPP_Recipe_Map sMultiblockCentrifugeRecipes_GT = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(2000), "gt.recipe.temp2", "temp2", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 0, 0, 0, 0, "", 0, "", false, false); + public static final GTPP_Recipe_Map sMultiblockElectrolyzerRecipes_GT = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(2000), "gt.recipe.temp3", "temp3", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 0, 0, 0, 0, "", 0, "", false, false); + public static final GTPP_Recipe_Map sChemicalPlant_GT = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(2000), "gt.recipe.temp4", "temp4", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 0, 0, 0, 0, "", 0, "", false, false); //Semi-Fluid Fuel Map public static final GT_Recipe_Map_Fuel sSemiFluidLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<GT_Recipe>(10), "gt.recipe.semifluidgeneratorfuels", "Semifluid Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); // Flotation Cell - public static final GT_Recipe_Map sFlotationCellRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.flotationcell", "Flotation Cell", null, RES_PATH_GUI + "basicmachines/LFTR", 6, 4, 1, 1, 1, "Ore Key: ", 1, E, true, false); + public static final GTPP_Recipe_Map sFlotationCellRecipes = new GTPP_Recipe_Map(new HashSet<GT_Recipe>(10000), "gt.recipe.flotationcell", "Flotation Cell", null, RES_PATH_GUI + "basicmachines/LFTR", 6, 4, 1, 1, 1, "Ore Key: ", 1, E, true, false); diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 4ddec1f9f4..6a0de88b05 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -11,23 +11,15 @@ import java.util.Collection; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLLoadCompleteEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.event.FMLServerStoppingEvent; +import cpw.mods.fml.common.event.*; import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.util.FishPondFakeRecipe; -import gregtech.api.util.GT_Recipe; +import gregtech.api.util.*; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.Recipe_GT; -import gregtech.api.util.SemiFluidFuelHandler; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.chunkloading.GTPP_ChunkManager; import gtPlusPlus.core.commands.CommandDebugChunks; @@ -205,6 +197,7 @@ public class GTplusplus implements ActionListener { //SprinklerHandler.registerModFerts(); BlockEventHandler.init(); + Recipe_GT.reInit(); Logger.INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Logger.INFO("| Recipes succesfully Loaded: " + RegistrationHandler.recipesSuccess + " | Failed: " @@ -258,6 +251,11 @@ public class GTplusplus implements ActionListener { generateGregtechRecipeMaps(); } + @Mod.EventHandler + public void onIDChangingEvent(FMLModIdMappingEvent aEvent) { + Recipe_GT.reInit(); + } + public static void tryPatchTurbineTextures() { if (enableAnimatedTurbines) { BlockIcons h = Textures.BlockIcons.GAS_TURBINE_SIDE_ACTIVE; diff --git a/src/Java/gtPlusPlus/nei/GTPP_NEI_CustomMapHandler.java b/src/Java/gtPlusPlus/nei/GTPP_NEI_CustomMapHandler.java new file mode 100644 index 0000000000..ca6eb55b90 --- /dev/null +++ b/src/Java/gtPlusPlus/nei/GTPP_NEI_CustomMapHandler.java @@ -0,0 +1,828 @@ +package gtPlusPlus.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.*; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import codechicken.nei.recipe.*; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +import gregtech.common.gui.GT_GUIContainer_FusionReactor; +import gregtech.common.gui.GT_GUIContainer_PrimitiveBlastFurnace; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GTPP_NEI_CustomMapHandler + extends TemplateRecipeHandler { + public static final int sOffsetX = 5; + public static final int sOffsetY = 11; + + static { + GuiContainerManager.addInputHandler(new GT_RectHandler()); + GuiContainerManager.addTooltipHandler(new GT_RectHandler()); + } + + protected final CustomRecipeMap mRecipeMap; + + public GTPP_NEI_CustomMapHandler(CustomRecipeMap tMap) { + this.mRecipeMap = tMap; + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtech@" + getRecipeName() + "@" + getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public List<GT_Recipe> getSortedRecipes() { + List<GT_Recipe> result = new ArrayList<>(this.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); + } + + public TemplateRecipeHandler newInstance() { + return new GTPP_NEI_CustomMapHandler(this.mRecipeMap); + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + for (GT_Recipe tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadCraftingRecipes(ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList<ItemStack> tResults = new ArrayList<ItemStack>(); + 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(new Object[]{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)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + ArrayList<ItemStack> tInputs = new ArrayList<ItemStack>(); + 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(new Object[]{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)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + } + + public String getOverlayIdentifier() { + return this.mRecipeMap.mNEIName; + } + + 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); + } + + public int recipiesPerPage() { + return 1; + } + + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + public String getGuiTexture() { +// return "gregtech:textures/gui/" + this.mRecipeMap.mUnlocalizedName + ".png"; + return this.mRecipeMap.mNEIGUIPath; + } + + public List<String> handleItemTooltip(GuiRecipe gui, ItemStack aStack, List<String> currenttip, int aRecipeIndex) { + TemplateRecipeHandler.CachedRecipe tObject = (TemplateRecipeHandler.CachedRecipe) this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + 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 ((gregtech.api.enums.ItemList.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; + } + + public void drawExtras(int aRecipeIndex) { + int tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); + if (recipeDesc == null) { + if (tEUt != 0) { + drawText(10, 73, trans("152","Total: ") + ((long)tDuration * tEUt) + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); + drawText(10, 103, trans("155","Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); + drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); + } + } + if (tDuration > 0) { +// drawText(10, 113, trans("158","Time: ") + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + trans("161"," secs"), -16777216); + drawText(10, 113, String.format("%s%.2f%s", trans("158","Time: "), 0.05 * tDuration, trans("161"," secs")), -16777216); + } + int tSpecial = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; + if (tSpecial == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { + drawText(10, 123, trans("159","Needs Low Gravity"), -16777216); + } else if (tSpecial == -200 && GT_Mod.gregtechproxy.mEnableCleanroom) { + drawText(10, 123, trans("160","Needs Cleanroom"), -16777216); + } else if (tSpecial == -201) { + drawText(10, 123, trans("206","Scan for Assembly Line"), -16777216); + } else if (tSpecial == -300) { + drawText(10, 123, trans("216","Deprecated Recipe"), -16777216); + } else if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); + } + } else { + int i = 0; + for (String descLine : recipeDesc) { + drawText(10, 73 + 10 * i, descLine, -16777216); + i++; + } + } + } + + public static class GT_RectHandler + implements IContainerInputHandler, IContainerTooltipHandler { + public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { + if (canHandle(gui)) { + if (button == 0) { + return transferRect(gui, false); + } + if (button == 1) { + return transferRect(gui, true); + } + } + return false; + } + + public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) { + return false; + } + + public boolean canHandle(GuiContainer gui) { + return (gui instanceof GT_GUIContainer_BasicMachine && GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) + || (gui instanceof GT_GUIContainer_FusionReactor && GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI)); + } + + public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) { + if ((canHandle(gui)) && (currenttip.isEmpty())) { + if (gui instanceof GT_GUIContainer_BasicMachine && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } else if (gui instanceof GT_GUIContainer_PrimitiveBlastFurnace && new Rectangle(51, 10, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_PrimitiveBlastFurnace) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_PrimitiveBlastFurnace) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } + + } + return currenttip; + } + + private boolean transferRect(GuiContainer gui, boolean usage) { + if (gui instanceof GT_GUIContainer_BasicMachine) { + return (canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0])); + } else if (gui instanceof GT_GUIContainer_FusionReactor) { + return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0])); + } + return false; + } + + public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) { + return currenttip; + } + + public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List<String> currenttip) { + return currenttip; + } + + public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) { + return false; + } + + public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { + } + + public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { + } + + public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { + } + + public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { + return false; + } + + public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { + } + + public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { + } + } + + 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); + this.mChance = aChance; + } + + public void generatePermutations() { + if (this.permutated) { + return; + } + ArrayList<ItemStack> tDisplayStacks = new ArrayList<ItemStack>(); + for (ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (Iterator<ItemStack> i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = (ItemStack) i$.next(); + } + } else { + ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = ((ItemStack[]) tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe + extends TemplateRecipeHandler.CachedRecipe { + public final GT_Recipe mRecipe; + public final List<PositionedStack> mOutputs; + public final List<PositionedStack> mInputs; + + public CachedDefaultRecipe(GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + + if (aRecipe.getInputPositionedStacks() != null && aRecipe.getOutputPositionedStacks() != null) { + mInputs = aRecipe.getInputPositionedStacks(); + mOutputs = aRecipe.getOutputPositionedStacks(); + return; + } + + mOutputs = new ArrayList<PositionedStack>(); + mInputs = new ArrayList<PositionedStack>(); + + int tStartIndex = 0; + switch (GTPP_NEI_CustomMapHandler.this.mRecipeMap.mUsualInputCount) { + case 0: + break; + case 1: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 2: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 3: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 4: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 5: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 6: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 7: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + break; + case 8: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + break; + default: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 32)); + } + tStartIndex++; + } + if (aRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + switch (GTPP_NEI_CustomMapHandler.this.mRecipeMap.mUsualOutputCount) { + case 0: + break; + case 1: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 2: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 3: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 4: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 5: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 6: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 7: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 8: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + default: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + } + if ((aRecipe.mFluidInputs.length > 0) && (aRecipe.mFluidInputs[0] != null) && (aRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[0], true), 48, 52)); + if ((aRecipe.mFluidInputs.length > 1) && (aRecipe.mFluidInputs[1] != null) && (aRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[1], true), 30, 52)); + } + } + if (aRecipe.mFluidOutputs.length > 1) { + if (aRecipe.mFluidOutputs[0] != null && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 120, 5)); + } + if (aRecipe.mFluidOutputs[1] != null && (aRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[1], true), 138, 5)); + } + if (aRecipe.mFluidOutputs.length > 2 && aRecipe.mFluidOutputs[2] != null && (aRecipe.mFluidOutputs[2].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[2], true), 102, 23)); + } + if (aRecipe.mFluidOutputs.length > 3 && aRecipe.mFluidOutputs[3] != null && (aRecipe.mFluidOutputs[3].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[3], true), 120, 23)); + } + if (aRecipe.mFluidOutputs.length > 4 && aRecipe.mFluidOutputs[4] != null && (aRecipe.mFluidOutputs[4].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[4], true), 138, 23)); + } + } else if ((aRecipe.mFluidOutputs.length > 0) && (aRecipe.mFluidOutputs[0] != null) && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 102, 52)); + } + } + + public List<PositionedStack> getIngredients() { + return getCycledIngredients(GTPP_NEI_CustomMapHandler.this.cycleticks / 10, this.mInputs); + } + + public PositionedStack getResult() { + return null; + } + + public List<PositionedStack> getOtherStacks() { + return this.mOutputs; + } + } + + public String trans(String aKey, String aEnglish){ + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + } +} diff --git a/src/Java/gtPlusPlus/nei/GTPP_NEI_DefaultHandler.java b/src/Java/gtPlusPlus/nei/GTPP_NEI_DefaultHandler.java new file mode 100644 index 0000000000..279f45f756 --- /dev/null +++ b/src/Java/gtPlusPlus/nei/GTPP_NEI_DefaultHandler.java @@ -0,0 +1,829 @@ +package gtPlusPlus.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.*; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import codechicken.nei.recipe.*; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; +import gregtech.common.gui.GT_GUIContainer_FusionReactor; +import gregtech.common.gui.GT_GUIContainer_PrimitiveBlastFurnace; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GTPP_NEI_DefaultHandler + extends TemplateRecipeHandler { + public static final int sOffsetX = 5; + public static final int sOffsetY = 11; + + static { + GuiContainerManager.addInputHandler(new GT_RectHandler()); + GuiContainerManager.addTooltipHandler(new GT_RectHandler()); + } + + protected final Gregtech_Recipe_Map mRecipeMap; + + public GTPP_NEI_DefaultHandler(Gregtech_Recipe_Map tMap) { + this.mRecipeMap = tMap; + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtech@" + getRecipeName() + "@" + getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public List<GT_Recipe> getSortedRecipes() { + List<GT_Recipe> result = new ArrayList<>(this.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); + } + + public TemplateRecipeHandler newInstance() { + return new GTPP_NEI_DefaultHandler(this.mRecipeMap); + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + for (GT_Recipe tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadCraftingRecipes(ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList<ItemStack> tResults = new ArrayList<ItemStack>(); + 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(new Object[]{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)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + ArrayList<ItemStack> tInputs = new ArrayList<ItemStack>(); + 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(new Object[]{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)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + } + + public String getOverlayIdentifier() { + return this.mRecipeMap.mNEIName; + } + + 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); + } + + public int recipiesPerPage() { + return 1; + } + + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + public String getGuiTexture() { +// return "gregtech:textures/gui/" + this.mRecipeMap.mUnlocalizedName + ".png"; + return this.mRecipeMap.mNEIGUIPath; + } + + public List<String> handleItemTooltip(GuiRecipe gui, ItemStack aStack, List<String> currenttip, int aRecipeIndex) { + TemplateRecipeHandler.CachedRecipe tObject = (TemplateRecipeHandler.CachedRecipe) this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + 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 ((gregtech.api.enums.ItemList.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; + } + + public void drawExtras(int aRecipeIndex) { + int tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); + if (recipeDesc == null) { + if (tEUt != 0) { + drawText(10, 73, trans("152","Total: ") + ((long)tDuration * tEUt) + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); + drawText(10, 103, trans("155","Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); + drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); + } + } + if (tDuration > 0) { +// drawText(10, 113, trans("158","Time: ") + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + trans("161"," secs"), -16777216); + drawText(10, 113, String.format("%s%.2f%s", trans("158","Time: "), 0.05 * tDuration, trans("161"," secs")), -16777216); + } + int tSpecial = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; + if (tSpecial == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { + drawText(10, 123, trans("159","Needs Low Gravity"), -16777216); + } else if (tSpecial == -200 && GT_Mod.gregtechproxy.mEnableCleanroom) { + drawText(10, 123, trans("160","Needs Cleanroom"), -16777216); + } else if (tSpecial == -201) { + drawText(10, 123, trans("206","Scan for Assembly Line"), -16777216); + } else if (tSpecial == -300) { + drawText(10, 123, trans("216","Deprecated Recipe"), -16777216); + } else if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); + } + } else { + int i = 0; + for (String descLine : recipeDesc) { + drawText(10, 73 + 10 * i, descLine, -16777216); + i++; + } + } + } + + public static class GT_RectHandler + implements IContainerInputHandler, IContainerTooltipHandler { + public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { + if (canHandle(gui)) { + if (button == 0) { + return transferRect(gui, false); + } + if (button == 1) { + return transferRect(gui, true); + } + } + return false; + } + + public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) { + return false; + } + + public boolean canHandle(GuiContainer gui) { + return (gui instanceof GT_GUIContainer_BasicMachine && GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) + || (gui instanceof GT_GUIContainer_FusionReactor && GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI)); + } + + public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) { + if ((canHandle(gui)) && (currenttip.isEmpty())) { + if (gui instanceof GT_GUIContainer_BasicMachine && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } else if (gui instanceof GT_GUIContainer_PrimitiveBlastFurnace && new Rectangle(51, 10, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_PrimitiveBlastFurnace) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_PrimitiveBlastFurnace) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } + + } + return currenttip; + } + + private boolean transferRect(GuiContainer gui, boolean usage) { + if (gui instanceof GT_GUIContainer_BasicMachine) { + return (canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0])); + } else if (gui instanceof GT_GUIContainer_FusionReactor) { + return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0])); + } + return false; + } + + public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) { + return currenttip; + } + + public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List<String> currenttip) { + return currenttip; + } + + public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) { + return false; + } + + public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { + } + + public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { + } + + public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { + } + + public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { + return false; + } + + public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { + } + + public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { + } + } + + 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); + this.mChance = aChance; + } + + public void generatePermutations() { + if (this.permutated) { + return; + } + ArrayList<ItemStack> tDisplayStacks = new ArrayList<ItemStack>(); + for (ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (Iterator<ItemStack> i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = (ItemStack) i$.next(); + } + } else { + ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = ((ItemStack[]) tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe + extends TemplateRecipeHandler.CachedRecipe { + public final GT_Recipe mRecipe; + public final List<PositionedStack> mOutputs; + public final List<PositionedStack> mInputs; + + public CachedDefaultRecipe(GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + + if (aRecipe.getInputPositionedStacks() != null && aRecipe.getOutputPositionedStacks() != null) { + mInputs = aRecipe.getInputPositionedStacks(); + mOutputs = aRecipe.getOutputPositionedStacks(); + return; + } + + mOutputs = new ArrayList<PositionedStack>(); + mInputs = new ArrayList<PositionedStack>(); + + int tStartIndex = 0; + switch (GTPP_NEI_DefaultHandler.this.mRecipeMap.mUsualInputCount) { + case 0: + break; + case 1: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 2: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 3: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 4: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 5: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 6: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 7: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + break; + case 8: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + break; + default: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 32)); + } + tStartIndex++; + } + if (aRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + switch (GTPP_NEI_DefaultHandler.this.mRecipeMap.mUsualOutputCount) { + case 0: + break; + case 1: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 2: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 3: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 4: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 5: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 6: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 7: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 8: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + default: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + } + if ((aRecipe.mFluidInputs.length > 0) && (aRecipe.mFluidInputs[0] != null) && (aRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[0], true), 48, 52)); + if ((aRecipe.mFluidInputs.length > 1) && (aRecipe.mFluidInputs[1] != null) && (aRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[1], true), 30, 52)); + } + } + if (aRecipe.mFluidOutputs.length > 1) { + if (aRecipe.mFluidOutputs[0] != null && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 120, 5)); + } + if (aRecipe.mFluidOutputs[1] != null && (aRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[1], true), 138, 5)); + } + if (aRecipe.mFluidOutputs.length > 2 && aRecipe.mFluidOutputs[2] != null && (aRecipe.mFluidOutputs[2].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[2], true), 102, 23)); + } + if (aRecipe.mFluidOutputs.length > 3 && aRecipe.mFluidOutputs[3] != null && (aRecipe.mFluidOutputs[3].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[3], true), 120, 23)); + } + if (aRecipe.mFluidOutputs.length > 4 && aRecipe.mFluidOutputs[4] != null && (aRecipe.mFluidOutputs[4].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[4], true), 138, 23)); + } + } else if ((aRecipe.mFluidOutputs.length > 0) && (aRecipe.mFluidOutputs[0] != null) && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 102, 52)); + } + } + + public List<PositionedStack> getIngredients() { + return getCycledIngredients(GTPP_NEI_DefaultHandler.this.cycleticks / 10, this.mInputs); + } + + public PositionedStack getResult() { + return null; + } + + public List<PositionedStack> getOtherStacks() { + return this.mOutputs; + } + } + + public String trans(String aKey, String aEnglish){ + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + } +} diff --git a/src/Java/gtPlusPlus/nei/GTPP_NEI_DefaultHandlerEx.java b/src/Java/gtPlusPlus/nei/GTPP_NEI_DefaultHandlerEx.java new file mode 100644 index 0000000000..8bf048730a --- /dev/null +++ b/src/Java/gtPlusPlus/nei/GTPP_NEI_DefaultHandlerEx.java @@ -0,0 +1,829 @@ +package gtPlusPlus.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.*; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import codechicken.nei.recipe.*; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; +import gregtech.common.gui.GT_GUIContainer_FusionReactor; +import gregtech.common.gui.GT_GUIContainer_PrimitiveBlastFurnace; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GTPP_NEI_DefaultHandlerEx + extends TemplateRecipeHandler { + public static final int sOffsetX = 5; + public static final int sOffsetY = 11; + + static { + GuiContainerManager.addInputHandler(new GT_RectHandler()); + GuiContainerManager.addTooltipHandler(new GT_RectHandler()); + } + + protected final Gregtech_Recipe_Map mRecipeMap; + + public GTPP_NEI_DefaultHandlerEx(Gregtech_Recipe_Map tMap) { + this.mRecipeMap = tMap; + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtech@" + getRecipeName() + "@" + getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public List<GT_Recipe> getSortedRecipes() { + List<GT_Recipe> result = new ArrayList<>(this.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); + } + + public TemplateRecipeHandler newInstance() { + return new GTPP_NEI_DefaultHandlerEx(this.mRecipeMap); + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + for (GT_Recipe tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadCraftingRecipes(ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList<ItemStack> tResults = new ArrayList<ItemStack>(); + 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(new Object[]{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)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + ArrayList<ItemStack> tInputs = new ArrayList<ItemStack>(); + 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(new Object[]{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)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + } + + public String getOverlayIdentifier() { + return this.mRecipeMap.mNEIName; + } + + 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); + } + + public int recipiesPerPage() { + return 1; + } + + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + public String getGuiTexture() { +// return "gregtech:textures/gui/" + this.mRecipeMap.mUnlocalizedName + ".png"; + return this.mRecipeMap.mNEIGUIPath; + } + + public List<String> handleItemTooltip(GuiRecipe gui, ItemStack aStack, List<String> currenttip, int aRecipeIndex) { + TemplateRecipeHandler.CachedRecipe tObject = (TemplateRecipeHandler.CachedRecipe) this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + 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 ((gregtech.api.enums.ItemList.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; + } + + public void drawExtras(int aRecipeIndex) { + int tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); + if (recipeDesc == null) { + if (tEUt != 0) { + drawText(10, 73, trans("152","Total: ") + ((long)tDuration * tEUt) + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); + drawText(10, 103, trans("155","Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); + drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); + } + } + if (tDuration > 0) { +// drawText(10, 113, trans("158","Time: ") + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + trans("161"," secs"), -16777216); + drawText(10, 113, String.format("%s%.2f%s", trans("158","Time: "), 0.05 * tDuration, trans("161"," secs")), -16777216); + } + int tSpecial = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; + if (tSpecial == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { + drawText(10, 123, trans("159","Needs Low Gravity"), -16777216); + } else if (tSpecial == -200 && GT_Mod.gregtechproxy.mEnableCleanroom) { + drawText(10, 123, trans("160","Needs Cleanroom"), -16777216); + } else if (tSpecial == -201) { + drawText(10, 123, trans("206","Scan for Assembly Line"), -16777216); + } else if (tSpecial == -300) { + drawText(10, 123, trans("216","Deprecated Recipe"), -16777216); + } else if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + tSpecial * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); + } + } else { + int i = 0; + for (String descLine : recipeDesc) { + drawText(10, 73 + 10 * i, descLine, -16777216); + i++; + } + } + } + + public static class GT_RectHandler + implements IContainerInputHandler, IContainerTooltipHandler { + public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { + if (canHandle(gui)) { + if (button == 0) { + return transferRect(gui, false); + } + if (button == 1) { + return transferRect(gui, true); + } + } + return false; + } + + public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) { + return false; + } + + public boolean canHandle(GuiContainer gui) { + return (gui instanceof GT_GUIContainer_BasicMachine && GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) + || (gui instanceof GT_GUIContainer_FusionReactor && GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI)); + } + + public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) { + if ((canHandle(gui)) && (currenttip.isEmpty())) { + if (gui instanceof GT_GUIContainer_BasicMachine && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } else if (gui instanceof GT_GUIContainer_PrimitiveBlastFurnace && new Rectangle(51, 10, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_PrimitiveBlastFurnace) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_PrimitiveBlastFurnace) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } + + } + return currenttip; + } + + private boolean transferRect(GuiContainer gui, boolean usage) { + if (gui instanceof GT_GUIContainer_BasicMachine) { + return (canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0])); + } else if (gui instanceof GT_GUIContainer_FusionReactor) { + return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0])); + } + return false; + } + + public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) { + return currenttip; + } + + public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List<String> currenttip) { + return currenttip; + } + + public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) { + return false; + } + + public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { + } + + public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { + } + + public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { + } + + public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { + return false; + } + + public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { + } + + public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { + } + } + + 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); + this.mChance = aChance; + } + + public void generatePermutations() { + if (this.permutated) { + return; + } + ArrayList<ItemStack> tDisplayStacks = new ArrayList<ItemStack>(); + for (ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (Iterator<ItemStack> i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = (ItemStack) i$.next(); + } + } else { + ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = ((ItemStack[]) tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe + extends TemplateRecipeHandler.CachedRecipe { + public final GT_Recipe mRecipe; + public final List<PositionedStack> mOutputs; + public final List<PositionedStack> mInputs; + + public CachedDefaultRecipe(GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + + if (aRecipe.getInputPositionedStacks() != null && aRecipe.getOutputPositionedStacks() != null) { + mInputs = aRecipe.getInputPositionedStacks(); + mOutputs = aRecipe.getOutputPositionedStacks(); + return; + } + + mOutputs = new ArrayList<PositionedStack>(); + mInputs = new ArrayList<PositionedStack>(); + + int tStartIndex = 0; + switch (GTPP_NEI_DefaultHandlerEx.this.mRecipeMap.mUsualInputCount) { + case 0: + break; + case 1: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 2: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 3: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + break; + case 4: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 5: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 6: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 5)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 23)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 23)); + } + tStartIndex++; + break; + case 7: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + break; + case 8: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + break; + default: + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, -4)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 12, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 30, 32)); + } + tStartIndex++; + if (aRecipe.getRepresentativeInput(tStartIndex) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 32)); + } + tStartIndex++; + } + if (aRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); + } + tStartIndex = 0; + switch (GTPP_NEI_DefaultHandlerEx.this.mRecipeMap.mUsualOutputCount) { + case 0: + break; + case 1: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 2: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 3: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 4: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 5: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 6: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 5, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 23, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 7: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + case 8: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + break; + default: + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, -4, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 14, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 120, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + if (aRecipe.getOutput(tStartIndex) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 138, 32, aRecipe.getOutputChance(tStartIndex))); + } + tStartIndex++; + } + if ((aRecipe.mFluidInputs.length > 0) && (aRecipe.mFluidInputs[0] != null) && (aRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[0], true), 48, 52)); + if ((aRecipe.mFluidInputs.length > 1) && (aRecipe.mFluidInputs[1] != null) && (aRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[1], true), 30, 52)); + } + } + if (aRecipe.mFluidOutputs.length > 1) { + if (aRecipe.mFluidOutputs[0] != null && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 120, 5)); + } + if (aRecipe.mFluidOutputs[1] != null && (aRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[1], true), 138, 5)); + } + if (aRecipe.mFluidOutputs.length > 2 && aRecipe.mFluidOutputs[2] != null && (aRecipe.mFluidOutputs[2].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[2], true), 102, 23)); + } + if (aRecipe.mFluidOutputs.length > 3 && aRecipe.mFluidOutputs[3] != null && (aRecipe.mFluidOutputs[3].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[3], true), 120, 23)); + } + if (aRecipe.mFluidOutputs.length > 4 && aRecipe.mFluidOutputs[4] != null && (aRecipe.mFluidOutputs[4].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[4], true), 138, 23)); + } + } else if ((aRecipe.mFluidOutputs.length > 0) && (aRecipe.mFluidOutputs[0] != null) && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 102, 52)); + } + } + + public List<PositionedStack> getIngredients() { + return getCycledIngredients(GTPP_NEI_DefaultHandlerEx.this.cycleticks / 10, this.mInputs); + } + + public PositionedStack getResult() { + return null; + } + + public List<PositionedStack> getOtherStacks() { + return this.mOutputs; + } + } + + public String trans(String aKey, String aEnglish){ + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + } +} diff --git a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java index 32d2a464f9..0a0ba9b9e8 100644 --- a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java +++ b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java @@ -3,7 +3,10 @@ package gtPlusPlus.nei; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; import gregtech.api.util.CustomRecipeMap; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.Recipe_GT; import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; +import gregtech.nei.GT_NEI_DefaultHandler; import gtPlusPlus.api.objects.data.AutoMap; public class NEI_GT_Config @@ -21,15 +24,27 @@ implements IConfigureNEI { mUniqueRecipeMapHandling.add(Gregtech_Recipe_Map.sFlotationCellRecipes.mUnlocalizedName); mUniqueRecipeMapHandling.add(Gregtech_Recipe_Map.sVacuumFurnaceRecipes.mUnlocalizedName); - for (final CustomRecipeMap tMap : gregtech.api.util.CustomRecipeMap.sMappings) { + // Custom Recipe Maps + for (final CustomRecipeMap tMap : CustomRecipeMap.sMappings) { if (tMap.mNEIAllowed) { - new GT_NEI_DefaultHandler(tMap); + new GTPP_NEI_CustomMapHandler(tMap); } } - for (final Gregtech_Recipe_Map tMap : gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map.sMappings) { + + // Custom Recipe maps + for (final Gregtech_Recipe_Map tMap : Recipe_GT.Gregtech_Recipe_Map.sMappings) { + if (tMap.mNEIAllowed) { + if (!mUniqueRecipeMapHandling.contains(tMap.mUnlocalizedName)) { + new GTPP_NEI_DefaultHandler(tMap); + } + } + } + + // Standard GT Recipe Maps + for (final GT_Recipe_Map tMap : Recipe_GT.GTPP_Recipe_Map.sMappingsEx) { if (tMap.mNEIAllowed) { if (!mUniqueRecipeMapHandling.contains(tMap.mUnlocalizedName)) { - new GT_NEI_MultiBlockHandler(tMap); + new GT_NEI_DefaultHandler(tMap); } } } |