Search in sources :

Example 1 with ClickType

use of net.minecraft.inventory.ClickType in project BetterQuesting by Funwayguy.

the class GuiContainerThemed method mouseClicked.

/**
 * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
 */
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    super.mouseClicked(mouseX, mouseY, mouseButton);
    boolean flag = this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(mouseButton - 100);
    Slot slot = this.getSlotAtPosition(mouseX, mouseY);
    long i = Minecraft.getSystemTime();
    this.doubleClick = this.lastClickSlot == slot && i - this.lastClickTime < 250L && this.lastClickButton == mouseButton;
    this.ignoreMouseUp = false;
    if (mouseButton == 0 || mouseButton == 1 || flag) {
        int j = this.guiLeft;
        int k = this.guiTop;
        boolean flag1 = mouseX < j || mouseY < k || mouseX >= j + this.sizeX || mouseY >= k + this.sizeY;
        // Forge, prevent dropping of items through slots outside of GUI boundaries
        if (slot != null)
            flag1 = false;
        int l = -1;
        if (slot != null) {
            l = slot.slotNumber;
        }
        if (flag1) {
            l = -999;
        }
        if (this.mc.gameSettings.touchscreen && flag1 && this.mc.player.inventory.getItemStack().isEmpty()) {
            this.mc.displayGuiScreen((GuiScreen) null);
            return;
        }
        if (l != -1) {
            if (this.mc.gameSettings.touchscreen) {
                if (slot != null && slot.getHasStack()) {
                    this.clickedSlot = slot;
                    this.draggedStack = ItemStack.EMPTY;
                    this.isRightMouseClick = mouseButton == 1;
                } else {
                    this.clickedSlot = null;
                }
            } else if (!this.dragSplitting) {
                if (this.mc.player.inventory.getItemStack().isEmpty()) {
                    if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(mouseButton - 100)) {
                        this.handleMouseClick(slot, l, mouseButton, ClickType.CLONE);
                    } else {
                        boolean flag2 = l != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
                        ClickType clicktype = ClickType.PICKUP;
                        if (flag2) {
                            this.shiftClickedSlot = slot != null && slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY;
                            clicktype = ClickType.QUICK_MOVE;
                        } else if (l == -999) {
                            clicktype = ClickType.THROW;
                        }
                        this.handleMouseClick(slot, l, mouseButton, clicktype);
                    }
                    this.ignoreMouseUp = true;
                } else {
                    this.dragSplitting = true;
                    this.dragSplittingButton = mouseButton;
                    this.dragSplittingSlots.clear();
                    if (mouseButton == 0) {
                        this.dragSplittingLimit = 0;
                    } else if (mouseButton == 1) {
                        this.dragSplittingLimit = 1;
                    } else if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(mouseButton - 100)) {
                        this.dragSplittingLimit = 2;
                    }
                }
            }
        }
    }
    this.lastClickSlot = slot;
    this.lastClickTime = i;
    this.lastClickButton = mouseButton;
}
Also used : ClickType(net.minecraft.inventory.ClickType) Slot(net.minecraft.inventory.Slot)

Aggregations

ClickType (net.minecraft.inventory.ClickType)1 Slot (net.minecraft.inventory.Slot)1