diff --git a/src/main/java/forestry/core/gui/ContainerAnalyzerProviderHelper.java b/src/main/java/forestry/core/gui/ContainerAnalyzerProviderHelper.java index 0a8a1cb0f..87ac29254 100644 --- a/src/main/java/forestry/core/gui/ContainerAnalyzerProviderHelper.java +++ b/src/main/java/forestry/core/gui/ContainerAnalyzerProviderHelper.java @@ -65,14 +65,14 @@ public class ContainerAnalyzerProviderHelper { return container.getSlotFromInventory(alyzerInventory, 0); } - public ItemStack analyzeSpecimen(int selectedSlot) { + public void analyzeSpecimen(int selectedSlot) { if(selectedSlot < 0 || alyzerInventory == null){ - return ItemStack.EMPTY; + return; } Slot specimenSlot = container.getForestrySlot( selectedSlot); ItemStack specimen = specimenSlot.getStack(); if (specimen.isEmpty()) { - return ItemStack.EMPTY; + return; } ItemStack convertedSpecimen = GeneticsUtil.convertToGeneticEquivalent(specimen); @@ -85,7 +85,7 @@ public class ContainerAnalyzerProviderHelper { // No individual, abort if (speciesRoot == null) { - return specimen; + return; } IIndividual individual = speciesRoot.getMember(specimen); @@ -93,11 +93,9 @@ public class ContainerAnalyzerProviderHelper { // Analyze if necessary if (individual != null && !individual.isAnalyzed()) { final boolean requiresEnergy = ModuleHelper.isEnabled(ForestryModuleUids.APICULTURE); - if (requiresEnergy) { - // Requires energy - if (!ItemInventoryAlyzer.isAlyzingFuel(alyzerInventory.getStackInSlot(InventoryDatabaseAnalyzer.SLOT_ENERGY))) { - return specimen; - } + ItemStack energyStack = alyzerInventory.getStackInSlot(InventoryDatabaseAnalyzer.SLOT_ENERGY); + if (requiresEnergy && !ItemInventoryAlyzer.isAlyzingFuel(energyStack)) { + return; } if (individual.analyze()) { @@ -117,6 +115,6 @@ public class ContainerAnalyzerProviderHelper { } specimenSlot.putStack(specimen); } - return specimen; + return; } } diff --git a/src/main/java/forestry/core/gui/GuiAnalyzerProvider.java b/src/main/java/forestry/core/gui/GuiAnalyzerProvider.java index 8bba79b48..bcd0ac787 100644 --- a/src/main/java/forestry/core/gui/GuiAnalyzerProvider.java +++ b/src/main/java/forestry/core/gui/GuiAnalyzerProvider.java @@ -24,7 +24,7 @@ public abstract class GuiAnalyzerProvider extends GuiForest protected static final Drawable SELECTED_COMB_SLOT = new Drawable(GeneticAnalyzer.TEXTURE, 163, 0, 22, 22); protected static final Drawable TOGGLE_BUTTON = new Drawable(GeneticAnalyzer.TEXTURE, 35, 166, 18, 20); /* Attributes - Global */ - protected static boolean analyzerVisible = false; + private static boolean analyzerVisible = false; /* Attributes - Final */ public final IGeneticAnalyzer analyzer; @@ -64,16 +64,16 @@ public abstract class GuiAnalyzerProvider extends GuiForest this.analyzer = GuiElementFactory.INSTANCE.createAnalyzer(window, -189 - screenDistance, 0, hasBoarder, this); updateVisibility(); - SlotAnalyzer analyzer = null; + SlotAnalyzer analyzerSlot = null; if (container instanceof IContainerAnalyzerProvider) { IContainerAnalyzerProvider containerAnalyzer = (IContainerAnalyzerProvider) container; - Slot analyzerSlot = containerAnalyzer.getAnalyzerSlot(); - if (analyzerSlot instanceof SlotAnalyzer) { - ((SlotAnalyzer) analyzerSlot).setGui(this); - analyzer = (SlotAnalyzer) analyzerSlot; + Slot slot = containerAnalyzer.getAnalyzerSlot(); + if (slot instanceof SlotAnalyzer) { + ((SlotAnalyzer) slot).setGui(this); + analyzerSlot = (SlotAnalyzer) slot; } } - this.slotAnalyzer = analyzer; + this.slotAnalyzer = analyzerSlot; } /* Methods */ @@ -124,39 +124,23 @@ public abstract class GuiAnalyzerProvider extends GuiForest dirty = false; } super.drawScreen(mouseX, mouseY, partialTicks); - //analyzer.drawTooltip(this, mouseX, mouseY); } @Override protected void actionPerformed(GuiButton button) throws IOException { super.actionPerformed(button); if (button instanceof GuiToggleButton) { - analyzerVisible = !analyzerVisible; + setAnalyzerVisible(!isAnalyzerVisible()); updateVisibility(); dirtyAnalyzer = true; } } - @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - super.mouseClicked(mouseX, mouseY, mouseButton); - //analyzer.mouseClicked(mouseX, mouseY, mouseButton); - } - - @Override - protected void keyTyped(char typedChar, int keyCode) throws IOException { - /*if (analyzer.keyTyped(typedChar, keyCode)) { - return; - }*/ - super.keyTyped(typedChar, keyCode); - } - /* Methods - Implement GuiContainer */ @Override protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); GlStateManager.color(1.0F, 1.0F, 1.0F); - //analyzer.draw(0, 0, mouseX, mouseY); if (analyzer.isVisible()) { int selectedSlot = analyzer.getSelected(); if (selectedSlot >= 0) { @@ -195,4 +179,12 @@ public abstract class GuiAnalyzerProvider extends GuiForest return firstSlot; } + /* Methods - Gui Globals */ + private static void setAnalyzerVisible(boolean analyzerVisible) { + GuiAnalyzerProvider.analyzerVisible = analyzerVisible; + } + + private static boolean isAnalyzerVisible() { + return analyzerVisible; + } }