From 2e77e12630f6103eaf56804a4c90a3117a6cfb1b Mon Sep 17 00:00:00 2001 From: Tonius Date: Wed, 17 Sep 2014 21:08:54 +0200 Subject: [PATCH 1/3] Ignore the entire eclipse folder if present --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 871c8969..11cd2fc2 100644 --- a/.gitignore +++ b/.gitignore @@ -26,11 +26,10 @@ gradle-app.setting #manual version override version.properties #eclipse stuffs -#eclipse stuffs /.classpath /.project /.settings/ -/eclipse/.metadata/ +/eclipse/ /debug/ *.lock /.metadata/ From 4f95e9395e44fcb3ce5967dbfdf7f28f77b62292 Mon Sep 17 00:00:00 2001 From: Tonius Date: Thu, 18 Sep 2014 19:23:28 +0200 Subject: [PATCH 2/3] Added NEI handlers for the smeltery and liquid casting --- .../tinker/textures/gui/nei/casting.png | Bin 0 -> 3699 bytes .../tinker/textures/gui/nei/smeltery.png | Bin 0 -> 4335 bytes .../smeltery/nei/NEITinkerSmelteryConfig.java | 34 ++ .../smeltery/nei/RecipeHandlerAlloying.java | 167 +++++++++ .../smeltery/nei/RecipeHandlerBase.java | 347 ++++++++++++++++++ .../nei/RecipeHandlerCastingBase.java | 135 +++++++ .../nei/RecipeHandlerCastingBasin.java | 41 +++ .../nei/RecipeHandlerCastingTable.java | 41 +++ .../smeltery/nei/RecipeHandlerMelting.java | 138 +++++++ 9 files changed, 903 insertions(+) create mode 100644 resources/assets/tinker/textures/gui/nei/casting.png create mode 100644 resources/assets/tinker/textures/gui/nei/smeltery.png create mode 100644 src/main/java/tconstruct/smeltery/nei/NEITinkerSmelteryConfig.java create mode 100644 src/main/java/tconstruct/smeltery/nei/RecipeHandlerAlloying.java create mode 100644 src/main/java/tconstruct/smeltery/nei/RecipeHandlerBase.java create mode 100644 src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingBase.java create mode 100644 src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingBasin.java create mode 100644 src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingTable.java create mode 100644 src/main/java/tconstruct/smeltery/nei/RecipeHandlerMelting.java diff --git a/resources/assets/tinker/textures/gui/nei/casting.png b/resources/assets/tinker/textures/gui/nei/casting.png new file mode 100644 index 0000000000000000000000000000000000000000..d9d5487a551833e379168b34d2820d1352fe51d5 GIT binary patch literal 3699 zcmeH}`8(8W8^E7242RK(EZJr%=OkGMsmL-MOOCP}dnN{Di4tQe#FQK~%#aLa8Ktr$ zSvm}2RKiOmvcHzlv5oBe{(h&<`wzU=_5OB#`QG2_x$o!RuIK(dPn@N>i6FluKL9|` z^sM3U0KlMM7~tcAM2C=`DkQi)_0Q`AP(l^hcI5$JpMt5OzReBinasf}qAg<4I&;}V z$$XXAxJXqm?j+&}%XpqwTmCH?DZhTQHucq?YnQ}x9SXZtyN;CEzmlAu7BF>Vv9sJM zenIwY1?;`;-JLCjQ#qH4^P8sG`@7GrFo0lYKkQd-et?nW9Hxcj(aP72*;oVMOYN;Q zdU{L-V|{U~r8;D8^a~ZOx9jJ+wLH}^-SY}kZ;i9kYie|)nFXMgZFCz3-YrD#M24+? zbKKcj_}aL)6GGObp|kWNYnelUZFY004mpho4c=taau|K`Y4S=H_O=5F2wnLjA#i z!BcUN*(>nCEHiWp9jU^kA!1@;R1vZI#Dj;_PZwc*(-SsXA%MhqPYehM2o4rQ&-*7? zSFCH4$Dq)%($dmsbmOOXMG&j69`*Iv5{~&tZ}|~4z!Y6UR5(>!`|#!cLdfhuTs6Jq z1HkMGM|mI`LEAA+IH><{E<#1Bq(3Oe2Bg?o}l$JK_Es9agvH-*Ku{SER^u;#06 zcYZ@YI&~8%WHDV@4!P7AS{gJs8uVxpfUdFVyX$`r%&Az!M%@ebkgtduz2_B#EY`G$ zeZS*6@IdJb5@bs5l)je*gay^>8)?k2wQH5!1r~3`&<7suUt$k4+K*eGf&=xI@#n;; zgV`6fb?4xu`4Bw2lV||T$q;%TJg>3EOTss%t(*k7-Wp&3F%fFjXhfv8NURh6m2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%@ztx^s2|`dt6E`e_MvlAF}h3jaI9yBk1?3wV+$wL4cLpgoshZ9^z`Qjt!D z6)znk%pk*2sZ!vzl`MOc0AcG=UsVk{3m!OAnV_`}?VV|0UHMn?aKfTx4{tISjcMtg z*?Ap_x})+wXr@&|IvmQlD15WJNw`A4hmaEy@;02b-=hD?$AsMc2*Hx8CPPqx#^N-O z3|Kjb$Jbx*FS%g1EoFvCu@$lJF^|t*&IwmMg&vHT> zpA1d(@K8+{*;r*(r9lv3mum3dNn&QSVg8>7W$3imSriavp~I zp7dr-YFlv-q2f}DmxTY&P+PBQkJt0JcRl6IsDlh#F%w3kS^Ax@rm}u{c`)-RhhYTu zMo>1N>~N^+kqyT|JWRnixjVj9DSEU+iz6c=igea=pSN4|Fm_fit`b?UL-jOf<#oDe}sOQy6{q(gYZXT@&(C-Yo+ z(Oc$^aZo2dsN!z=G<+8Om8$_*+a&2;<`f4#KIoa5nORv4PKSBF2#EmbJz`kq1-(>C zvru0hR}c3@)oE~$MVMNO=(?G{vG3V2K1ZTxUuIz)0M-(2{hJS_^@kscLZs=%e_w}~ zLh_Z3!9kK2-J%JJrg4A1HzSGMn%SfR0P>pmdp-uh;X#s|4G+NCQcer-fVwB~a*q`N zC_Y3x78=l?z=+i;V|Nxp>>WxdeE15+b& K!y*I1o&Nwe*$q|z literal 0 HcmV?d00001 diff --git a/resources/assets/tinker/textures/gui/nei/smeltery.png b/resources/assets/tinker/textures/gui/nei/smeltery.png new file mode 100644 index 0000000000000000000000000000000000000000..3c6f3228c0083f883463924d24fba5d770e5c471 GIT binary patch literal 4335 zcmeHLXH=8f7QG>K0zm^JFeG3@L@7#u8$A^(swL(nH~)H9LZrMc{s>E zy}Mzgawp+{_(-LAd8)%MjnJR&$QOxNgHnlhp_>Lu#JUb$7}&gV|ynIqV3{- z?mP9G>_@x0&CfhMEt{AfRA127FP$O=jK#Z}cOy&WSF6>|z^u1o=4$*1K;~a!5M>Z! z)v&`@00TsUnzJ5s+@6F`wdv^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4|m!K_5JMLzS`LNi;zLjEX$7Z#(A6e_u50flpexjtl4N<2eujctT?B z9Jv+-TV9bDoeCVz_&|F#s@JmhLP(-lkkB(4Whg5;xbLOfq(Cd zQ%Ht2Wymffb|27MT9;;=sS#VYULMb;pF;j!oQL;!@n7?K>*e_W^zCb_)F8H20Y|JYc-<8AKJvw7q~sUq*YUZw z@@m`4bfAKS!jK$@Kz}_Kb{*J4?`^{X_srZD1PExx3X2kkC$@zPU?gk103^gCT6jOm zhxEuRgM00ieleiiZwM7^#(tGIhLD8a7k_xwYM{@n0xDq`CJlN%`mqEF3jcurW6S@4 cTKXBbzC!3`%Lwe^KN!Grx6Q75JH5~S8_#vA0ssI2 literal 0 HcmV?d00001 diff --git a/src/main/java/tconstruct/smeltery/nei/NEITinkerSmelteryConfig.java b/src/main/java/tconstruct/smeltery/nei/NEITinkerSmelteryConfig.java new file mode 100644 index 00000000..3ab3ba2b --- /dev/null +++ b/src/main/java/tconstruct/smeltery/nei/NEITinkerSmelteryConfig.java @@ -0,0 +1,34 @@ +package tconstruct.smeltery.nei; + +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; + +public class NEITinkerSmelteryConfig implements IConfigureNEI +{ + + @Override + public void loadConfig () + { + API.registerRecipeHandler(new RecipeHandlerMelting()); + API.registerUsageHandler(new RecipeHandlerMelting()); + API.registerRecipeHandler(new RecipeHandlerAlloying()); + API.registerUsageHandler(new RecipeHandlerAlloying()); + API.registerRecipeHandler(new RecipeHandlerCastingTable()); + API.registerUsageHandler(new RecipeHandlerCastingTable()); + API.registerRecipeHandler(new RecipeHandlerCastingBasin()); + API.registerUsageHandler(new RecipeHandlerCastingBasin()); + } + + @Override + public String getName () + { + return "TinkerSmeltery"; + } + + @Override + public String getVersion () + { + return "${version}"; + } + +} diff --git a/src/main/java/tconstruct/smeltery/nei/RecipeHandlerAlloying.java b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerAlloying.java new file mode 100644 index 00000000..17539dce --- /dev/null +++ b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerAlloying.java @@ -0,0 +1,167 @@ +package tconstruct.smeltery.nei; + +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import tconstruct.library.crafting.AlloyMix; +import tconstruct.library.crafting.Smeltery; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; + +public class RecipeHandlerAlloying extends RecipeHandlerBase +{ + + public static final Rectangle OUTPUT_TANK = new Rectangle(118, 9, 18, 32); + + public class CachedAlloyingRecipe extends CachedBaseRecipe + { + private List fluidTanks; + private int minAmount; + + public CachedAlloyingRecipe(AlloyMix recipe) + { + this.fluidTanks = new ArrayList(); + + int maxAmount = recipe.mixers.get(0).amount; + int mult = 1; + this.minAmount = maxAmount; + for (FluidStack stack : recipe.mixers) + { + if (stack.amount > maxAmount) + { + maxAmount = stack.amount; + } + if (stack.amount < this.minAmount) + { + this.minAmount = stack.amount; + } + } + FluidTankElement tank = new FluidTankElement(OUTPUT_TANK, maxAmount * mult, recipe.result); + tank.fluid.amount *= mult; + this.fluidTanks.add(tank); + + int width = 36 / recipe.mixers.size(); + int counter = 0; + for (FluidStack stack : recipe.mixers) + { + if (counter == recipe.mixers.size() - 1) + { + tank = new FluidTankElement(new Rectangle(21 + width * counter, 9, 36 - width * counter, 32), maxAmount * mult, stack); + } + else + { + tank = new FluidTankElement(new Rectangle(21 + width * counter, 9, width, 32), maxAmount * mult, stack); + } + tank.fluid.amount *= mult; + this.fluidTanks.add(tank); + counter++; + } + } + + @Override + public PositionedStack getIngredient () + { + return null; + } + + @Override + public PositionedStack getResult () + { + return null; + } + + @Override + public List getFluidTanks () + { + return this.fluidTanks; + } + } + + @Override + public String getRecipeName () + { + return "Smeltery Alloying"; + } + + @Override + public String getRecipeID () + { + return "tconstruct.smeltery.alloying"; + } + + @Override + public String getGuiTexture () + { + return "tinker:textures/gui/nei/smeltery.png"; + } + + @Override + public void loadTransferRects () + { + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(76, 21, 22, 15), this.getRecipeID(), new Object[0])); + } + + @Override + public void drawBackground (int recipe) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 0, 62, 160, 65); + } + + @Override + public void loadCraftingRecipes (String outputId, Object... results) + { + if (outputId.equals(this.getRecipeID())) + { + for (AlloyMix recipe : Smeltery.getAlloyList()) + { + if (!recipe.mixers.isEmpty()) + { + this.arecipes.add(new CachedAlloyingRecipe(recipe)); + } + } + } + else + { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes (FluidStack result) + { + for (AlloyMix recipe : Smeltery.getAlloyList()) + { + if (areFluidsEqual(recipe.result, result) && !recipe.mixers.isEmpty()) + { + this.arecipes.add(new CachedAlloyingRecipe(recipe)); + } + } + } + + @Override + public void loadUsageRecipes (FluidStack ingredient) + { + for (Iterator i = Smeltery.getAlloyList().iterator(); i.hasNext();) + { + AlloyMix recipe = i.next(); + for (FluidStack liquid : recipe.mixers) + { + if (areFluidsEqual(liquid, ingredient) && !recipe.mixers.isEmpty()) + { + this.arecipes.add(new CachedAlloyingRecipe(recipe)); + break; + } + } + } + } + +} diff --git a/src/main/java/tconstruct/smeltery/nei/RecipeHandlerBase.java b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerBase.java new file mode 100644 index 00000000..f886dd27 --- /dev/null +++ b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerBase.java @@ -0,0 +1,347 @@ +package tconstruct.smeltery.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidBlock; +import net.minecraftforge.fluids.IFluidContainerItem; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; + +public abstract class RecipeHandlerBase extends TemplateRecipeHandler +{ + + public abstract class CachedBaseRecipe extends CachedRecipe + { + public abstract List getFluidTanks (); + } + + public abstract String getRecipeID (); + + public void loadCraftingRecipes (FluidStack result) + { + } + + public void loadUsageRecipes (FluidStack ingredient) + { + } + + @Override + public void drawForeground (int recipe) + { + super.drawForeground(recipe); + this.drawFluidTanks(recipe); + } + + @Override + public void loadCraftingRecipes (String outputId, Object... results) + { + try + { + if (outputId.equals("liquid") && results.length == 1 && results[0] instanceof FluidStack) + { + this.loadCraftingRecipes((FluidStack) results[0]); + } + else + { + super.loadCraftingRecipes(outputId, results); + } + } + catch (Throwable ex) + { + ex.printStackTrace(); + } + } + + @Override + public void loadCraftingRecipes (ItemStack result) + { + FluidStack fluid = getFluidStack(result); + if (fluid != null) + { + this.loadCraftingRecipes(fluid); + } + } + + @Override + public void loadUsageRecipes (String inputId, Object... ingredients) + { + try + { + if (inputId.equals("liquid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) + { + this.loadUsageRecipes((FluidStack) ingredients[0]); + } + else + { + super.loadUsageRecipes(inputId, ingredients); + } + } + catch (Throwable ex) + { + ex.printStackTrace(); + } + } + + @Override + public void loadUsageRecipes (ItemStack result) + { + FluidStack fluid = getFluidStack(result); + if (fluid != null) + { + this.loadUsageRecipes(fluid); + } + } + + @Override + public List handleTooltip (GuiRecipe guiRecipe, List currenttip, int recipe) + { + super.handleTooltip(guiRecipe, currenttip, recipe); + CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe); + if (GuiContainerManager.shouldShowTooltip(guiRecipe)) + { + Point mouse = GuiDraw.getMousePosition(); + Point offset = guiRecipe.getRecipePosition(recipe); + Point relMouse = new Point(mouse.x - ((guiRecipe.width - 176) / 2) - offset.x, mouse.y - ((guiRecipe.height - 166) / 2) - offset.y); + for (FluidTankElement tank : crecipe.getFluidTanks()) + { + if (tank.position.contains(relMouse)) + { + tank.handleTooltip(currenttip); + } + } + } + return currenttip; + } + + @Override + public boolean keyTyped (GuiRecipe gui, char keyChar, int keyCode, int recipe) + { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) + { + if (this.transferFluidTank(gui, recipe, false)) + { + return true; + } + } + else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) + { + if (this.transferFluidTank(gui, recipe, true)) + { + return true; + } + } + return super.keyTyped(gui, keyChar, keyCode, recipe); + } + + @Override + public boolean mouseClicked (GuiRecipe gui, int button, int recipe) + { + if (button == 0) + { + if (this.transferFluidTank(gui, recipe, false)) + { + return true; + } + } + else if (button == 1) + { + if (this.transferFluidTank(gui, recipe, true)) + { + return true; + } + } + return super.mouseClicked(gui, button, recipe); + } + + protected boolean transferFluidTank (GuiRecipe guiRecipe, int recipe, boolean usage) + { + CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe); + Point mousepos = GuiDraw.getMousePosition(); + Point offset = guiRecipe.getRecipePosition(recipe); + Point relMouse = new Point(mousepos.x - ((guiRecipe.width - 176) / 2) - offset.x, mousepos.y - ((guiRecipe.height - 166) / 2) - offset.y); + for (FluidTankElement tank : crecipe.getFluidTanks()) + { + if (tank.position.contains(relMouse)) + { + if ((tank.fluid != null) && tank.fluid.amount > 0) + { + if (usage) + { + if (!GuiUsageRecipe.openRecipeGui("liquid", new Object[] { tank.fluid })) + { + return false; + } + } + else + { + if (!GuiCraftingRecipe.openRecipeGui("liquid", new Object[] { tank.fluid })) + { + return false; + } + } + return true; + } + } + } + + return false; + } + + public void drawFluidTanks (int recipe) + { + CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe); + for (FluidTankElement fluidTank : crecipe.getFluidTanks()) + { + fluidTank.draw(); + } + } + + public static FluidStack getFluidStack (ItemStack stack) + { + if (stack == null) + { + return null; + } + Item item = stack.getItem(); + FluidStack fluidStack = null; + if ((item instanceof IFluidContainerItem)) + { + fluidStack = ((IFluidContainerItem) item).getFluid(stack); + } + if (fluidStack == null) + { + fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack); + } + if ((fluidStack == null) && (Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock)) + { + Fluid fluid = ((IFluidBlock) Block.getBlockFromItem(stack.getItem())).getFluid(); + if (fluid != null) + { + return new FluidStack(fluid, 1000); + } + } + return fluidStack; + } + + public static boolean areFluidsEqual (FluidStack fluidStack1, FluidStack fluidStack2) + { + if (fluidStack1 == null || fluidStack2 == null) + { + return false; + } + return fluidStack1.isFluidEqual(fluidStack2); + } + + public static String getMoltenTooltip (FluidStack fluid) + { + if (fluid == null) + { + return null; + } + return null; + } + + public static class FluidTankElement + { + public Rectangle position; + public FluidStack fluid; + public int capacity; + public boolean flowingTexture = false; + + public FluidTankElement(Rectangle position, int capacity, FluidStack fluid) + { + this.position = position; + this.capacity = capacity; + this.fluid = fluid; + } + + public List handleTooltip (List currenttip) + { + if (this.fluid == null || this.fluid.getFluid() == null || this.fluid.amount <= 0) + { + return currenttip; + } + currenttip.add(this.fluid.getLocalizedName()); + currenttip.add(EnumChatFormatting.GRAY.toString() + this.fluid.amount + " mB"); + return currenttip; + } + + public void draw () + { + if (this.fluid == null || this.fluid.getFluid() == null || this.fluid.amount <= 0) + { + return; + } + IIcon fluidIcon = null; + if (this.flowingTexture && this.fluid.getFluid().getFlowingIcon() != null) + { + fluidIcon = this.fluid.getFluid().getFlowingIcon(); + } + else if (this.fluid.getFluid().getStillIcon() != null) + { + fluidIcon = this.fluid.getFluid().getStillIcon(); + } + else + { + return; + } + + GuiDraw.changeTexture(TextureMap.locationBlocksTexture); + int color = this.fluid.getFluid().getColor(this.fluid); + GL11.glColor3ub((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF)); + GL11.glDisable(GL11.GL_BLEND); + + int amount = Math.max(Math.min(this.position.height, this.fluid.amount * this.position.height / this.capacity), 1); + int posY = this.position.y + this.position.height - amount; + + for (int i = 0; i < this.position.width; i += 16) + { + for (int j = 0; j < amount; j += 16) + { + int drawWidth = Math.min(this.position.width - i, 16); + int drawHeight = Math.min(amount - j, 16); + + int drawX = this.position.x + i; + int drawY = posY + j; + + double minU = fluidIcon.getMinU(); + double maxU = fluidIcon.getMaxU(); + double minV = fluidIcon.getMinV(); + double maxV = fluidIcon.getMaxV(); + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(drawX, drawY + drawHeight, 0, minU, minV + (maxV - minV) * drawHeight / 16F); + tessellator.addVertexWithUV(drawX + drawWidth, drawY + drawHeight, 0, minU + (maxU - minU) * drawWidth / 16F, minV + (maxV - minV) * drawHeight / 16F); + tessellator.addVertexWithUV(drawX + drawWidth, drawY, 0, minU + (maxU - minU) * drawWidth / 16F, minV); + tessellator.addVertexWithUV(drawX, drawY, 0, minU, minV); + tessellator.draw(); + } + } + + GL11.glEnable(GL11.GL_BLEND); + } + + } + +} diff --git a/src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingBase.java b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingBase.java new file mode 100644 index 00000000..ca50f7cc --- /dev/null +++ b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingBase.java @@ -0,0 +1,135 @@ +package tconstruct.smeltery.nei; + +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import tconstruct.library.crafting.CastingRecipe; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; + +public abstract class RecipeHandlerCastingBase extends RecipeHandlerBase +{ + public static final Rectangle MOLTEN_FLOW = new Rectangle(60, 8, 6, 11); + public static final Rectangle MOLTEN_FLOW_NO_ITEM = new Rectangle(60, 8, 6, 27); + + public class CachedCastingRecipe extends CachedBaseRecipe + { + private List resources; + private FluidTankElement metal; + private PositionedStack output = null; + + public CachedCastingRecipe(CastingRecipe recipe) + { + this.metal = new FluidTankElement(MOLTEN_FLOW, recipe.castingMetal.amount, recipe.castingMetal); + this.metal.flowingTexture = true; + this.resources = new ArrayList(); + if (recipe.cast != null) + { + this.resources.add(new PositionedStack(recipe.cast, 55, 19)); + } + else + { + this.metal.position = MOLTEN_FLOW_NO_ITEM; + } + this.output = new PositionedStack(recipe.output, 110, 18); + } + + @Override + public List getIngredients () + { + return getCycledIngredients(cycleticks / 20, this.resources); + } + + @Override + public PositionedStack getResult () + { + return this.output; + } + + @Override + public List getFluidTanks () + { + List res = new ArrayList(); + res.add(this.metal); + return res; + } + } + + @Override + public String getRecipeID () + { + return "tconstruct.smeltery.casting"; + } + + @Override + public String getGuiTexture () + { + return "tinker:textures/gui/nei/casting.png"; + } + + @Override + public void loadTransferRects () + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(76, 18, 22, 15), this.getRecipeID(), new Object[0])); + } + + public abstract List getCastingRecipes (); + + @Override + public void loadCraftingRecipes (String outputId, Object... results) + { + if (outputId.equals(this.getRecipeID())) + { + for (CastingRecipe recipe : this.getCastingRecipes()) + { + this.arecipes.add(new CachedCastingRecipe(recipe)); + } + } + else + { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes (ItemStack result) + { + for (CastingRecipe recipe : getCastingRecipes()) + { + if (NEIServerUtils.areStacksSameTypeCrafting(result, recipe.getResult())) + { + this.arecipes.add(new CachedCastingRecipe(recipe)); + } + } + } + + @Override + public void loadUsageRecipes (ItemStack ingred) + { + for (CastingRecipe recipe : getCastingRecipes()) + { + if (NEIServerUtils.areStacksSameTypeCrafting(recipe.cast, ingred)) + { + CachedCastingRecipe irecipe = new CachedCastingRecipe(recipe); + irecipe.setIngredientPermutation(irecipe.resources, ingred); + this.arecipes.add(irecipe); + } + } + } + + @Override + public void loadUsageRecipes (FluidStack ingredient) + { + for (CastingRecipe recipe : getCastingRecipes()) + { + if (areFluidsEqual(recipe.castingMetal, ingredient)) + { + this.arecipes.add(new CachedCastingRecipe(recipe)); + } + } + } + +} diff --git a/src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingBasin.java b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingBasin.java new file mode 100644 index 00000000..1c977d74 --- /dev/null +++ b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingBasin.java @@ -0,0 +1,41 @@ +package tconstruct.smeltery.nei; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.CastingRecipe; +import tconstruct.library.crafting.LiquidCasting; +import codechicken.lib.gui.GuiDraw; + +public class RecipeHandlerCastingBasin extends RecipeHandlerCastingBase +{ + + @Override + public String getRecipeName () + { + return "Casting Basin"; + } + + @Override + public void drawBackground (int recipe) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(30, 0, 0, 62, 112, 55); + } + + @Override + public List getCastingRecipes () + { + LiquidCasting casting = TConstructRegistry.getBasinCasting(); + if (casting == null) + { + return new ArrayList(); + } + return casting.getCastingRecipes(); + } + +} diff --git a/src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingTable.java b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingTable.java new file mode 100644 index 00000000..1021733f --- /dev/null +++ b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerCastingTable.java @@ -0,0 +1,41 @@ +package tconstruct.smeltery.nei; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.CastingRecipe; +import tconstruct.library.crafting.LiquidCasting; +import codechicken.lib.gui.GuiDraw; + +public class RecipeHandlerCastingTable extends RecipeHandlerCastingBase +{ + + @Override + public String getRecipeName () + { + return "Casting Table"; + } + + @Override + public void drawBackground (int recipe) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(30, 0, 0, 0, 112, 55); + } + + @Override + public List getCastingRecipes () + { + LiquidCasting casting = TConstructRegistry.getTableCasting(); + if (casting == null) + { + return new ArrayList(); + } + return casting.getCastingRecipes(); + } + +} diff --git a/src/main/java/tconstruct/smeltery/nei/RecipeHandlerMelting.java b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerMelting.java new file mode 100644 index 00000000..9706ff91 --- /dev/null +++ b/src/main/java/tconstruct/smeltery/nei/RecipeHandlerMelting.java @@ -0,0 +1,138 @@ +package tconstruct.smeltery.nei; + +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; +import java.util.Map.Entry; + +import mantle.utils.ItemMetaWrapper; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import tconstruct.library.crafting.Smeltery; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; + +public class RecipeHandlerMelting extends RecipeHandlerBase +{ + + public static final Rectangle MOLTEN_TANK = new Rectangle(115, 20, 18, 18); + + public class CachedMeltingRecipe extends CachedBaseRecipe + { + private PositionedStack input; + private int temperature; + private FluidTankElement output; + + public CachedMeltingRecipe(ItemStack input) + { + this.input = new PositionedStack(input, 28, 21); + this.temperature = Smeltery.getLiquifyTemperature(input); + this.output = new FluidTankElement(MOLTEN_TANK, 1, Smeltery.getSmelteryResult(input)); + this.output.capacity = this.output.fluid != null ? this.output.fluid.amount : 1000; + } + + @Override + public PositionedStack getIngredient () + { + return this.input; + } + + @Override + public PositionedStack getResult () + { + return null; + } + + @Override + public List getFluidTanks () + { + List tanks = new ArrayList(); + tanks.add(this.output); + return tanks; + } + } + + @Override + public String getRecipeName () + { + return "Smeltery Melting"; + } + + @Override + public String getRecipeID () + { + return "tconstruct.smeltery.melting"; + } + + @Override + public String getGuiTexture () + { + return "tinker:textures/gui/nei/smeltery.png"; + } + + @Override + public void loadTransferRects () + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(72, 20, 16, 34), this.getRecipeID(), new Object[0])); + } + + @Override + public void drawBackground (int recipe) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 160, 55); + } + + @Override + public void drawExtras (int recipe) + { + int temperature = ((CachedMeltingRecipe) this.arecipes.get(recipe)).temperature; + GuiDraw.drawStringC(temperature + " C", 81, 9, 0x808080, false); + } + + @Override + public void loadCraftingRecipes (String outputId, Object... results) + { + if (outputId.equals(getRecipeID())) + { + for (ItemMetaWrapper key : Smeltery.getSmeltingList().keySet()) + { + this.arecipes.add(new CachedMeltingRecipe(new ItemStack(key.item, 1, key.meta))); + } + } + else + { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes (FluidStack result) + { + for (Entry pair : Smeltery.getSmeltingList().entrySet()) + { + if (areFluidsEqual(pair.getValue(), result)) + { + this.arecipes.add(new CachedMeltingRecipe(new ItemStack(pair.getKey().item, 1, pair.getKey().meta))); + } + } + } + + @Override + public void loadUsageRecipes (ItemStack ingred) + { + for (ItemMetaWrapper key : Smeltery.getSmeltingList().keySet()) + { + if (NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(key.item, 1, key.meta), ingred)) + { + this.arecipes.add(new CachedMeltingRecipe(new ItemStack(key.item, 1, key.meta))); + } + } + } + +} From a4397948e61674eebce72ba7f1ef778ea63f8279 Mon Sep 17 00:00:00 2001 From: Tonius Date: Thu, 18 Sep 2014 19:43:24 +0200 Subject: [PATCH 3/3] Added Pulse check --- .../smeltery/nei/NEITinkerSmelteryConfig.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/tconstruct/smeltery/nei/NEITinkerSmelteryConfig.java b/src/main/java/tconstruct/smeltery/nei/NEITinkerSmelteryConfig.java index 3ab3ba2b..73faabb5 100644 --- a/src/main/java/tconstruct/smeltery/nei/NEITinkerSmelteryConfig.java +++ b/src/main/java/tconstruct/smeltery/nei/NEITinkerSmelteryConfig.java @@ -1,5 +1,6 @@ package tconstruct.smeltery.nei; +import tconstruct.TConstruct; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; @@ -9,14 +10,17 @@ public class NEITinkerSmelteryConfig implements IConfigureNEI @Override public void loadConfig () { - API.registerRecipeHandler(new RecipeHandlerMelting()); - API.registerUsageHandler(new RecipeHandlerMelting()); - API.registerRecipeHandler(new RecipeHandlerAlloying()); - API.registerUsageHandler(new RecipeHandlerAlloying()); - API.registerRecipeHandler(new RecipeHandlerCastingTable()); - API.registerUsageHandler(new RecipeHandlerCastingTable()); - API.registerRecipeHandler(new RecipeHandlerCastingBasin()); - API.registerUsageHandler(new RecipeHandlerCastingBasin()); + if (TConstruct.pulsar.isPulseLoaded("Tinkers' Smeltery")) + { + API.registerRecipeHandler(new RecipeHandlerMelting()); + API.registerUsageHandler(new RecipeHandlerMelting()); + API.registerRecipeHandler(new RecipeHandlerAlloying()); + API.registerUsageHandler(new RecipeHandlerAlloying()); + API.registerRecipeHandler(new RecipeHandlerCastingTable()); + API.registerUsageHandler(new RecipeHandlerCastingTable()); + API.registerRecipeHandler(new RecipeHandlerCastingBasin()); + API.registerUsageHandler(new RecipeHandlerCastingBasin()); + } } @Override