From b638bc34c3249a5cf2d869178bf004537d71b3b3 Mon Sep 17 00:00:00 2001 From: Technus Date: Tue, 22 Nov 2016 12:51:04 +0100 Subject: initial --- src/main/java/gregtech/api/util/GT_Recipe.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/util') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 3d238bf147..9c0d940bb3 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -466,7 +466,7 @@ public class GT_Recipe { public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet(3), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sRepicatorFakeRecipes = new GT_Recipe_Map(new HashSet(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.scanner", "Scanner", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.fakeAssemblyline", "fakeAssemblyline", "Assemblyline", RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(10000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(10000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true); -- cgit From 6f03cd84cdf8b00df57b620cc552efcbf87e3a61 Mon Sep 17 00:00:00 2001 From: Technus Date: Tue, 22 Nov 2016 16:40:21 +0100 Subject: some initial gui work --- src/main/java/gregtech/api/util/GT_Recipe.java | 3 +- .../java/gregtech/nei/GT_NEI_AssLineHandler.java | 422 +++++++++++++++++++++ .../java/gregtech/nei/GT_NEI_DefaultHandler.java | 2 +- src/main/java/gregtech/nei/NEI_GT_Config.java | 4 + .../gregtech/textures/gui/FakeAssemblyline.png | Bin 262931 -> 262931 bytes 5 files changed, 429 insertions(+), 2 deletions(-) create mode 100644 src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java (limited to 'src/main/java/gregtech/api/util') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 9c0d940bb3..51307813e4 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -466,7 +466,8 @@ public class GT_Recipe { public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet(3), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sRepicatorFakeRecipes = new GT_Recipe_Map(new HashSet(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.fakeAssemblyline", "fakeAssemblyline", "Assemblyline", RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, false);//Just a common list + public static final GT_Recipe_Map sAssemblylineUnlockedRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.unlockedAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, true);//will content add in achievements public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(10000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(10000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true); diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java new file mode 100644 index 0000000000..6edda76f23 --- /dev/null +++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java @@ -0,0 +1,422 @@ +package gregtech.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 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.ItemData; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +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.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class GT_NEI_AssLineHandler + 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 GT_Recipe.GT_Recipe_Map mRecipeMap; + + public GT_NEI_AssLineHandler(GT_Recipe.GT_Recipe_Map aRecipeMap) {//this is called when recipes should be shown + this.mRecipeMap = aRecipeMap; + this.transferRects.add(new RecipeTransferRect(new Rectangle(138, 18, 18, 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 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_AssLineHandler(this.mRecipeMap); + } + + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + for (GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) { + if (!tRecipe.mHidden) { + this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + public void loadCraftingRecipes(ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList tResults = new ArrayList(); + tResults.add(aResult); + tResults.add(GT_OreDictUnificator.get(true, aResult)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); + if (tFluid != null) { + tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tResults.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) { + if (!tRecipe.mHidden) { + CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (ItemStack tStack : tResults) { + if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + CachedDefaultRecipe tNEIRecipe; + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + + ArrayList tInputs = new ArrayList(); + tInputs.add(aInput); + tInputs.add(GT_OreDictUnificator.get(false, aInput)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + if (tFluid != null) { + tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tInputs.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (GT_Recipe tRecipe : this.mRecipeMap.mRecipeList) { + 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, 79); + } + + public int recipiesPerPage() { + return 1; + } + + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + public String getGuiTexture() { + return this.mRecipeMap.mNEIGUIPath; + } + + public List handleItemTooltip(GuiRecipe gui, ItemStack aStack, List currenttip, int aRecipeIndex) { + CachedRecipe tObject = (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("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("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; + if (tEUt != 0) { + drawText(10, 73, "Total: " + tDuration * tEUt + " EU", -16777216); + drawText(10, 83, "Usage: " + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 93, "Voltage: " + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); + drawText(10, 103, "Amperage: " + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, 93, "Voltage: unspecified", -16777216); + drawText(10, 103, "Amperage: unspecified", -16777216); + } + } + if (tDuration > 0) { + drawText(10, 113, "Time: " + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + " secs", -16777216); + } + if ((GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre)) || (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost))) { + drawText(10, 123, this.mRecipeMap.mNEISpecialValuePre + ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); + } + } + + 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 false; + //return (((gui instanceof GT_GUIContainer_BasicMachine)) && (GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI))); + } + + public List handleTooltip(GuiContainer gui, int mousex, int mousey, List currenttip) { + if ((canHandle(gui)) && (currenttip.isEmpty())) { + if (new Rectangle(138, 18, 18, 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) { + return (canHandle(gui)) && (new Rectangle(138, 18, 18, 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])); + + } + + public List handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List currenttip) { + return currenttip; + } + + public List handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List currenttip) { + return currenttip; + } + + public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) { + return false; + } + + public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { + } + + public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { + } + + public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { + } + + public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { + return false; + } + + public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { + } + + public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { + } + } + + public class FixedPositionedStack + extends PositionedStack { + public final int mChance; + public boolean permutated = false; + + public FixedPositionedStack(Object object, int x, int y) { + this(object, x, y, 0); + } + + public FixedPositionedStack(Object object, int x, int y, int aChance) { + super(object, x, y, true); + this.mChance = aChance; + } + + public void generatePermutations() { + if (this.permutated) { + return; + } + ArrayList tDisplayStacks = new ArrayList(); + for (ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + List permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (Iterator i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = (ItemStack) i$.next(); + } + } else { + ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = ((ItemStack[]) tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe + extends CachedRecipe { + public final GT_Recipe mRecipe; + public final List mOutputs = new ArrayList(); + public final List mInputs = new ArrayList(); + + public CachedDefaultRecipe(GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + + if (aRecipe.getRepresentativeInput(0) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(0), 12, 0)); + } + if (aRecipe.getRepresentativeInput(1) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(1), 30, 0)); + } + if (aRecipe.getRepresentativeInput(2) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(2), 48, 0)); + } + if (aRecipe.getRepresentativeInput(3) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(3), 66, 0)); + } + if (aRecipe.getRepresentativeInput(4) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(4), 12, 18)); + } + if (aRecipe.getRepresentativeInput(5) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(5), 30, 18)); + } + if (aRecipe.getRepresentativeInput(6) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(6), 48, 18)); + } + if (aRecipe.getRepresentativeInput(7) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(7), 66, 18)); + } + if (aRecipe.getRepresentativeInput(8) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(8), 12,36)); + } + if (aRecipe.getRepresentativeInput(9) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(9), 30,36)); + } + if (aRecipe.getRepresentativeInput(10) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(10),48, 36)); + } + if (aRecipe.getRepresentativeInput(11) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(11),66, 36)); + } + if (aRecipe.getRepresentativeInput(12) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(12), 12, 54)); + } + if (aRecipe.getRepresentativeInput(13) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(13), 30, 54)); + } + if (aRecipe.getRepresentativeInput(14) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(14), 48, 54)); + } + if (aRecipe.getRepresentativeInput(15) != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(15), 66, 54)); + } + + if (aRecipe.mSpecialItems != null) { + this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 138, 36)); + } + if (aRecipe.getOutput(0) != null) { + this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(0), 138, 0, aRecipe.getOutputChance(0))); + } + 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), 102, 0)); + 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), 102, 18)); + if ((aRecipe.mFluidInputs.length > 2) && (aRecipe.mFluidInputs[2] != null) && (aRecipe.mFluidInputs[2].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[2], true), 102, 36)); + if ((aRecipe.mFluidInputs.length > 3) && (aRecipe.mFluidInputs[3] != null) && (aRecipe.mFluidInputs[3].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[3], true), 102, 54)); + } + } + } + } + } + + public List getIngredients() { + return getCycledIngredients(GT_NEI_AssLineHandler.this.cycleticks / 10, this.mInputs); + } + + public PositionedStack getResult() { + return null; + } + + public List getOtherStacks() { + return this.mOutputs; + } + } +} diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java index cf94695a82..d14d63acf6 100644 --- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java @@ -44,7 +44,7 @@ public class GT_NEI_DefaultHandler protected final GT_Recipe.GT_Recipe_Map mRecipeMap; - public GT_NEI_DefaultHandler(GT_Recipe.GT_Recipe_Map aRecipeMap) { + public GT_NEI_DefaultHandler(GT_Recipe.GT_Recipe_Map aRecipeMap) {//this is called when recipes should be shown this.mRecipeMap = aRecipeMap; this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier(), new Object[0])); if (!NEI_GT_Config.sIsAdded) { diff --git a/src/main/java/gregtech/nei/NEI_GT_Config.java b/src/main/java/gregtech/nei/NEI_GT_Config.java index 02dd084ccf..ac496b4d4f 100644 --- a/src/main/java/gregtech/nei/NEI_GT_Config.java +++ b/src/main/java/gregtech/nei/NEI_GT_Config.java @@ -1,7 +1,9 @@ package gregtech.nei; import codechicken.nei.api.IConfigureNEI; +import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; public class NEI_GT_Config implements IConfigureNEI { @@ -14,6 +16,8 @@ public class NEI_GT_Config new GT_NEI_DefaultHandler(tMap); } } + if(FMLCommonHandler.instance().getEffectiveSide().isClient()) + new GT_NEI_AssLineHandler(GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes); sIsAdded = true; } diff --git a/src/main/resources/assets/gregtech/textures/gui/FakeAssemblyline.png b/src/main/resources/assets/gregtech/textures/gui/FakeAssemblyline.png index 0c1b04f2ee..e56d1e686e 100644 Binary files a/src/main/resources/assets/gregtech/textures/gui/FakeAssemblyline.png and b/src/main/resources/assets/gregtech/textures/gui/FakeAssemblyline.png differ -- cgit From 2de6e3eadb6ab57736c51ed72d1617cff11d05f1 Mon Sep 17 00:00:00 2001 From: Technus Date: Tue, 22 Nov 2016 19:05:12 +0100 Subject: Stuff --- src/main/java/gregtech/api/util/GT_Recipe.java | 16 +++++++++-- src/main/java/gregtech/api/util/GT_Utility.java | 2 ++ src/main/java/gregtech/common/GT_Client.java | 3 ++ src/main/java/gregtech/common/GT_RecipeAdder.java | 2 +- .../java/gregtech/nei/GT_NEI_AssLineHandler.java | 33 +++++++++++++--------- src/main/java/gregtech/nei/NEI_GT_Config.java | 3 +- 6 files changed, 40 insertions(+), 19 deletions(-) (limited to 'src/main/java/gregtech/api/util') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 51307813e4..6367cd0750 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -466,9 +466,8 @@ public class GT_Recipe { public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet(3), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sRepicatorFakeRecipes = new GT_Recipe_Map(new HashSet(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, false);//Just a common list - public static final GT_Recipe_Map sAssemblylineUnlockedRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.unlockedAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, true);//will content add in achievements - + public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(10000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(10000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true); public static final GT_Recipe_Map sPrinterRecipes = new GT_Recipe_Map_Printer(new HashSet(100), "gt.recipe.printer", "Printer", null, RES_PATH_GUI + "basicmachines/Printer", 1, 1, 1, 1, 1, E, 1, E, true, true); @@ -625,6 +624,9 @@ public class GT_Recipe { public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); } + public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue,boolean hidden) { + return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue),hidden); + } /** * Only used for fake Recipe Handlers to show something in NEI, do not use this for adding actual Recipes! findRecipe wont find fake Recipes, containsInput WILL find fake Recipes @@ -632,6 +634,9 @@ public class GT_Recipe { public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe) { return addRecipe(aRecipe, aCheckForCollisions, true, false); } + public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe,boolean hidden) { + return addRecipe(aRecipe, aCheckForCollisions, true, hidden); + } public GT_Recipe add(GT_Recipe aRecipe) { mRecipeList.add(aRecipe); @@ -816,6 +821,11 @@ public class GT_Recipe { return null; } + @Override + public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue,boolean hidden) { + return null; + } + @Override public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, GT_Recipe aRecipe) { return null; diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 5b065a4bc7..575f5bebab 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -21,6 +21,8 @@ import gregtech.api.objects.ItemData; import gregtech.api.objects.XSTR; import gregtech.api.threads.GT_Runnable_Sound; import gregtech.common.GT_Proxy; +import gregtech.nei.GT_NEI_AssLineHandler; +import gregtech.nei.NEI_GT_Config; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.RecipeInputOreDict; diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 33222c03bb..fe2d3c71d7 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -7,6 +7,7 @@ package gregtech.common; import codechicken.lib.vec.Rotation; import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import gregtech.GT_Mod; @@ -20,10 +21,12 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.objects.GT_FluidStack; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_PlayedSound; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.entities.GT_Entity_Arrow; import gregtech.common.entities.GT_Entity_Arrow_Potion; import gregtech.common.render.*; +import gregtech.nei.NEI_GT_Config; import ic2.api.tile.IWrenchable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; diff --git a/src/main/java/gregtech/common/GT_RecipeAdder.java b/src/main/java/gregtech/common/GT_RecipeAdder.java index d9558bcec6..e8dfc4615a 100644 --- a/src/main/java/gregtech/common/GT_RecipeAdder.java +++ b/src/main/java/gregtech/common/GT_RecipeAdder.java @@ -836,7 +836,7 @@ public class GT_RecipeAdder implements IGT_RecipeAdder { if(tItem==null)System.out.println("addAssemblylineRecipe"+aResearchItem.getDisplayName()); } GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Research result", new Object[0])}, null, null, aResearchTime, 30, 0); - GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes.addFakeRecipe(false, aInputs, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Research result", new Object[0])}, aFluidInputs, null, aDuration, aEUt, 0); + GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes.addFakeRecipe(false, aInputs, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Research result", new Object[0])}, aFluidInputs, null, aDuration, aEUt, 0,true); GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe_AssemblyLine( aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt)); return true; } diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java index 6edda76f23..227ce05d85 100644 --- a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java @@ -58,7 +58,8 @@ public class GT_NEI_AssLineHandler } public TemplateRecipeHandler newInstance() { - return new GT_NEI_AssLineHandler(this.mRecipeMap); + NEI_GT_Config.ALH=new GT_NEI_AssLineHandler(this.mRecipeMap); + return NEI_GT_Config.ALH; } public void loadCraftingRecipes(String outputId, Object... results) { @@ -73,6 +74,10 @@ public class GT_NEI_AssLineHandler } } + public void clearRecipes(){ + this.arecipes.clear(); + } + public void loadCraftingRecipes(ItemStack aResult) { ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); @@ -215,14 +220,14 @@ public class GT_NEI_AssLineHandler 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); - } - } + //if (canHandle(gui)) { + // if (button == 0) { + // return transferRect(gui, false); + // } + // if (button == 1) { + // return transferRect(gui, true); + // } + //} return false; } @@ -236,11 +241,11 @@ public class GT_NEI_AssLineHandler } public List handleTooltip(GuiContainer gui, int mousex, int mousey, List currenttip) { - if ((canHandle(gui)) && (currenttip.isEmpty())) { - if (new Rectangle(138, 18, 18, 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"); - } - } + //if ((canHandle(gui)) && (currenttip.isEmpty())) { + // if (new Rectangle(138, 18, 18, 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; } diff --git a/src/main/java/gregtech/nei/NEI_GT_Config.java b/src/main/java/gregtech/nei/NEI_GT_Config.java index ac496b4d4f..4f72d40608 100644 --- a/src/main/java/gregtech/nei/NEI_GT_Config.java +++ b/src/main/java/gregtech/nei/NEI_GT_Config.java @@ -8,6 +8,7 @@ import gregtech.api.util.GT_Utility; public class NEI_GT_Config implements IConfigureNEI { public static boolean sIsAdded = true; + public static GT_NEI_AssLineHandler ALH; public void loadConfig() { sIsAdded = false; @@ -17,7 +18,7 @@ public class NEI_GT_Config } } if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - new GT_NEI_AssLineHandler(GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes); + ALH=new GT_NEI_AssLineHandler(GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes); sIsAdded = true; } -- cgit From 317d6062d298b1157f698f100fea43fe53df00d0 Mon Sep 17 00:00:00 2001 From: Technus Date: Tue, 22 Nov 2016 19:44:57 +0100 Subject: WIP --- src/main/java/gregtech/api/util/GT_Recipe.java | 2 +- src/main/java/gregtech/common/GT_RecipeAdder.java | 2 +- src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) (limited to 'src/main/java/gregtech/api/util') diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 6367cd0750..06b70df0ae 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -466,7 +466,7 @@ public class GT_Recipe { public static final GT_Recipe_Map sRockBreakerFakeRecipes = new GT_Recipe_Map(new HashSet(3), "gt.recipe.rockbreaker", "Rock Breaker", null, RES_PATH_GUI + "basicmachines/RockBreaker", 1, 1, 0, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sByProductList = new GT_Recipe_Map(new HashSet(1000), "gt.recipe.byproductlist", "Ore Byproduct List", null, RES_PATH_GUI + "basicmachines/Default", 1, 6, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sRepicatorFakeRecipes = new GT_Recipe_Map(new HashSet(100), "gt.recipe.replicator", "Replicator", null, RES_PATH_GUI + "basicmachines/Replicator", 0, 1, 0, 1, 1, E, 1, E, true, true); - public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sAssemblylineFakeRecipes = new GT_Recipe_Map(new HashSet(30), "gt.recipe.fakeAssemblylineProcess", "Assemblyline Process", null, RES_PATH_GUI + "FakeAssemblyline", 1, 1, 1, 0, 1, E, 1, E, true, false); public static final GT_Recipe_Map sPlasmaArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(10000), "gt.recipe.plasmaarcfurnace", "Plasma Arc Furnace", null, RES_PATH_GUI + "basicmachines/PlasmaArcFurnace", 1, 4, 1, 1, 1, E, 1, E, true, true); public static final GT_Recipe_Map sArcFurnaceRecipes = new GT_Recipe_Map(new HashSet(10000), "gt.recipe.arcfurnace", "Arc Furnace", null, RES_PATH_GUI + "basicmachines/ArcFurnace", 1, 4, 1, 1, 3, E, 1, E, true, true); diff --git a/src/main/java/gregtech/common/GT_RecipeAdder.java b/src/main/java/gregtech/common/GT_RecipeAdder.java index e8dfc4615a..9f993d25d0 100644 --- a/src/main/java/gregtech/common/GT_RecipeAdder.java +++ b/src/main/java/gregtech/common/GT_RecipeAdder.java @@ -836,7 +836,7 @@ public class GT_RecipeAdder implements IGT_RecipeAdder { if(tItem==null)System.out.println("addAssemblylineRecipe"+aResearchItem.getDisplayName()); } GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Research result", new Object[0])}, null, null, aResearchTime, 30, 0); - GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes.addFakeRecipe(false, aInputs, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Research result", new Object[0])}, aFluidInputs, null, aDuration, aEUt, 0,true); + GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes.addFakeRecipe(true, aInputs, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Research result", new Object[0])}, aFluidInputs, null, aDuration, aEUt, 0,true); GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe_AssemblyLine( aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt)); return true; } diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java index 227ce05d85..c1f0b90ad9 100644 --- a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java @@ -74,10 +74,6 @@ public class GT_NEI_AssLineHandler } } - public void clearRecipes(){ - this.arecipes.clear(); - } - public void loadCraftingRecipes(ItemStack aResult) { ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); -- cgit