private void sendItemWidgetClicked(final int mouseX, final int mouseY, final int mouseButton) { for (int index = 0; index < this.widgetCount; ++index) { WidgetAEItem currentWidget = this.itemWidgets.get(index); if (currentWidget.isMouseOverWidget(mouseX, mouseY)) { IAEItemStack widgetStack = currentWidget.getItemStack(); if (widgetStack != null) { if (widgetStack.getStackSize() == 0) { if (widgetStack.isCraftable()) { // new PacketChiselingTerminalServer().createRequestAutoCraft( this.player, // widgetStack ).sendPacketToServer(); } } else { boolean isShiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); new PacketChiselingTerminalServer() .createRequestExtract(this.entityPlayer, widgetStack, mouseButton, isShiftHeld) .sendPacketToServer(); } } return; } } }
@Override protected void drawGuiContainerForegroundLayer(int cursorX, int cursorY) { super.drawGuiContainerForegroundLayer(cursorX, cursorY); this.fontRendererObj.drawString(this.guiTitle, TITLE_POS_X, TITLE_POS_Y, 0x000000); // Draw the search field. this.searchField.drawTextBox(); // Enable lighting GL11.glEnable(GL11.GL_LIGHTING); // Draw the widgets and get which one the mouse is over WidgetAEItem widgetUnderMouse = this.drawItemWidgets(cursorX, cursorY); // Should we force a tooltip update? boolean forceTooltipUpdate = ((System.currentTimeMillis() - this.lastTooltipUpdateTime) >= WIDGET_TOOLTIP_UPDATE_INTERVAL); // Has the mouse moved, or timeout reached? if (forceTooltipUpdate || (this.previousMouseX != cursorX) || (this.previousMouseY != cursorY)) { // Do we have a widget under the mouse? if (widgetUnderMouse != null) { // Has the widget changed? if (forceTooltipUpdate || (widgetUnderMouse != this.previousWidgetUnderMouse)) { // Clear the tooltip this.tooltip.clear(); // Get the tooltip from the widget widgetUnderMouse.getTooltip(this.tooltip); // Set the time this.lastTooltipUpdateTime = System.currentTimeMillis(); } } else { // Clear the tooltip this.tooltip.clear(); // Set the time this.lastTooltipUpdateTime = System.currentTimeMillis(); // Get the tooltip from the buttons this.addTooltipFromButtons(cursorX, cursorY); } // Set the previous position this.previousMouseX = cursorX; this.previousMouseY = cursorY; // Set the previous widget this.previousWidgetUnderMouse = widgetUnderMouse; } // Draw the tooltip this.drawTooltip(cursorX - this.guiLeft, cursorY - this.guiTop, false); }
private WidgetAEItem drawItemWidgets(int cursorX, int cursorY) { boolean hasNoOverlay = true; WidgetAEItem widgetUnderMouse = null; for (int index = 0; index < this.widgetCount; ++index) { WidgetAEItem currentWidget = this.itemWidgets.get(index); currentWidget.drawWidget(); if (hasNoOverlay && currentWidget.isMouseOverWidget(cursorX, cursorY)) { currentWidget.drawMouseHoverUnderlay(); hasNoOverlay = false; widgetUnderMouse = currentWidget; } } return widgetUnderMouse; }