From 053b6f34f652f9611981cff886be19919ead0231 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Wed, 15 Jan 2014 23:03:40 -0500 Subject: [PATCH] =?UTF-8?q?Salination=20Controller=20GUI=20handler=20becau?= =?UTF-8?q?se=20I=E2=80=99m=20nice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/nei/NEIMekanismConfig.java | 7 +- .../SalinationControllerRecipeHandler.java | 284 ++++++++++++++++++ .../gui/nei/GuiSalinationController.png | Bin 0 -> 4410 bytes 3 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 common/mekanism/client/nei/SalinationControllerRecipeHandler.java create mode 100644 resources/assets/mekanism/gui/nei/GuiSalinationController.png diff --git a/common/mekanism/client/nei/NEIMekanismConfig.java b/common/mekanism/client/nei/NEIMekanismConfig.java index 861b756cf..b7c09e959 100644 --- a/common/mekanism/client/nei/NEIMekanismConfig.java +++ b/common/mekanism/client/nei/NEIMekanismConfig.java @@ -12,6 +12,7 @@ import mekanism.client.gui.GuiOsmiumCompressor; import mekanism.client.gui.GuiPrecisionSawmill; import mekanism.client.gui.GuiPurificationChamber; import mekanism.client.gui.GuiRotaryCondensentrator; +import mekanism.client.gui.GuiSalinationController; import mekanism.common.Mekanism; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; @@ -60,6 +61,9 @@ public class NEIMekanismConfig implements IConfigureNEI API.registerRecipeHandler(new PrecisionSawmillRecipeHandler()); API.registerUsageHandler(new PrecisionSawmillRecipeHandler()); + API.registerRecipeHandler(new SalinationControllerRecipeHandler()); + API.registerUsageHandler(new SalinationControllerRecipeHandler()); + API.setGuiOffset(GuiEnrichmentChamber.class, 16, 6); API.setGuiOffset(GuiOsmiumCompressor.class, 16, 6); API.setGuiOffset(GuiCrusher.class, 16, 6); @@ -72,6 +76,7 @@ public class NEIMekanismConfig implements IConfigureNEI API.setGuiOffset(GuiRotaryCondensentrator.class, RotaryCondensentratorRecipeHandler.xOffset, RotaryCondensentratorRecipeHandler.yOffset); API.setGuiOffset(GuiElectrolyticSeparator.class, ElectrolyticSeparatorRecipeHandler.xOffset, ElectrolyticSeparatorRecipeHandler.yOffset); API.setGuiOffset(GuiPrecisionSawmill.class, 16, 6); + API.setGuiOffset(GuiSalinationController.class, SalinationControllerRecipeHandler.xOffset, SalinationControllerRecipeHandler.yOffset); API.hideItem(Mekanism.boundingBlockID); API.hideItem(Mekanism.ItemProxy.itemID); @@ -86,6 +91,6 @@ public class NEIMekanismConfig implements IConfigureNEI @Override public String getVersion() { - return "1.1"; + return "1.2"; } } diff --git a/common/mekanism/client/nei/SalinationControllerRecipeHandler.java b/common/mekanism/client/nei/SalinationControllerRecipeHandler.java new file mode 100644 index 000000000..1bf1328d6 --- /dev/null +++ b/common/mekanism/client/nei/SalinationControllerRecipeHandler.java @@ -0,0 +1,284 @@ +package mekanism.client.nei; + +import static codechicken.core.gui.GuiDraw.changeTexture; +import static codechicken.core.gui.GuiDraw.drawTexturedModalRect; + +import java.awt.Point; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import mekanism.client.gui.GuiSalinationController; +import mekanism.common.ObfuscatedNames; +import mekanism.common.recipe.RecipeHandler.Recipe; +import mekanism.common.util.MekanismUtils; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import codechicken.core.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; + +public class SalinationControllerRecipeHandler extends BaseRecipeHandler +{ + private int ticksPassed; + + private static Map recipes = new HashMap(); + + public static int xOffset = 5; + public static int yOffset = 12; + + static { + if(recipes.isEmpty()) + { + recipes.put(new FluidStack(FluidRegistry.WATER, 1), new FluidStack(FluidRegistry.getFluid("brine"), 1)); + } + } + + @Override + public String getRecipeName() + { + return "Salination Controller"; + } + + @Override + public String getOverlayIdentifier() + { + return "salinationcontroller"; + } + + @Override + public String getGuiTexture() + { + return "mekanism:gui/nei/GuiSalinationController.png"; + } + + @Override + public Class getGuiClass() + { + return GuiSalinationController.class; + } + + public String getRecipeId() + { + return "mekanism.salinationcontroller"; + } + + public Set> getRecipes() + { + return recipes.entrySet(); + } + + @Override + public void drawBackground(int i) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-2, 0, 3, yOffset, 170, 62); + } + + @Override + public void drawExtras(int i) + { + CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + + drawProgressBar(49-xOffset, 64-yOffset, 176, 59, 78, 8, ticksPassed < 20 ? ticksPassed % 20 / 20.0F : 1.0F, 0); + + if(recipe.fluidInput != null) + { + displayGauge(58, 7-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidInput, null); + } + + if(recipe.fluidOutput != null) + { + displayGauge(58, 153-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidOutput, null); + } + } + + @Override + public void onUpdate() + { + super.onUpdate(); + + ticksPassed++; + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) + { + if(outputId.equals(getRecipeId())) + { + for(Map.Entry irecipe : getRecipes()) + { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + else if(outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack) + { + for(Map.Entry irecipe : getRecipes()) + { + if(((FluidStack)results[0]).isFluidEqual(irecipe.getValue())) + { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } + else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) + { + if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) + { + for(Map.Entry irecipe : getRecipes()) + { + if(irecipe.getKey().isFluidEqual((FluidStack)ingredients[0])) + { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } + else { + super.loadUsageRecipes(inputId, ingredients); + } + } + + @Override + public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) + { + Point point = GuiDraw.getMousePosition(); + + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); + int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + + if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4) + { + currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidInput.getFluid().getLocalizedName()); + } + else if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14+4 && yAxis <= 72+4) + { + currenttip.add(((CachedIORecipe)arecipes.get(recipe)).fluidOutput.getFluid().getLocalizedName()); + } + + return super.handleTooltip(gui, currenttip, recipe); + } + + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) + { + Point point = GuiDraw.getMousePosition(); + + int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); + int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + + FluidStack stack = null; + + if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4) + { + stack = ((CachedIORecipe)arecipes.get(recipe)).fluidInput; + } + else if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14+4 && yAxis <= 72+4) + { + stack = ((CachedIORecipe)arecipes.get(recipe)).fluidOutput; + } + + if(stack != null) + { + if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) + { + if(doFluidLookup(stack, false)) + { + return true; + } + } + else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) + { + if(doFluidLookup(stack, true)) + { + return true; + } + } + } + + return super.keyTyped(gui, keyChar, keyCode, recipe); + } + + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) + { + Point point = GuiDraw.getMousePosition(); + + int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); + int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + + FluidStack stack = null; + + if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4) + { + stack = ((CachedIORecipe)arecipes.get(recipe)).fluidInput; + } + else if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14+4 && yAxis <= 72+4) + { + stack = ((CachedIORecipe)arecipes.get(recipe)).fluidOutput; + } + + if(stack != null) + { + if(button == 0) + { + if(doFluidLookup(stack, false)) + { + return true; + } + } + else if(button == 1) + { + if(doFluidLookup(stack, true)) + { + return true; + } + } + } + + return super.mouseClicked(gui, button, recipe); + } + + @Override + public int recipiesPerPage() + { + return 1; + } + + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe + { + public FluidStack fluidInput; + public FluidStack fluidOutput; + + @Override + public PositionedStack getResult() + { + return null; + } + + public CachedIORecipe(FluidStack input, FluidStack output) + { + fluidInput = input; + fluidOutput = output; + } + + public CachedIORecipe(Map.Entry recipe) + { + this((FluidStack)recipe.getKey(), (FluidStack)recipe.getValue()); + } + } +} diff --git a/resources/assets/mekanism/gui/nei/GuiSalinationController.png b/resources/assets/mekanism/gui/nei/GuiSalinationController.png new file mode 100644 index 0000000000000000000000000000000000000000..ad9ddd4638ebe23ef06e241f660b38c5a7bdaadd GIT binary patch literal 4410 zcmd5yvtznlx^KM^$z<*Ri4^@4DC!&x(Iv5W)71$-nNt9VlWms@6aZutRUKAUU_d@$Vt0 zo`zo#;rzVuo(8Hz*cb?mz+RsZo6x`YY~x;eP-T@3&bg~Gy(&&~;g0U|psGIJK98J> z5O$khb5=#CKSAeaYhRT-N-&V6>z9^9nKwDXS>RoXCf_<-B|lE9LnbJPp|`J=m4ab~ z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