Search in sources :

Example 1 with GhostSlot

use of com.enderio.core.client.gui.widget.GhostSlot in project EnderIO by SleepyTrousers.

the class GuiInventoryPanel method mouseWheel.

@Override
protected void mouseWheel(int x, int y, int delta) {
    super.mouseWheel(x, y, delta);
    if (draggingScrollbar == null) {
        x -= guiLeft;
        y -= guiTop;
        boolean shift = isShiftKeyDown();
        if (inventoryArea.contains(x, y)) {
            GhostSlot hovered = getGhostSlotHandler().getGhostSlotAt(this, x, y);
            if (!shift) {
                scrollbar.scrollBy(-Integer.signum(delta));
            } else if (hovered instanceof InvSlot) {
                InvSlot invSlot = (InvSlot) hovered;
                InventoryDatabaseClient db = getDatabase();
                if (invSlot.getStack() != null && invSlot.entry != null && db != null) {
                    ItemStack itemStack = mc.player.inventory.getItemStack();
                    if (itemStack.isEmpty() || ItemUtil.areStackMergable(itemStack, invSlot.getStack())) {
                        PacketHandler.INSTANCE.sendToServer(new PacketFetchItem(db.getGeneration(), invSlot.entry, -1, 1));
                    }
                }
            }
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) GhostSlot(com.enderio.core.client.gui.widget.GhostSlot) InventoryDatabaseClient(crazypants.enderio.machine.invpanel.client.InventoryDatabaseClient)

Aggregations

GhostSlot (com.enderio.core.client.gui.widget.GhostSlot)1 InventoryDatabaseClient (crazypants.enderio.machine.invpanel.client.InventoryDatabaseClient)1 ItemStack (net.minecraft.item.ItemStack)1