From 50db10656a85c8b4e64b5bcdaa497b933b4e6196 Mon Sep 17 00:00:00 2001 From: Jordan Byrne Date: Fri, 20 Apr 2018 00:14:08 +1000 Subject: ^ Version bump to 1.7.0-pre11-final. $ Fixed many .08 compat issues stemming from use of newer NEI handler features in .09. $ Redid a lot of GT_Recipe and Recipe_GT handling. $ Fix to Adv. Vacuum Freezer recipe handling. $ Fixed NEI not loading Multiblock Handler. $ Fixed various crashed from NEI. --- .../api/interfaces/IComparableRecipe.java | 8 + src/Java/gtPlusPlus/core/lib/CORE.java | 2 +- .../gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java | 941 +++++++++++++++++++++ src/Java/gtPlusPlus/nei/NEI_GT_Config.java | 6 + .../GT_MetaTileEntity_Hatch_AirIntake.java | 55 +- .../api/util/GregtechOreDictUnificator.java | 846 +++++++++--------- .../api/util/GregtechRecipeRegistrator.java | 371 -------- ...techMetaTileEntity_IndustrialVacuumFreezer.java | 14 +- 8 files changed, 1401 insertions(+), 842 deletions(-) create mode 100644 src/Java/gtPlusPlus/api/interfaces/IComparableRecipe.java create mode 100644 src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechRecipeRegistrator.java (limited to 'src/Java/gtPlusPlus') diff --git a/src/Java/gtPlusPlus/api/interfaces/IComparableRecipe.java b/src/Java/gtPlusPlus/api/interfaces/IComparableRecipe.java new file mode 100644 index 0000000000..5d79fd8a51 --- /dev/null +++ b/src/Java/gtPlusPlus/api/interfaces/IComparableRecipe.java @@ -0,0 +1,8 @@ +package gtPlusPlus.api.interfaces; + +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.Recipe_GT; + +public interface IComparableRecipe extends Comparable{ + +} diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 21f8163fbb..93f40ef737 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -48,7 +48,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.7.0-prerelease-10-final"; + public static final String VERSION = "1.7.0-prerelease-11-final"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java new file mode 100644 index 0000000000..1ac33106e2 --- /dev/null +++ b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java @@ -0,0 +1,941 @@ +package gtPlusPlus.nei; + +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.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.api.util.GregtechOreDictUnificator; + +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; + +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; +import org.lwjgl.opengl.GL11; + +import java.awt.Point; +import java.awt.Rectangle; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; + +public class GT_NEI_MultiBlockHandler +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 Recipe_GT.Gregtech_Recipe_Map mRecipeMap; + + public GT_NEI_MultiBlockHandler(Gregtech_Recipe_Map aRecipeMap) { + this.mRecipeMap = aRecipeMap; + 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 getSortedRecipes() { + List result = new ArrayList<>(this.mRecipeMap.mRecipeList); + //List resultReal = new ArrayList(); + /*for (Recipe_GT g : this.mRecipeMap.mRecipeList) { + + } + this.mRecipeMap.findRecipe(null, aRecipe, aNotUnificated, aVoltage, aFluids, fluidStacks)*/ + //result.sort(new recipeCompare()); + 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 GT_NEI_MultiBlockHandler(this.mRecipeMap); + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + for (Recipe_GT 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 tResults = new ArrayList(); + tResults.add(aResult); + tResults.add(GT_OreDictUnificator.get(true, aResult)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); + if (tFluid != null) { + tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tResults.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (Recipe_GT 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; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + + ArrayList tInputs = new ArrayList(); + tInputs.add(aInput); + tInputs.add(GT_OreDictUnificator.get(false, aInput)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + if (tFluid != null) { + tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tInputs.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (Recipe_GT 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; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + 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 handleItemTooltip(GuiRecipe gui, ItemStack aStack, List 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(); + String[] recipeDesc = null; + 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 ((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)); + } + + public List handleTooltip(GuiContainer gui, int mousex, int mousey, List 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"); + } + } + 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])); + } + return false; + } + + public List handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List currenttip) { + return currenttip; + } + + public List handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List 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(getNonUnifiedStacks(object), x, y, true); + this.mChance = aChance; + } + + public void generatePermutations() { + if (this.permutated) { + return; + } + ArrayList tDisplayStacks = new ArrayList(); + for (ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + List permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (Iterator 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 Recipe_GT mRecipe; + public final List mOutputs; + public final List mInputs; + + public CachedDefaultRecipe(Recipe_GT aRecipe) { + super(); + this.mRecipe = aRecipe; + + if (aRecipe.getInputPositionedStacks() != null && aRecipe.getOutputPositionedStacks() != null) { + mInputs = aRecipe.getInputPositionedStacks(); + mOutputs = aRecipe.getOutputPositionedStacks(); + return; + } + + mOutputs = new ArrayList(); + mInputs = new ArrayList(); + + int tStartIndex = 0; + switch (GT_NEI_MultiBlockHandler.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 (GT_NEI_MultiBlockHandler.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 getIngredients() { + return getCycledIngredients(GT_NEI_MultiBlockHandler.this.cycleticks / 10, this.mInputs); + } + + public PositionedStack getResult() { + return null; + } + + public List getOtherStacks() { + return this.mOutputs; + } + } + + public String trans(String aKey, String aEnglish){ + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); + } + + public static Map sUnifTable; + public static Map sNametoStackTable; + public static Map> sItemToDataTable; + public static Field sFields[] = new Field[3]; + public static Method sMethods[] = new Method[2]; + + @SuppressWarnings("unchecked") + private static final void setVars() { + try { + //Set Fields + for (int u=0;u<3;u++) { + if (sFields[u] == null) { + if (u==0) { + sFields[0] = ReflectionUtils.getField(GT_OreDictUnificator.class, "sUnificationTable"); + if (sFields[0] == null) { + ReflectionUtils.getField(GregtechOreDictUnificator.class, "sUnificationTable"); + } + } + else if (u==1) { + sFields[1] = ReflectionUtils.getField(GT_OreDictUnificator.class, "sName2StackMap"); + } + else if (u==2) { + sFields[2] = ReflectionUtils.getField(GT_OreDictUnificator.class, "sItemStack2DataMap"); + } + } + } + + //Set Method + if (sMethods[0] == null) { + sMethods[0] = GT_OreDictUnificator.class.getMethod("get", boolean.class, ItemStack.class, boolean.class); + } + + //Set Local Fields + sUnifTable = (Map) sFields[0].get(null); + sNametoStackTable = (Map) sFields[1].get(null); + sItemToDataTable = (Map>) sFields[2].get(null); + + } + catch (Throwable T) { + + } + } + + public static List getNonUnifiedStacks(Object obj) { + setVars(); + if (sUnifTable != null) + synchronized (sUnifTable) { + if (sUnifTable.isEmpty() && !sItemToDataTable.isEmpty()) { + for (GT_ItemStack tGTStack0 : sItemToDataTable.keySet()) { + ItemStack tStack0 = tGTStack0.toStack(); + ItemStack tStack1 = null; + try { + tStack1 = (ItemStack) sMethods[0].invoke(null, false, tStack0, true); + } + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + GregtechOreDictUnificator.get(false, tStack0, true); + } + + if (tStack0 != null && tStack1 != null && !GT_Utility.areStacksEqual(tStack0, tStack1)) { + GT_ItemStack tGTStack1 = new GT_ItemStack(tStack1); + List list = sItemToDataTable.get(tGTStack1); + if (list == null) sItemToDataTable.put(tGTStack1, list = new ArrayList()); + if (!list.contains(tStack0)) list.add(tStack0); + } + } + } + } + ItemStack[] aStacks = {}; + if (obj instanceof ItemStack) aStacks = new ItemStack[]{(ItemStack) obj}; + else if (obj instanceof ItemStack[]) aStacks = (ItemStack[]) obj; + else if (obj instanceof List) aStacks = (ItemStack[]) ((List)obj).toArray(new ItemStack[0]); + List rList = new ArrayList(); + for (ItemStack aStack : aStacks) { + rList.add(aStack); + if (sItemToDataTable != null) { + List tList = sItemToDataTable.get(new GT_ItemStack(aStack)); + if (tList != null) { + for (ItemStack tStack : tList) { + ItemStack tStack1 = GT_Utility.copyAmount(aStack.stackSize, tStack); + tStack1.setTagCompound(aStack.getTagCompound()); + rList.add(tStack1); + } + } + } + } + return rList; + + //List x = new ArrayList(); + //return x; + } + + + public class recipeCompare implements Comparator { + public int compare(GT_Recipe a, GT_Recipe b) { + if (a.mEUt != b.mEUt) { + return a.mEUt - b.mEUt; + } else if (a.mDuration != b.mDuration) { + return a.mDuration - b.mDuration; + } else if (a.mSpecialValue != b.mSpecialValue) { + return a.mSpecialValue - b.mSpecialValue; + } else if (a.mFluidInputs.length != b.mFluidInputs.length) { + return a.mFluidInputs.length - b.mFluidInputs.length; + } else if (a.mInputs.length != b.mInputs.length) { + return a.mInputs.length - b.mInputs.length; + } + return 0; + } + } + + + +} diff --git a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java index 4ba55babad..aca6dd5662 100644 --- a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java +++ b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java @@ -1,6 +1,7 @@ package gtPlusPlus.nei; import gregtech.api.util.CustomRecipeMap; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; import codechicken.nei.api.IConfigureNEI; @@ -16,6 +17,11 @@ implements IConfigureNEI { new GT_NEI_DefaultHandler(tMap); } } + for (final Gregtech_Recipe_Map tMap : gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map.sMappings) { + if (tMap.mNEIAllowed) { + new GT_NEI_MultiBlockHandler(tMap); + } + } sIsAdded = true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java index 85387590e6..80f4b984da 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_AirIntake.java @@ -7,10 +7,14 @@ import net.minecraft.item.ItemStack; import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +import java.lang.reflect.Field; + import net.minecraft.entity.player.EntityPlayer; import gregtech.api.interfaces.IIconContainer; import gregtech.api.objects.GT_RenderedTexture; @@ -30,18 +34,51 @@ public class GT_MetaTileEntity_Hatch_AirIntake extends GT_MetaTileEntity_Hatch_I super(aName, aTier, aDescription, aTextures); } - public GT_MetaTileEntity_Hatch_AirIntake(final String aName, final int aTier, final String[] aDescription, + /*public GT_MetaTileEntity_Hatch_AirIntake(final String aName, final int aTier, final String[] aDescription, final ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); - } + }*/ + + private static String[] S; + private static Field F; + + public synchronized String[] getDescription() { + try { + if (F == null || S == null) { + if (ReflectionUtils.getField(this.getClass(), "mDescriptionArray") != null) { + F = ReflectionUtils.getField(this.getClass(), "mDescriptionArray"); + } + else { + F = ReflectionUtils.getField(this.getClass(), "mDescription"); + } + if (S == null && F != null) { + Object o = F.get(this); + if (o instanceof String[]) { + S = (String[]) o; + } + else if (o instanceof String) { + S = new String[] {(String) o}; + } + } + + } + } + catch (Throwable t) { + + } + if (S != null) { + final String[] desc = new String[S.length + 3]; + System.arraycopy(S, 0, desc, 0, S.length); + desc[S.length] = "DO NOT OBSTRUCT THE INPUT!"; + desc[S.length + 1] = "Draws in Air from the surrounding environment"; + desc[S.length + 2] = "Creates 1000L of Air every 4 ticks"; + return desc; + } + else { + return new String[] {"DO NOT OBSTRUCT THE INPUT!", "Draws in Air from the surrounding environment", "Creates 1000L of Air every 4 ticks"}; + } + - public String[] getDescription() { - final String[] desc = new String[this.mDescriptionArray.length + 3]; - System.arraycopy(this.mDescriptionArray, 0, desc, 0, this.mDescriptionArray.length); - desc[this.mDescriptionArray.length] = "DO NOT OBSTRUCT THE INPUT!"; - desc[this.mDescriptionArray.length + 1] = "Draws in Air from the surrounding environment."; - desc[this.mDescriptionArray.length + 2] = "Creates 1000L of Air every 4 ticks"; - return desc; } public ITexture[] getTexturesActive(final ITexture aBaseTexture) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java index 28249ebfb5..69c95bc1ff 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java @@ -1,473 +1,405 @@ package gtPlusPlus.xmod.gregtech.api.util; -import static gregtech.api.enums.GT_Values.*; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.SubTag; import gregtech.api.objects.GT_HashSet; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import gregtech.common.GT_Proxy.OreDictEventContainer; - -import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; -import gtPlusPlus.xmod.gregtech.api.objects.GregtechItemData; -import gtPlusPlus.xmod.gregtech.api.objects.GregtechMaterialStack; -import net.minecraftforge.oredict.OreDictionary; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * This is the Core of my OreDict Unification Code - *

- * If you just want to use this to unificate your Items, then use the Function in the GregTech_API File - *

- * P.S. It is intended to be named "Unificator" and not "Unifier", because that sounds more awesome. - */ -public class GregtechOreDictUnificator { - private static final HashMap sName2StackMap = new HashMap<>(); - private static final HashMap sItemStack2DataMap = new HashMap<>(); - private static final GT_HashSet sNoUnificationList = new GT_HashSet<>(); - public static volatile int VERSION = 508; - private static int isRegisteringOre = 0, isAddingOre = 0; - private static boolean mRunThroughTheList = true; - - static { - GregTech_API.sItemStackMappings.add(sItemStack2DataMap); - } - - /** - * The Blacklist just prevents the Item from being unificated into something else. - * Useful if you have things like the Industrial Diamond, which is better than regular Diamond, but also usable in absolutely all Diamond Recipes. - */ - public static void addToBlacklist(final ItemStack aStack) { - if (GT_Utility.isStackValid(aStack) && !GT_Utility.isStackInList(aStack, sNoUnificationList)) { - sNoUnificationList.add(aStack); - } - } - - public static boolean isBlacklisted(final ItemStack aStack) { - return GT_Utility.isStackInList(aStack, sNoUnificationList); - } - - public static void add(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final ItemStack aStack) { - set(aPrefix, aMaterial, aStack, false, false); - } - - public static void set(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final ItemStack aStack) { - set(aPrefix, aMaterial, aStack, true, false); - } - - public static void set(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, ItemStack aStack, final boolean aOverwrite, final boolean aAlreadyRegistered) { - if ((aMaterial == null) || (aPrefix == null) || GT_Utility.isStackInvalid(aStack) || (Items.feather.getDamage(aStack) == W)) { - return; - } - isAddingOre++; - aStack = GT_Utility.copyAmount(1, aStack); - if (!aAlreadyRegistered) { - registerOre(aPrefix.get(aMaterial), aStack); - } - addAssociation(aPrefix, aMaterial, aStack, isBlacklisted(aStack)); - if (aOverwrite || GT_Utility.isStackInvalid(sName2StackMap.get(aPrefix.get(aMaterial).toString()))) { - sName2StackMap.put(aPrefix.get(aMaterial).toString(), aStack); - } - isAddingOre--; - } - - public static ItemStack getFirstOre(final Object aName, final long aAmount) { - if (GT_Utility.isStringInvalid(aName)) { - return null; - } - final ItemStack tStack = sName2StackMap.get(aName.toString()); - if (GT_Utility.isStackValid(tStack)) { - return GT_Utility.copyAmount(aAmount, tStack); - } - return GT_Utility.copyAmount(aAmount, getOres(aName).toArray()); - } - - public static ItemStack get(final Object aName, final long aAmount) { - return get(aName, null, aAmount, true, true); - } - - public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount) { - return get(aName, aReplacement, aAmount, true, true); - } - - public static ItemStack get(final GregtechOrePrefixes aPrefix, final Object aMaterial, final long aAmount) { - return get(aPrefix, aMaterial, null, aAmount); - } - - public static ItemStack get(final GregtechOrePrefixes aPrefix, final Object aMaterial, final ItemStack aReplacement, final long aAmount) { - return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); - } - - public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount, final boolean aMentionPossibleTypos, final boolean aNoInvalidAmounts) { - if (aNoInvalidAmounts && (aAmount < 1)) { - return null; - } - if (!sName2StackMap.containsKey(aName.toString()) && aMentionPossibleTypos) { - GT_Log.err.println("Unknown Key for Unification, Typo? " + aName); - } - return GT_Utility.copyAmount(aAmount, sName2StackMap.get(aName.toString()), getFirstOre(aName, aAmount), aReplacement); - } - - public static ItemStack[] setStackArray(final boolean aUseBlackList, final ItemStack... aStacks) { - for (int i = 0; i < aStacks.length; i++) { - aStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i])); - } - return aStacks; - } - - public static ItemStack[] getStackArray(final boolean aUseBlackList, final Object... aStacks) { - final ItemStack[] rStacks = new ItemStack[aStacks.length]; - for (int i = 0; i < aStacks.length; i++) { - rStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i])); - } - return rStacks; - } - - public static ItemStack setStack(final ItemStack aStack) { - return setStack(true, aStack); - } - - public static ItemStack setStack(final boolean aUseBlackList, final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return aStack; - } - final ItemStack tStack = get(aUseBlackList, aStack); - if (GT_Utility.areStacksEqual(aStack, tStack)) { - return aStack; - } - aStack.func_150996_a(tStack.getItem()); - Items.feather.setDamage(aStack, Items.feather.getDamage(tStack)); - return aStack; - } - - public static ItemStack get(final ItemStack aStack) { - return get(true, aStack); - } - - public static ItemStack get(final boolean aUseBlackList, final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return null; - } - final GregtechItemData tPrefixMaterial = getAssociation(aStack); - ItemStack rStack = null; - if ((tPrefixMaterial == null) || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed)) { - return GT_Utility.copy(aStack); - } - if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { - tPrefixMaterial.mBlackListed = true; - return GT_Utility.copy(aStack); - } - if (tPrefixMaterial.mUnificationTarget == null) { - tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); - } - rStack = tPrefixMaterial.mUnificationTarget; - if (GT_Utility.isStackInvalid(rStack)) { - return GT_Utility.copy(aStack); - } - assert rStack != null; - rStack.setTagCompound(aStack.getTagCompound()); - return GT_Utility.copyAmount(aStack.stackSize, rStack); - } - - public static void addItemData(final ItemStack aStack, final GregtechItemData aData) { - if (GT_Utility.isStackValid(aStack) && (getItemData(aStack) == null) && (aData != null)) { - setItemData(aStack, aData); - } - } - - public static void setItemData(ItemStack aStack, final GregtechItemData aData) { - if (GT_Utility.isStackInvalid(aStack) || (aData == null)) { - return; - } - final GregtechItemData tData = getItemData(aStack); - if ((tData == null) || !tData.hasValidPrefixMaterialData()) { - if (tData != null) { - for (final Object tObject : tData.mExtraData) { - if (!aData.mExtraData.contains(tObject)) { - aData.mExtraData.add(tObject); - } - } - } - if (aStack.stackSize > 1) { - if (aData.mMaterial != null) { - aData.mMaterial.mAmount /= aStack.stackSize; - } - for (final GregtechMaterialStack tMaterial : aData.mByProducts) { - tMaterial.mAmount /= aStack.stackSize; - } - aStack = GT_Utility.copyAmount(1, aStack); - } - sItemStack2DataMap.put(new GT_ItemStack(aStack), aData); - if (aData.hasValidMaterialData()) { - long tValidMaterialAmount = aData.mMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : aData.mMaterial.mAmount >= 0 ? aData.mMaterial.mAmount : M; - for (final GregtechMaterialStack tMaterial : aData.mByProducts) { - tValidMaterialAmount += tMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 : tMaterial.mAmount >= 0 ? tMaterial.mAmount : M; - } - if (tValidMaterialAmount < M) { - GT_ModHandler.addToRecyclerBlackList(aStack); - } - } - if (mRunThroughTheList) { - if (GregTech_API.sLoadStarted) { - mRunThroughTheList = false; - for (final Entry tEntry : sItemStack2DataMap.entrySet()) { - if (!tEntry.getValue().hasValidPrefixData() || tEntry.getValue().mPrefix.mAllowNormalRecycling) { - GregtechRecipeRegistrator.registerMaterialRecycling(tEntry.getKey().toStack(), tEntry.getValue()); - } - } - } - } else { - if (!aData.hasValidPrefixData() || aData.mPrefix.mAllowNormalRecycling) { - GregtechRecipeRegistrator.registerMaterialRecycling(aStack, aData); - } - } - } else { - for (final Object tObject : aData.mExtraData) { - if (!tData.mExtraData.contains(tObject)) { - tData.mExtraData.add(tObject); - } - } - } - } - - public static void addAssociation(final GregtechOrePrefixes aPrefix, final GT_Materials aMaterial, final ItemStack aStack, final boolean aBlackListed) { - if ((aPrefix == null) || (aMaterial == null) || GT_Utility.isStackInvalid(aStack)) { - return; - } - if (Items.feather.getDamage(aStack) == W) { - for (byte i = 0; i < 16; i++) { - setItemData(GT_Utility.copyAmountAndMetaData(1, i, aStack), new GregtechItemData(aPrefix, aMaterial, aBlackListed)); - } - } - setItemData(aStack, new GregtechItemData(aPrefix, aMaterial, aBlackListed)); - } - - public static GregtechItemData getItemData(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return null; - } - GregtechItemData rData = sItemStack2DataMap.get(new GT_ItemStack(aStack)); - if (rData == null) { - rData = sItemStack2DataMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack))); - } - return rData; - } +import gregtech.api.objects.ItemData; +import gregtech.api.objects.MaterialStack; +import gregtech.api.util.*; - public static GregtechItemData getAssociation(final ItemStack aStack) { - final GregtechItemData rData = getItemData(aStack); - return (rData != null) && rData.hasValidPrefixMaterialData() ? rData : null; - } +import gtPlusPlus.core.util.reflect.ReflectionUtils; - public static boolean isItemStackInstanceOf(final ItemStack aStack, final Object aName) { - if (GT_Utility.isStringInvalid(aName) || GT_Utility.isStackInvalid(aStack)) { - return false; - } - for (final ItemStack tOreStack : getOres(aName.toString())) { - if (GT_Utility.areStacksEqual(tOreStack, aStack, true)) { - return true; - } - } - return false; - } +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; - public static boolean isItemStackDye(final ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) { - return false; - } - for (final Dyes tDye : Dyes.VALUES) { - if (isItemStackInstanceOf(aStack, tDye.toString())) { - return true; - } - } - return false; - } +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; - public static boolean registerOre(final GregtechOrePrefixes aPrefix, final Object aMaterial, final ItemStack aStack) { - return registerOre(aPrefix.get(aMaterial), aStack); - } +import static gregtech.api.enums.GT_Values.*; - public static boolean registerOre(final Object aName, final ItemStack aStack) { - if ((aName == null) || GT_Utility.isStackInvalid(aStack)) { - return false; - } - final String tName = aName.toString(); - if (GT_Utility.isStringInvalid(tName)) { - return false; - } - final ArrayList tList = getOres(tName); - for (int i = 0; i < tList.size(); i++) { - if (GT_Utility.areStacksEqual(tList.get(i), aStack, true)) { - return false; +public class GregtechOreDictUnificator { + + + private static final Map sName2StackMap = new HashMap(); + private static final Map sItemStack2DataMap = new HashMap(); + private static final Map> sUnificationTable = new HashMap>(); + private static final GT_HashSet sNoUnificationList = new GT_HashSet(); + + + private static int isRegisteringOre = 0, isAddingOre = 0; + private static boolean mRunThroughTheList = true; + + static { + try { + if (ReflectionUtils.getField(GT_OreDictUnificator.class, "sUnificationTable") == null) { + GregTech_API.sItemStackMappings.add(sUnificationTable); } } - isRegisteringOre++; - OreDictionary.registerOre(tName, GT_Utility.copyAmount(1, aStack)); - isRegisteringOre--; - return true; - } - - public static boolean isRegisteringOres() { - return isRegisteringOre > 0; - } - - public static boolean isAddingOres() { - return isAddingOre > 0; - } - - public static void resetUnificationEntries() { - for (final GregtechItemData tPrefixMaterial : sItemStack2DataMap.values()) { - tPrefixMaterial.mUnificationTarget = null; - } - } - - public static ItemStack getGem(final GregtechMaterialStack aMaterial) { - return aMaterial == null ? null : getGem(aMaterial.mMaterial, aMaterial.mAmount); - } - - public static ItemStack getGem(final GT_Materials aMaterial, final OrePrefixes aPrefix) { - return aMaterial == null ? null : getGem(aMaterial, aPrefix.mMaterialAmount); - } - - public static ItemStack getGem(final GT_Materials aMaterial, final long aMaterialAmount) { - ItemStack rStack = null; - if (((aMaterialAmount >= M) || (aMaterialAmount >= (M * 32)))) { - rStack = get(GregtechOrePrefixes.gem, aMaterial, aMaterialAmount / M); - } - if ((rStack == null) && ((((aMaterialAmount * 2) % M) == 0) || (aMaterialAmount >= (M * 16)))) { - rStack = get(GregtechOrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M); - } - if ((rStack == null) && (((aMaterialAmount * 4) >= M))) { - rStack = get(GregtechOrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / M); - } - return rStack; - } - - public static ItemStack getDust(final GregtechMaterialStack aMaterial) { - return aMaterial == null ? null : getDust(aMaterial.mMaterial, aMaterial.mAmount); - } - - public static ItemStack getDust(final GT_Materials aMaterial, final OrePrefixes aPrefix) { - return aMaterial == null ? null : getDust(aMaterial, aPrefix.mMaterialAmount); - } - - public static ItemStack getDust(final GT_Materials aMaterial, final long aMaterialAmount) { - if (aMaterialAmount <= 0) { - return null; - } - ItemStack rStack = null; - if ((((aMaterialAmount % M) == 0) || (aMaterialAmount >= (M * 16)))) { - rStack = get(GregtechOrePrefixes.dust, aMaterial, aMaterialAmount / M); - } - if ((rStack == null) && ((((aMaterialAmount * 4) % M) == 0) || (aMaterialAmount >= (M * 8)))) { - rStack = get(GregtechOrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M); - } - if ((rStack == null) && (((aMaterialAmount * 9) >= M))) { - rStack = get(GregtechOrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M); - } - return rStack; - } - - public static ItemStack getIngot(final GregtechMaterialStack aMaterial) { - return aMaterial == null ? null : getIngot(aMaterial.mMaterial, aMaterial.mAmount); - } - - public static ItemStack getIngot(final GT_Materials aMaterial, final OrePrefixes aPrefix) { - return aMaterial == null ? null : getIngot(aMaterial, aPrefix.mMaterialAmount); - } - - public static ItemStack getIngot(final GT_Materials aMaterial, final long aMaterialAmount) { - if (aMaterialAmount <= 0) { - return null; - } - ItemStack rStack = null; - if (((((aMaterialAmount % (M * 9)) == 0) && ((aMaterialAmount / (M * 9)) > 1)) || (aMaterialAmount >= (M * 72)))) { - rStack = get(GregtechOrePrefixes.block, aMaterial, aMaterialAmount / (M * 9)); - } - if ((rStack == null) && (((aMaterialAmount % M) == 0) || (aMaterialAmount >= (M * 8)))) { - rStack = get(GregtechOrePrefixes.ingot, aMaterial, aMaterialAmount / M); - } - if ((rStack == null) && (((aMaterialAmount * 9) >= M))) { - rStack = get(GregtechOrePrefixes.nugget, aMaterial, (aMaterialAmount * 9) / M); - } - return rStack; - } - - public static ItemStack getIngotOrDust(final GT