Clean Up Analyzer Provider

This commit is contained in:
Nedelosk committed 2018-06-16 17:50:56 +02:00
1 parent d34ad60d31
commit a12cfff9d9
2 files changed
+24 -34

No files matched your search

@@ -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;
}
}
@@ -24,7 +24,7 @@ public abstract class GuiAnalyzerProvider<C extends Container> 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<C extends Container> 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<C extends Container> 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<C extends Container> extends GuiForest
return firstSlot;
}
/* Methods - Gui Globals */
private static void setAnalyzerVisible(boolean analyzerVisible) {
GuiAnalyzerProvider.analyzerVisible = analyzerVisible;
}
private static boolean isAnalyzerVisible() {
return analyzerVisible;
}
}