diff --git a/src/main/java/logisticspipes/gui/modules/GuiApiaristSink.java b/src/main/java/logisticspipes/gui/modules/GuiApiaristSink.java index 9d9e8629b..2d8034db7 100644 --- a/src/main/java/logisticspipes/gui/modules/GuiApiaristSink.java +++ b/src/main/java/logisticspipes/gui/modules/GuiApiaristSink.java @@ -5,6 +5,7 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; @@ -18,59 +19,57 @@ import logisticspipes.proxy.MainProxy; import logisticspipes.proxy.SimpleServiceLocator; import logisticspipes.utils.gui.DummyContainer; -import logisticspipes.utils.gui.GuiGraphics; import logisticspipes.utils.gui.IItemTextureRenderSlot; import logisticspipes.utils.gui.ISmallColorRenderSlot; +import logisticspipes.utils.item.ItemIdentifierInventory; +import logisticspipes.utils.string.StringUtils; public class GuiApiaristSink extends ModuleBaseGui { + static final String PREFIX = "gui.apiaristsink."; + private static final ResourceLocation TEXTURE = new ResourceLocation( + "logisticspipes", + "textures/gui/apiarist_sink.png"); + private final ModuleApiaristSink module; public GuiApiaristSink(ModuleApiaristSink module, EntityPlayer player) { - super(new DummyContainer(player.inventory, null), module); + super(null, module); + this.module = module; + + DummyContainer dummy = new DummyContainer(player.inventory, this.module.getInventoryBee()); + dummy.addNormalSlotsForHotbar(8, 157); + dummy.addDummySlot(0, 110, 121); + for (int i = 0; i < 6; i++) { SinkSetting filter = module.filter[i]; - addRenderSlot(new TypeSlot(20, 20 + (i * 18), filter, i)); - addRenderSlot(new GroupSlot(guiLeft + 45, guiTop + 25 + (i * 18), filter, i)); - addRenderSlot(new BeeSlot(60, 20 + (i * 18), filter, 0, i)); - addRenderSlot(new BeeSlot(78, 20 + (i * 18), filter, 1, i)); + addRenderSlot(new TypeSlot(24 + (i * 22), 20, filter, i)); + addRenderSlot(new GroupSlot(guiLeft + 29 + (i * 22), guiTop + 45, filter, i)); + addRenderSlot(new BeeSlot(24 + (i * 22), 60, filter, 0, i)); + addRenderSlot(new BeeSlot(24 + (i * 22), 60 + 18, filter, 1, i)); } - xSize = 120; - ySize = 150; - } - public void renderForestryBeeAt(Minecraft mc, int x, int y, float zLevel, String id) { - GL11.glDisable(GL11.GL_LIGHTING); - mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); + inventorySlots = dummy; - for (int i = 0; i < SimpleServiceLocator.forestryProxy.getRenderPassesForAlleleId(id); i++) { - IIcon icon = SimpleServiceLocator.forestryProxy.getIconIndexForAlleleId(id, i); - if (icon == null) { - continue; - } - int color = SimpleServiceLocator.forestryProxy.getColorForAlleleId(id, i); - float colorR = (color >> 16 & 0xFF) / 255.0F; - float colorG = (color >> 8 & 0xFF) / 255.0F; - float colorB = (color & 0xFF) / 255.0F; - - GL11.glColor4f(colorR, colorG, colorB, 1.0F); - - // Render icon - Tessellator var9 = Tessellator.instance; - var9.startDrawingQuads(); - var9.addVertexWithUV(x, y + 16, zLevel, icon.getMinU(), icon.getMaxV()); - var9.addVertexWithUV(x + 16, y + 16, zLevel, icon.getMaxU(), icon.getMaxV()); - var9.addVertexWithUV(x + 16, y, zLevel, icon.getMaxU(), icon.getMinV()); - var9.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV()); - var9.draw(); - } - GL11.glEnable(GL11.GL_LIGHTING); + xSize = 175; + ySize = 180; } @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { - GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(GuiApiaristSink.TEXTURE); + int j = guiLeft; + int k = guiTop; + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + super.drawGuiContainerForegroundLayer(par1, par2); + mc.fontRenderer.drawString(StringUtils.translate(PREFIX + "title"), 8, 6, 0x404040); + mc.fontRenderer.drawString(module.getInventoryBee().getInventoryName(), 35, 125, 0x404040); } private class TypeSlot extends IItemTextureRenderSlot { @@ -263,8 +262,37 @@ private BeeSlot(int xPos, int yPos, SinkSetting setting, int slotNumber, int row this.row = row; } + private void renderForestryBeeAt(Minecraft mc, int x, int y, float zLevel, String id) { + GL11.glDisable(GL11.GL_LIGHTING); + mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); + + for (int i = 0; i < SimpleServiceLocator.forestryProxy.getRenderPassesForAlleleId(id); i++) { + IIcon icon = SimpleServiceLocator.forestryProxy.getIconIndexForAlleleId(id, i); + if (icon == null) { + continue; + } + int color = SimpleServiceLocator.forestryProxy.getColorForAlleleId(id, i); + float colorR = (color >> 16 & 0xFF) / 255.0F; + float colorG = (color >> 8 & 0xFF) / 255.0F; + float colorB = (color & 0xFF) / 255.0F; + + GL11.glColor4f(colorR, colorG, colorB, 1.0F); + + // Render icon + Tessellator var9 = Tessellator.instance; + var9.startDrawingQuads(); + var9.addVertexWithUV(x, y + 16, zLevel, icon.getMinU(), icon.getMaxV()); + var9.addVertexWithUV(x + 16, y + 16, zLevel, icon.getMaxU(), icon.getMaxV()); + var9.addVertexWithUV(x + 16, y, zLevel, icon.getMaxU(), icon.getMinV()); + var9.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV()); + var9.draw(); + } + GL11.glEnable(GL11.GL_LIGHTING); + } + @Override public void mouseClicked(int button) { + if (button == 2) { if (slotNumber == 0) { setting.firstBeeReset(); @@ -272,18 +300,41 @@ public void mouseClicked(int button) { setting.secondBeeReset(); } } + if (button == 0) { + ItemIdentifierInventory inventoryBee = module.getInventoryBee(); if (slotNumber == 0) { - setting.firstBeeUp(); + if (!inventoryBee.isEmpty() && SinkSetting.isBee(inventoryBee, 0)) { + setting.firstBeeSetFirstAlleleID(inventoryBee, 0); + } else { + setting.firstBeeUp(); + } } else { - setting.secondBeeUp(); + if (!inventoryBee.isEmpty() && SinkSetting.isBee(inventoryBee, 0)) { + setting.secondBeeSetFirstAlleleID(module.getInventoryBee(), 0); + } else { + setting.secondBeeUp(); + } } } if (button == 1) { + ItemIdentifierInventory inventoryBee = module.getInventoryBee(); if (slotNumber == 0) { - setting.firstBeeDown(); + if (!inventoryBee.isEmpty() && SinkSetting.isBee(inventoryBee, 0)) { + if (SinkSetting.isAnalyzedBee(inventoryBee, 0)) { + setting.firstBeeSetSecondAlleleID(inventoryBee, 0); + } + } else { + setting.firstBeeDown(); + } } else { - setting.secondBeeDown(); + if (!inventoryBee.isEmpty() && SinkSetting.isBee(inventoryBee, 0)) { + if (SinkSetting.isAnalyzedBee(inventoryBee, 0)) { + setting.secondBeeSetSecondAlleleID(inventoryBee, 0); + } + } else { + setting.secondBeeDown(); + } } } MainProxy.sendPacketToServer( diff --git a/src/main/java/logisticspipes/modules/ModuleApiaristSink.java b/src/main/java/logisticspipes/modules/ModuleApiaristSink.java index 35eadb6be..1366f2879 100644 --- a/src/main/java/logisticspipes/modules/ModuleApiaristSink.java +++ b/src/main/java/logisticspipes/modules/ModuleApiaristSink.java @@ -21,9 +21,17 @@ import logisticspipes.utils.SinkReply; import logisticspipes.utils.SinkReply.FixedPriority; import logisticspipes.utils.item.ItemIdentifier; +import logisticspipes.utils.item.ItemIdentifierInventory; +import logisticspipes.utils.string.StringUtils; public class ModuleApiaristSink extends LogisticsGuiModule { + static final String PREFIX = "gui.apiaristsink."; + private final ItemIdentifierInventory _inventoryBee = new ItemIdentifierInventory( + 1, + String.format(StringUtils.translate(PREFIX + "inventorySlot"), "->"), + 1); + public enum FilterType { Null("", "anything", 0), @@ -62,6 +70,34 @@ public SinkSetting(ModuleApiaristSink module) { this.module = module; } + public static boolean isBee(ItemIdentifierInventory inventory, int i) { + return SimpleServiceLocator.forestryProxy.isBee(inventory.getIDStackInSlot(i).makeNormalStack()); + } + + public static boolean isAnalyzedBee(ItemIdentifierInventory inventory, int i) { + return SimpleServiceLocator.forestryProxy.isAnalysedBee(inventory.getIDStackInSlot(i).makeNormalStack()); + } + + public void firstBeeSetFirstAlleleID(ItemIdentifierInventory inventory, int i) { + firstBee = SimpleServiceLocator.forestryProxy + .getFirstAlleleId(inventory.getIDStackInSlot(i).makeNormalStack()); + } + + public void firstBeeSetSecondAlleleID(ItemIdentifierInventory inventory, int i) { + firstBee = SimpleServiceLocator.forestryProxy + .getSecondAlleleId(inventory.getIDStackInSlot(i).makeNormalStack()); + } + + public void secondBeeSetFirstAlleleID(ItemIdentifierInventory inventory, int i) { + secondBee = SimpleServiceLocator.forestryProxy + .getFirstAlleleId(inventory.getIDStackInSlot(i).makeNormalStack()); + } + + public void secondBeeSetSecondAlleleID(ItemIdentifierInventory inventory, int i) { + secondBee = SimpleServiceLocator.forestryProxy + .getSecondAlleleId(inventory.getIDStackInSlot(i).makeNormalStack()); + } + public void firstBeeUp() { firstBee = SimpleServiceLocator.forestryProxy.getNextAlleleId(firstBee, module._world.getWorld()); } @@ -200,6 +236,10 @@ public ModuleApiaristSink() { filter[5] = new SinkSetting(this); } + public ItemIdentifierInventory getInventoryBee() { + return _inventoryBee; + } + @Override public void readFromNBT(NBTTagCompound nbttagcompound) { NBTTagCompound filters = nbttagcompound.getCompoundTag("filters"); @@ -207,6 +247,7 @@ public void readFromNBT(NBTTagCompound nbttagcompound) { NBTTagCompound filterNBT = filters.getCompoundTag("" + i); filter[i].readFromNBT(filterNBT); } + _inventoryBee.readFromNBT(nbttagcompound, ""); } @Override @@ -218,6 +259,7 @@ public void writeToNBT(NBTTagCompound nbttagcompound) { filters.setTag("" + i, filterNBT); } nbttagcompound.setTag("filters", filters); + _inventoryBee.writeToNBT(nbttagcompound, ""); } @Override diff --git a/src/main/java/logisticspipes/network/guis/module/inhand/ApiaristSinkModuleInHand.java b/src/main/java/logisticspipes/network/guis/module/inhand/ApiaristSinkModuleInHand.java index 0d0a18ba4..d0d9bc490 100644 --- a/src/main/java/logisticspipes/network/guis/module/inhand/ApiaristSinkModuleInHand.java +++ b/src/main/java/logisticspipes/network/guis/module/inhand/ApiaristSinkModuleInHand.java @@ -33,6 +33,11 @@ public DummyContainer getContainer(EntityPlayer player) { if (!(dummy.getModule() instanceof ModuleApiaristSink)) { return null; } + dummy.setInventory(((ModuleApiaristSink) dummy.getModule()).getInventoryBee()); + + dummy.addNormalSlotsForHotbar(8, 157); + dummy.addDummySlot(0, 110, 121); + return dummy; } diff --git a/src/main/java/logisticspipes/network/guis/module/inpipe/ApiaristSinkModuleSlot.java b/src/main/java/logisticspipes/network/guis/module/inpipe/ApiaristSinkModuleSlot.java index 2debf2bfa..e11ff8ad5 100644 --- a/src/main/java/logisticspipes/network/guis/module/inpipe/ApiaristSinkModuleSlot.java +++ b/src/main/java/logisticspipes/network/guis/module/inpipe/ApiaristSinkModuleSlot.java @@ -32,7 +32,13 @@ public DummyContainer getContainer(EntityPlayer player) { if (module == null) { return null; } - return new DummyContainer(player.inventory, null); + + DummyContainer dummy = new DummyContainer(player.inventory, module.getInventoryBee()); + + dummy.addNormalSlotsForHotbar(8, 157); + dummy.addDummySlot(0, 110, 121); + + return dummy; } @Override diff --git a/src/main/java/logisticspipes/utils/gui/DummyContainer.java b/src/main/java/logisticspipes/utils/gui/DummyContainer.java index 4ab345648..8806f0f7d 100644 --- a/src/main/java/logisticspipes/utils/gui/DummyContainer.java +++ b/src/main/java/logisticspipes/utils/gui/DummyContainer.java @@ -99,6 +99,19 @@ public void addNormalSlotsForPlayerInventory(int xOffset, int yOffset) { } } + public void addNormalSlotsForHotbar(int xOffset, int yOffset) { + + if (_playerInventory == null) { + return; + } + + for (int i1 = 0; i1 < 9; i1++) { + Slot slot = new Slot(_playerInventory, i1, xOffset + i1 * 18, yOffset); + addSlotToContainer(slot); + transferBottom.add(slot); + } + } + /** * Add a dummy slot that will not consume players items * diff --git a/src/main/resources/assets/logisticspipes/lang/en_US.lang b/src/main/resources/assets/logisticspipes/lang/en_US.lang index a91823c83..b8e4f28fa 100644 --- a/src/main/resources/assets/logisticspipes/lang/en_US.lang +++ b/src/main/resources/assets/logisticspipes/lang/en_US.lang @@ -382,6 +382,9 @@ gui.itemsink.IgnoreData=Ignore Data gui.itemsink.IgnoreNBT=Ignore NBT gui.itemsink.import=Import +gui.apiaristsink.title=Apiarist Sink Filters +gui.apiaristsink.inventorySlot=Set on click %s + gui.crafting.Inputs=Inputs gui.crafting.Import=Import gui.crafting.Open=Open diff --git a/src/main/resources/assets/logisticspipes/textures/gui/apiarist_sink.png b/src/main/resources/assets/logisticspipes/textures/gui/apiarist_sink.png new file mode 100644 index 000000000..68809632a Binary files /dev/null and b/src/main/resources/assets/logisticspipes/textures/gui/apiarist_sink.png differ