diff options
author | Jordan Byrne <draknyte1@hotmail.com> | 2018-04-20 00:14:08 +1000 |
---|---|---|
committer | Jordan Byrne <draknyte1@hotmail.com> | 2018-04-20 00:14:08 +1000 |
commit | 50db10656a85c8b4e64b5bcdaa497b933b4e6196 (patch) | |
tree | b11c9b7f0f30b8f7ba95df726aa73b98dc99d667 /src/Java/gtPlusPlus | |
parent | ada14a51bd79b68ad37ff69ef0ad69610b7c73a6 (diff) | |
download | GT5-Unofficial-50db10656a85c8b4e64b5bcdaa497b933b4e6196.tar.gz GT5-Unofficial-50db10656a85c8b4e64b5bcdaa497b933b4e6196.tar.bz2 GT5-Unofficial-50db10656a85c8b4e64b5bcdaa497b933b4e6196.zip |
^ 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.
Diffstat (limited to 'src/Java/gtPlusPlus')
8 files changed, 1401 insertions, 842 deletions
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<GT_Recipe>{ + +} 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<Recipe_GT> getSortedRecipes() { + List<Recipe_GT> result = new ArrayList<>(this.mRecipeMap.mRecipeList); + //List<Recipe_GT> resultReal = new ArrayList<Recipe_GT>(); + /*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<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 (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<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 (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<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(); + 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<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"); + } + } + 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<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(getNonUnifiedStacks(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 Recipe_GT mRecipe; + public final List<PositionedStack> mOutputs; + public final List<PositionedStack> 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<PositionedStack>(); + mInputs = new ArrayList<PositionedStack>(); + + 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<PositionedStack> getIngredients() { + return getCycledIngredients(GT_NEI_MultiBlockHandler.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); + } + + public static Map<String, ItemStack> sUnifTable; + public static Map<GT_ItemStack, ItemData> sNametoStackTable; + public static Map<GT_ItemStack, List<ItemStack>> 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<String, ItemStack>) sFields[0].get(null); + sNametoStackTable = (Map<GT_ItemStack, ItemData>) sFields[1].get(null); + sItemToDataTable = (Map<GT_ItemStack, List<ItemStack>>) sFields[2].get(null); + + } + catch (Throwable T) { + + } + } + + public static List<ItemStack> 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<ItemStack> list = sItemToDataTable.get(tGTStack1); + if (list == null) sItemToDataTable.put(tGTStack1, list = new ArrayList<ItemStack>()); + 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<ItemStack> rList = new ArrayList<ItemStack>(); + for (ItemStack aStack : aStacks) { + rList.add(aStack); + if (sItemToDataTable != null) { + List<ItemStack> 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<ItemStack> x = new ArrayList<ItemStack>(); + //return x; + } + + + public class recipeCompare implements Comparator<GT_Recipe> { + 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!!! - * <p/> - * This is the Core of my OreDict Unification Code - * <p/> - * If you just want to use this to unificate your Items, then use the Function in the GregTech_API File - * <p/> - * P.S. It is intended to be named "Unificator" and not "Unifier", because that sounds more awesome. - */ -public class GregtechOreDictUnificator { - private static final HashMap<String, ItemStack> sName2StackMap = new HashMap<>(); - private static final HashMap<GT_ItemStack, GregtechItemData> sItemStack2DataMap = new HashMap<>(); - private static final GT_HashSet<GT_ItemStack> 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<GT_ItemStack, GregtechItemData> 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<ItemStack> 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<String, ItemStack> sName2StackMap = new HashMap<String, ItemStack>(); + private static final Map<GT_ItemStack, ItemData> sItemStack2DataMap = new HashMap<GT_ItemStack, ItemData>(); + private static final Map<GT_ItemStack, List<ItemStack>> sUnificationTable = new HashMap<GT_ItemStack, List<ItemStack>>(); + private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<GT_ItemStack>(); + + + 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_Materials aMaterial, final long aMaterialAmount) { - if (aMaterialAmount <= 0) { - return null; - } - ItemStack rStack = getIngot(aMaterial, aMaterialAmount); - if (rStack == null) { - rStack = getDust(aMaterial, aMaterialAmount); - } - return rStack; - } - - public static ItemStack getIngotOrDust(final GregtechMaterialStack aMaterial) { - ItemStack rStack = getIngot(aMaterial); - if((aMaterial!=null)&&(aMaterial.mMaterial!=null)) { - rStack = getDust(aMaterial); - } - if (rStack == null) { - rStack = getDust(aMaterial); - } - return rStack; - } - - public static ItemStack getDustOrIngot(final GT_Materials aMaterial, final long aMaterialAmount) { - if (aMaterialAmount <= 0) { - return null; - } - ItemStack rStack = getDust(aMaterial, aMaterialAmount); - if (rStack == null) { - rStack = getIngot(aMaterial, aMaterialAmount); - } - return rStack; - } - - public static ItemStack getDustOrIngot(final GregtechMaterialStack aMaterial) { - ItemStack rStack = getDust(aMaterial); - if (rStack == null) { - rStack = getIngot(aMaterial); - } - return rStack; - } - - /** - * @return a Copy of the OreDictionary.getOres() List - */ - public static ArrayList<ItemStack> getOres(final OrePrefixes aPrefix, final Object aMaterial) { - return getOres(aPrefix.get(aMaterial)); - } - - /** - * @return a Copy of the OreDictionary.getOres() List - */ - public static ArrayList<ItemStack> getOres(final Object aOreName) { - final String aName = aOreName == null ? E : aOreName.toString(); - final ArrayList<ItemStack> rList = new ArrayList<>(); - if (GT_Utility.isStringValid(aName)) { - rList.addAll(OreDictionary.getOres(aName)); - } - return rList; - } - - public static void registerRecipes(final OreDictEventContainer tOre) { - // TODO Auto-generated method stub - - } + catch (NoSuchFieldException e) {} + } + + /** + * 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(ItemStack aStack) { + if (GT_Utility.isStackValid(aStack) && !GT_Utility.isStackInList(aStack, sNoUnificationList)) + sNoUnificationList.add(aStack); + } + + public static boolean isBlacklisted(ItemStack aStack) { + return GT_Utility.isStackInList(aStack, sNoUnificationList); + } + + public static void add(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack) { + set(aPrefix, aMaterial, aStack, false, false); + } + + public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack) { + set(aPrefix, aMaterial, aStack, true, false); + } + + public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aOverwrite, 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(Object aName, long aAmount) { + if (GT_Utility.isStringInvalid(aName)) return null; + 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(Object aName, long aAmount) { + return get(aName, null, aAmount, true, true); + } + + public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount) { + return get(aName, aReplacement, aAmount, true, true); + } + + public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, long aAmount) { + return get(aPrefix, aMaterial, null, aAmount); + } + + public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, ItemStack aReplacement, long aAmount) { + //if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) aPrefix.mDynamicItems.add((Materials) aMaterial); + if (OrePrefixes.mPreventableComponents.contains(aPrefix) && aPrefix.mDisabledItems.contains(aMaterial)) return aReplacement; + return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); + } + + public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount, boolean aMentionPossibleTypos, 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(boolean aUseBlackList, 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(boolean aUseBlackList, Object... aStacks) { + 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(ItemStack aStack) { + return setStack(true, aStack); + } + + public static ItemStack setStack(boolean aUseBlackList, ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return aStack; + 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(ItemStack aStack) { + return get(true, aStack); + } + + public static ItemStack get(boolean aUseBlackList, ItemStack aStack) { + return get(aUseBlackList, aStack, false); + } + + public static ItemStack get(boolean aUseBlackList, ItemStack aStack, boolean aOnUnificationTableCreation) { + if (GT_Utility.isStackInvalid(aStack)) return null; + ItemData 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()); + if (!aOnUnificationTableCreation) sUnificationTable.clear(); + } + 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 List<ItemStack> getNonUnifiedStacks(Object obj) { + synchronized (sUnificationTable) { + if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) { + for (GT_ItemStack tGTStack0 : sItemStack2DataMap.keySet()) { + ItemStack tStack0 = tGTStack0.toStack(); + ItemStack tStack1 = get(false, tStack0, true); + if (tStack0 != null && tStack1 != null && !GT_Utility.areStacksEqual(tStack0, tStack1)) { + GT_ItemStack tGTStack1 = new GT_ItemStack(tStack1); + List<ItemStack> list = sUnificationTable.get(tGTStack1); + if (list == null) sUnificationTable.put(tGTStack1, list = new ArrayList<ItemStack>()); + 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<ItemStack> rList = new ArrayList<ItemStack>(); + for (ItemStack aStack : aStacks) { + rList.add(aStack); + List<ItemStack> tList = sUnificationTable.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; + } + + public static void addItemData(ItemStack aStack, ItemData aData) { + if (GT_Utility.isStackValid(aStack) && getItemData(aStack) == null && aData != null) setItemData(aStack, aData); + } + + public static void setItemData(ItemStack aStack, ItemData aData) { + if (GT_Utility.isStackInvalid(aStack) || aData == null) return; + ItemData tData = getItemData(aStack); + if (tData == null || !tData.hasValidPrefixMaterialData()) { + if (tData != null) for (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 (MaterialStack 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 (MaterialStack 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 (Entry<GT_ItemStack, ItemData> tEntry : sItemStack2DataMap.entrySet()) + if (!tEntry.getValue().hasValidPrefixData() || tEntry.getValue().mPrefix.mAllowNormalRecycling) + GT_RecipeRegistrator.registerMaterialRecycling(tEntry.getKey().toStack(), tEntry.getValue()); + } + } else { + if (!aData.hasValidPrefixData() || aData.mPrefix.mAllowNormalRecycling) + GT_RecipeRegistrator.registerMaterialRecycling(aStack, aData); + } + } else { + for (Object tObject : aData.mExtraData) + if (!tData.mExtraData.contains(tObject)) tData.mExtraData.add(tObject); + } + } + + public static void addAssociation(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, 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 ItemData(aPrefix, aMaterial, aBlackListed)); + setItemData(aStack, new ItemData(aPrefix, aMaterial, aBlackListed)); + } + + public static ItemData getItemData(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return null; + ItemData rData = sItemStack2DataMap.get(new GT_ItemStack(aStack)); + if (rData == null) rData = sItemStack2DataMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack))); + return rData; + } + + public static ItemData getAssociation(ItemStack aStack) { + ItemData rData = getItemData(aStack); + return rData != null && rData.hasValidPrefixMaterialData() ? rData : null; + } + + public static boolean isItemStackInstanceOf(ItemStack aStack, Object aName) { + if (GT_Utility.isStringInvalid(aName) || GT_Utility.isStackInvalid(aStack)) return false; + for (ItemStack tOreStack : getOres(aName.toString())) + if (GT_Utility.areStacksEqual(tOreStack, aStack, true)) return true; + return false; + } + + public static boolean isItemStackDye(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return false; + for (Dyes tDye : Dyes.VALUES) if (isItemStackInstanceOf(aStack, tDye.toString())) return true; + return false; + } + + public static boolean registerOre(OrePrefixes aPrefix, Object aMaterial, ItemStack aStack) { + return registerOre(aPrefix.get(aMaterial), aStack); + } + + public static boolean registerOre(Object aName, ItemStack aStack) { + if (aName == null || GT_Utility.isStackInvalid(aStack)) return false; + String tName = aName.toString(); + if (GT_Utility.isStringInvalid(tName)) return false; + ArrayList<ItemStack> tList = getOres(tName); + for (int i = 0; i < tList.size(); i++) if (GT_Utility.areStacksEqual(tList.get(i), aStack, true)) return false; + 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 (ItemData tPrefixMaterial : sItemStack2DataMap.values()) tPrefixMaterial.mUnificationTarget = null; + sUnificationTable.clear(); + } + + public static ItemStack getGem(MaterialStack aMaterial) { + return aMaterial == null ? null : getGem(aMaterial.mMaterial, aMaterial.mAmount); + } + + public static ItemStack getGem(Materials aMaterial, OrePrefixes aPrefix) { + return aMaterial == null ? null : getGem(aMaterial, aPrefix.mMaterialAmount); + } + + public static ItemStack getGem(Materials aMaterial, long aMaterialAmount) { + ItemStack rStack = null; + if (((aMaterialAmount >= M))) + rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M); + if (rStack == null) { + if ((((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16)) + rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M); + if ((((aMaterialAmount * 4) >= M))) + rStack = get(OrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / M); + } + return rStack; + } + + public static ItemStack getDust(MaterialStack aMaterial) { + return aMaterial == null ? null : getDust(aMaterial.mMaterial, aMaterial.mAmount); + } + + public static ItemStack getDust(Materials aMaterial, OrePrefixes aPrefix) { + return aMaterial == null ? null : getDust(aMaterial, aPrefix.mMaterialAmount); + } + + public static ItemStack getDust(Materials aMaterial, long aMaterialAmount) { + if (aMaterialAmount <= 0) return null; + ItemStack rStack = null; + if (((aMaterialAmount % M == 0) || aMaterialAmount >= M * 16)) + rStack = get(OrePrefixes.dust, aMaterial, aMaterialAmount / M); + if (rStack == null && (((aMaterialAmount * 4) % M == 0) || aMaterialAmount >= M * 8)) + rStack = get(OrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M); + if (rStack == null && (((aMaterialAmount * 9) >= M))) + rStack = get(OrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M); + return rStack; + } + + public static ItemStack getIngot(MaterialStack aMaterial) { + return aMaterial == null ? null : getIngot(aMaterial.mMaterial, aMaterial.mAmount); + } + + public static ItemStack getIngot(Materials aMaterial, OrePrefixes aPrefix) { + return aMaterial == null ? null : getIngot(aMaterial, aPrefix.mMaterialAmount); + } + + public static ItemStack getIngot(Materials aMaterial, long aMaterialAmount) { + if (aMaterialAmount <= 0) return null; + ItemStack rStack = null; + if (((aMaterialAmount % (M * 9) == 0 && aMaterialAmount / (M * 9) > 1) || aMaterialAmount >= M * 72)) + rStack = get(OrePrefixes.block, aMaterial, aMaterialAmount / (M * 9)); + if (rStack == null && ((aMaterialAmount % M == 0) || aMaterialAmount >= M * 8)) + rStack = get(OrePrefixes.ingot, aMaterial, aMaterialAmount / M); + if (rStack == null && (((aMaterialAmount * 9) >= M))) + rStack = get(OrePrefixes.nugget, aMaterial, (aMaterialAmount * 9) / M); + return rStack; + } + + public static ItemStack getIngotOrDust(Materials aMaterial, long aMaterialAmount) { + if (aMaterialAmount <= 0) return null; + ItemStack rStack = getIngot(aMaterial, aMaterialAmount); + if (rStack == null) rStack = getDust(aMaterial, aMaterialAmount); + return rStack; + } + + public static ItemStack getIngotOrDust(MaterialStack aMaterial) { + ItemStack rStack = getIngot(aMaterial); + if(aMaterial!=null&&aMaterial.mMaterial!=null&&(aMaterial.mMaterial==Materials.Naquadah||aMaterial.mMaterial==Materials.NaquadahEnriched))rStack = getDust(aMaterial); + if (rStack == null) rStack = getDust(aMaterial); + return rStack; + } + + public static ItemStack getDustOrIngot(Materials aMaterial, long aMaterialAmount) { + if (aMaterialAmount <= 0) return null; + ItemStack rStack = getDust(aMaterial, aMaterialAmount); + if (rStack == null) rStack = getIngot(aMaterial, aMaterialAmount); + return rStack; + } + + public static ItemStack getDustOrIngot(MaterialStack aMaterial) { + ItemStack rStack = getDust(aMaterial); + if (rStack == null) rStack = getIngot(aMaterial); + return rStack; + } + + /** + * @return a Copy of the OreDictionary.getOres() List + */ + public static ArrayList<ItemStack> getOres(OrePrefixes aPrefix, Object aMaterial) { + return getOres(aPrefix.get(aMaterial)); + } + + /** + * @return a Copy of the OreDictionary.getOres() List + */ + public static ArrayList<ItemStack> getOres(Object aOreName) { + String aName = aOreName == null ? E : aOreName.toString(); + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + if (GT_Utility.isStringValid(aName)) rList.addAll(OreDictionary.getOres(aName)); + return rList; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechRecipeRegistrator.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechRecipeRegistrator.java deleted file mode 100644 index be718974d9..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechRecipeRegistrator.java +++ /dev/null @@ -1,371 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.util; - -import static gregtech.api.enums.GT_Values.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.*; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; -import gregtech.api.interfaces.internal.IThaumcraftCompat; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; - -import gtPlusPlus.core.lib.CORE; -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; - -/** - * Class for Automatic Recipe registering. - */ -public class GregtechRecipeRegistrator { - /** - * List of GT_Materials, which are used in the Creation of Sticks. All Rod GT_Materials are automatically added to this List. - */ - public static final List<GT_Materials> sRodMaterialList = new ArrayList<>(); - private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0); - private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R"; - private static final ItemStack[][] - sShapes1 = new ItemStack[][]{ - {sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null}, - {sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1}, - {null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1}, - {sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null}, - {sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, - {sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1}, - {null, null, null, sMt1, null, sMt1, sMt1, null, sMt1}, - {null, sMt1, null, null, sMt1, null, null, sMt2, null}, - {sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, - {null, sMt1, null, null, sMt2, null, null, sMt2, null}, - {sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null}, - {null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null}, - {sMt1, sMt1, null, null, sMt2, null, null, sMt2, null}, - {null, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, - {null, sMt1, null, sMt1, null, null, null, sMt1, sMt2}, - {null, sMt1, null, null, null, sMt1, sMt2, sMt1, null}, - {null, sMt1, null, sMt1, null, sMt1, null, null, sMt2}, - {null, sMt1, null, sMt1, null, sMt1, sMt2, null, null}, - {null, sMt2, null, null, sMt1, null, null, sMt1, null}, - {null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1}, - {null, sMt2, null, null, sMt2, null, null, sMt1, null}, - {null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null}, - {null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1}, - {null, sMt2, null, null, sMt2, null, sMt1, sMt1, null}, - {sMt1, null, null, null, sMt2, null, null, null, sMt2}, - {null, null, sMt1, null, sMt2, null, sMt2, null, null}, - {sMt1, null, null, null, sMt2, null, null, null, null}, - {null, null, sMt1, null, sMt2, null, null, null, null}, - {sMt1, sMt2, null, null, null, null, null, null, null}, - {sMt2, sMt1, null, null, null, null, null, null, null}, - {sMt1, null, null, sMt2, null, null, null, null, null}, - {sMt2, null, null, sMt1, null, null, null, null, null}, - {sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null}, - {sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null}, - {null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1}, - {null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, - {sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null}, - {sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null}, - {null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1}, - {null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1}, - {sMt1, null, null, null, sMt1, null, null, null, null}, - {null, sMt1, null, sMt1, null, null, null, null, null}, - {sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null}, - {null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2} - }; - private static final String[][] sShapesA = new String[][]{ - null, - null, - null, - {"Helmet", s_P + s_P + s_P, s_P + s_H + s_P}, - {"ChestPlate", s_P + s_H + s_P, s_P + s_P + s_P, s_P + s_P + s_P}, - {"Pants", s_P + s_P + s_P, s_P + s_H + s_P, s_P + " " + s_P}, - {"Boots", s_P + " " + s_P, s_P + s_H + s_P}, - {"Sword", " " + s_P + " ", s_F + s_P + s_H, " " + s_R + " "}, - {"Pickaxe", s_P + s_I + s_I, s_F + s_R + s_H, " " + s_R + " "}, - {"Shovel", s_F + s_P + s_H, " " + s_R + " ", " " + s_R + " "}, - {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "}, - {"Axe", s_P + s_I + s_H, s_P + s_R + " ", s_F + s_R + " "}, - {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "}, - {"Hoe", s_P + s_I + s_H, s_F + s_R + " ", " " + s_R + " "}, - {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, - {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, - {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, - {"Sickle", " " + s_P + " ", s_P + s_F + " ", s_H + s_P + s_R}, - {"Sword", " " + s_R + " ", s_F + s_P + s_H, " " + s_P + " "}, - {"Pickaxe", " " + s_R + " ", s_F + s_R + s_H, s_P + s_I + s_I}, - {"Shovel", " " + s_R + " ", " " + s_R + " ", s_F + s_P + s_H}, - {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H}, - {"Axe", s_F + s_R + " ", s_P + s_R + " ", s_P + s_I + s_H}, - {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H}, - {"Hoe", " " + s_R + " ", s_F + s_R + " ", s_P + s_I + s_H}, - {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R}, - {"Spear", s_P + s_H + " ", s_F + s_R + " ", " " + " " + s_R}, - {"Knive", s_H + s_P, s_R + s_F}, - {"Knive", s_F + s_H, s_P + s_R}, - {"Knive", s_F + s_H, s_P + s_R}, - {"Knive", s_P + s_F, s_R + s_H}, - {"Knive", s_P + s_F, s_R + s_H}, - null, - null, - null, - null, - {"WarAxe", s_P + s_P + s_P, s_P + s_R + s_P, s_F + s_R + s_H}, - null, - null, - null, - {"Shears", s_H + s_P, s_P + s_F}, - {"Shears", s_H + s_P, s_P + s_F}, - {"Scythe", s_I + s_P + s_H, s_R + s_F + s_P, s_R + " " + " "}, - {"Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R} - }; - public static volatile int VERSION = 508; - - public static void registerMaterialRecycling(final ItemStack aStack, final GT_Materials aMaterial, final long aMaterialAmount, GregtechMaterialStack aByproduct) { - if (GT_Utility.isStackInvalid(aStack)) { - return; - } - if (aByproduct != null) { - aByproduct = aByproduct.clone(); - aByproduct.mAmount /= aStack.stackSize; - } - GregtechOreDictUnificator.addItemData(GT_Utility.copyAmount(1, aStack), new GregtechItemData(aMaterial, aMaterialAmount / aStack.stackSize, aByproduct)); - } - - public static void registerMaterialRecycling(final ItemStack aStack, final GregtechItemData aData) { - if (GT_Utility.isStackInvalid(aStack) || GT_Utility.areStacksEqual(new ItemStack(Items.blaze_rod), aStack) || (aData == null) || !aData.hasValidMaterialData() || (aData.mMaterial.mAmount <= 0) || (GT_Utility.getFluidForFilledItem(aStack, false) != null)) { - return; - } - registerReverseMacerating(GT_Utility.copyAmount(1, aStack), aData, aData.mPrefix == null); - registerReverseSmelting(GT_Utility.copyAmount(1, aStack), aData.mMaterial.mMaterial, aData.mMaterial.mAmount, true); - registerReverseFluidSmelting(GT_Utility.copyAmount(1, aStack), aData.mMaterial.mMaterial, aData.mMaterial.mAmount, aData.getByProduct(0)); - registerReverseArcSmelting(GT_Utility.copyAmount(1, aStack), aData); - } - - /** - * @param aStack the stack to be recycled. - * @param aMaterial the Material. - * @param aMaterialAmount the amount of it in Material Units. - */ - public static void registerReverseFluidSmelting(final ItemStack aStack, final GT_Materials aMaterial, final long aMaterialAmount, final GregtechMaterialStack aByproduct) { - if ((aStack == null) || (aMaterial == null) || (aMaterial.mSmeltInto.mStandardMoltenFluid == null) || !aMaterial.contains(SubTag.SMELTING_TO_FLUID) || (((L * aMaterialAmount) / (M * aStack.stackSize)) <= 0)) { - return; - } - RA.addFluidSmelterRecipe(GT_Utility.copyAmount(1, aStack), aByproduct == null ? null : aByproduct.mMaterial.contains(SubTag.NO_SMELTING) || !aByproduct.mMaterial.contains(SubTag.METAL) ? aByproduct.mMaterial.contains(SubTag.FLAMMABLE) ? GregtechOreDictUnificator.getDust(GT_Materials._NULL, aByproduct.mAmount / 2) : aByproduct.mMaterial.contains(SubTag.UNBURNABLE) ? GregtechOreDictUnificator.getDustOrIngot(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount) : null : GregtechOreDictUnificator.getIngotOrDust(aByproduct.mMaterial.mSmeltInto, aByproduct.mAmount), aMaterial.mSmeltInto.getMolten((L * aMaterialAmount) / (M * aStack.stackSize)), 10000, (int) Math.max(1, (24 * aMaterialAmount) / M), Math.max(8, (int) Math.sqrt(2 * aMaterial.mSmeltInto.mStandardMoltenFluid.getTemperature()))); - } - - /** - * @param aStack the stack to be recycled. - * @param aMaterial the Material. - * @param aMaterialAmount the amount of it in Material Units. - * @param aAllowAlloySmelter if it is allowed to be recycled inside the Alloy Smelter. - */ - public static void registerReverseSmelting(final ItemStack aStack, final GT_Materials aMaterial, long aMaterialAmount, final boolean aAllowAlloySmelter) { - if ((aStack == null) || (aMaterial == null) || (aMaterialAmount <= 0) || aMaterial.contains(SubTag.NO_SMELTING) || ((aMaterialAmount > M) && aMaterial.contains(SubTag.METAL))) { - return; - } - aMaterialAmount /= aStack.stackSize; - - if (aAllowAlloySmelter) { - CORE.GT_Recipe.addSmeltingAndAlloySmeltingRecipe(GT_Utility.copyAmount(1, aStack), GregtechOreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount)); - } else { - GT_ModHandler.addSmeltingRecipe(GT_Utility.copyAmount(1, aStack), GregtechOreDictUnificator.getIngot(aMaterial.mSmeltInto, aMaterialAmount)); - } - } - - public static void registerReverseArcSmelting(final ItemStack aStack, GregtechItemData aData) { - if ((aStack == null) || (aData == null)) { - return; - } - aData = new GregtechItemData(aData); - - if (!aData.hasValidMaterialData()) { - return; - } - - for (final GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks()) { - if (tMaterial.mMaterial.contains(SubTag.UNBURNABLE)) { - tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto; - continue; - } - if (tMaterial.mMaterial.contains(SubTag.EXPLOSIVE)) { - tMaterial.mAmount /= 4; - continue; - } - if (tMaterial.mMaterial.contains(SubTag.FLAMMABLE)) { - tMaterial.mAmount /= 2; - continue; - } - if (tMaterial.mMaterial.contains(SubTag.NO_SMELTING)) { - tMaterial.mAmount = 0; - continue; - } - if (tMaterial.mMaterial.contains(SubTag.METAL)) { - tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto; - continue; - } - tMaterial.mAmount = 0; - } - - aData = new GregtechItemData(aData); - - if (aData.mByProducts.length > 3) { - for (final GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks()) { - aData = new GregtechItemData(aData); - } - } - - if (!aData.hasValidMaterialData()) { - return; - } - - long tAmount = 0; - for (final GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks()) { - tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); - } - - RA.addArcFurnaceRecipe(aStack, new ItemStack[]{GregtechOreDictUnificator.getIngotOrDust(aData.mMaterial), GregtechOreDictUnificator.getIngotOrDust(aData.getByProduct(0)), GregtechOreDictUnificator.getIngotOrDust(aData.getByProduct(1)), GregtechOreDictUnificator.getIngotOrDust(aData.getByProduct(2))}, null, (int) Math.max(16, tAmount / M), 96); - } - - public static void registerReverseMacerating(final ItemStack aStack, GregtechItemData aData, final boolean aAllowHammer) { - if ((aStack == null) || (aData == null)) { - return; - } - aData = new GregtechItemData(aData); - - if (!aData.hasValidMaterialData()) { - return; - } - - for (final GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks()) { - tMaterial.mMaterial = tMaterial.mMaterial.mMacerateInto; - } - - aData = new GregtechItemData(aData); - - if (!aData.hasValidMaterialData()) { - return; - } - - long tAmount = 0; - for (final GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks()) { - tAmount += tMaterial.mAmount * tMaterial.mMaterial.getMass(); - } - - RA.addPulveriserRecipe(aStack, new ItemStack[]{GregtechOreDictUnificator.getDust(aData.mMaterial), GregtechOreDictUnificator.getDust(aData.getByProduct(0)), GregtechOreDictUnificator.getDust(aData.getByProduct(1)), GregtechOreDictUnificator.getDust(aData.getByProduct(2))}, null, (int) Math.max(16, tAmount / M), 4); - - if (aAllowHammer) { - for (final GregtechMaterialStack tMaterial : aData.getAllGT_MaterialStacks()) { - if (tMaterial.mMaterial.contains(SubTag.CRYSTAL) && !tMaterial.mMaterial.contains(SubTag.METAL)) { - if (RA.addForgeHammerRecipe(GT_Utility.copyAmount(1, aStack), GregtechOreDictUnificator.getDust(aData.mMaterial), 200, 32)) { - break; - } - } - } - } - final ItemStack tDust = GregtechOreDictUnificator.getDust(aData.mMaterial); - if ((tDust != null) && GT_ModHandler.addPulverisationRecipe(GT_Utility.copyAmount(1, aStack), tDust, GregtechOreDictUnificator.getDust(aData.getByProduct(0)), 100, GregtechOreDictUnificator.getDust(aData.getByProduct(1)), 100, true)) { - if (GregTech_API.sThaumcraftCompat != null) { - GregTech_API.sThaumcraftCompat.addCrucibleRecipe(IThaumcraftCompat.ADVANCEDENTROPICPROCESSING, aStack, tDust, Arrays.asList(new TC_AspectStack(TC_Aspects.PERDITIO, Math.max(1, (aData.mMaterial.mAmount * 2) / M)))); - } - } - } - - /** - * You give this Function a Material and it will scan almost everything for adding recycling Recipes - * - * @param aMat a Material, for example an Ingot or a Gem. - * @param aOutput the Dust you usually get from macerating aMat - * @param aRecipeReplacing allows to replace the Recipe with a Plate variant - */ - public static synchronized void registerUsagesForGT_Materials(ItemStack aMat, String aPlate, final boolean aRecipeReplacing) { - if (aMat == null) { - return; - } - aMat = GT_Utility.copy(aMat); - ItemStack tStack; - final GregtechItemData aItemData = GregtechOreDictUnificator.getItemData(aMat); - if ((aItemData == null) || (aItemData.mPrefix != GregtechOrePrefixes.ingot)) { - aPlate = null; - } - if ((aPlate != null) && (GregtechOreDictUnificator.getFirstOre(aPlate, 1) == null)) { - aPlate = null; - } - - sMt1.func_150996_a(aMat.getItem()); - sMt1.stackSize = 1; - Items.feather.setDamage(sMt1, Items.feather.getDamage(aMat)); - - sMt2.func_150996_a(new ItemStack(Blocks.dirt).getItem()); - sMt2.stackSize = 1; - Items.feather.setDamage(sMt2, 0); - - for (final ItemStack[] tRecipe : sShapes1) { - int tAmount1 = 0; - for (final ItemStack tMat : tRecipe) { - if (tMat == sMt1) { - tAmount1++; - } - } - if ((aItemData != null) && aItemData.hasValidPrefixMaterialData()) { - for (final ItemStack tCrafted : GT_ModHandler.getRecipeOutputs(tRecipe)) { - GregtechOreDictUnificator.addItemData(tCrafted, new GregtechItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1)); - } - } - } - - for (final GT_Materials tMaterial : sRodMaterialList) { - final ItemStack tMt2 = GregtechOreDictUnificator.get(GregtechOrePrefixes.stick, tMaterial, 1); - if (tMt2 != null) { - sMt2.func_150996_a(tMt2.getItem()); - sMt2.stackSize = 1; - Items.feather.setDamage(sMt2, Items.feather.getDamage(tMt2)); - - for (int i = 0; i < sShapes1.length; i++) { - final ItemStack[] tRecipe = sShapes1[i]; - - int tAmount1 = 0, tAmount2 = 0; - for (final ItemStack tMat : tRecipe) { - if (tMat == sMt1) { - tAmount1++; - } - if (tMat == sMt2) { - tAmount2++; - } - } - for (final ItemStack tCrafted : GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe)) { - if ((aItemData != null) && aItemData.hasValidPrefixMaterialData()) { - GregtechOreDictUnificator.addItemData(tCrafted, new GregtechItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1, new GregtechMaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tAmount2))); - } - - if (aRecipeReplacing && (aPlate != null) && (sShapesA[i] != null) && (sShapesA[i].length > 1)) { - assert aItemData != null; - if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, aItemData.mMaterial.mMaterial + "." + sShapesA[i][0], true)) { - if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe))) { - switch (sShapesA[i].length) { - case 2: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); - break; - case 3: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); - break; - default: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], sShapesA[i][3], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); - break; - } - } - } - } - } - } - } - } - } -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java index 29a1b0ff78..4bfc6681b9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java @@ -1,8 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidRegistry; - import gregtech.api.enums.TAE; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.util.minecraft.FluidUtils; @@ -13,6 +11,9 @@ import net.minecraft.item.ItemStack; import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; import gregtech.api.gui.GT_GUIContainer_MultiMachine; + +import static gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map.*; + import net.minecraft.entity.player.InventoryPlayer; import gregtech.api.interfaces.IIconContainer; import gregtech.api.objects.GT_RenderedTexture; @@ -78,8 +79,13 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta "VacuumFreezer.png"); } - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes; + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (sAdvFreezerRecipes_GT.mRecipeList.size() < 1) { + for (GT_Recipe a : sAdvFreezerRecipes.mRecipeList) { + sAdvFreezerRecipes_GT.add(a); + } + } + return Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes_GT; } public boolean isCorrectMachinePart(final ItemStack aStack) { |