當前位置: 首頁>>代碼示例>>Java>>正文


Java GuiContainer.getSlotAtPosition方法代碼示例

本文整理匯總了Java中net.minecraft.client.gui.inventory.GuiContainer.getSlotAtPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java GuiContainer.getSlotAtPosition方法的具體用法?Java GuiContainer.getSlotAtPosition怎麽用?Java GuiContainer.getSlotAtPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.client.gui.inventory.GuiContainer的用法示例。


在下文中一共展示了GuiContainer.getSlotAtPosition方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mouseScrolled

import net.minecraft.client.gui.inventory.GuiContainer; //導入方法依賴的package包/類
@Override
public boolean mouseScrolled(GuiScreen gui, int mouseX, int mouseY, int scrolled) {
    if (gui instanceof GuiContainer) {
        GuiContainer container = ((GuiContainer) gui);
        if (!NEIClientConfig.isEnabled() || GuiInfo.hasCustomSlots(container)) {
            return false;
        }

        Point mousePos = getMousePosition();
        Slot mouseover = container.getSlotAtPosition(mousePos.x, mousePos.y);
        if (mouseover != null && mouseover.getHasStack() && !ItemInfo.fastTransferContainerExemptions.contains(container.getClass())) {
            if (scrolled > 0) {
                fastTransferManager.transferItem(container, mouseover.slotNumber);
            } else {
                fastTransferManager.retrieveItem(container, mouseover.slotNumber);
            }
            return true;
        }
    }
    return false;
}
 
開發者ID:TheCBProject,項目名稱:NotEnoughItems,代碼行數:22,代碼來源:NEIController.java

示例2: handleDragNDrop

import net.minecraft.client.gui.inventory.GuiContainer; //導入方法依賴的package包/類
@Override
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button)
{
    Slot slot = gui.getSlotAtPosition(mousex, mousey);
    if(slot instanceof SlotDummy && slot.isItemValid(draggedStack) && gui.inventorySlots instanceof ContainerExtended)
    {
        ((SlotDummy)slot).slotClick(draggedStack, button, NEIClientUtils.shiftKey());
        NEICPH.sendDummySlotSet(slot.slotNumber, slot.getStack());
        return true;
    }
    return false;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:13,代碼來源:NEIDummySlotHandler.java

示例3: getSlotMouseOver

import net.minecraft.client.gui.inventory.GuiContainer; //導入方法依賴的package包/類
public static Slot getSlotMouseOver(GuiContainer window) {
    Point mousePos = getMousePosition();
    if (getManager(window).objectUnderMouse(mousePos.x, mousePos.y))
        return null;

    return window.getSlotAtPosition(mousePos.x, mousePos.y);
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:8,代碼來源:GuiContainerManager.java

示例4: getSlotUnderMouse

import net.minecraft.client.gui.inventory.GuiContainer; //導入方法依賴的package包/類
public static Slot getSlotUnderMouse() {
    Minecraft mc = Minecraft.getMinecraft();
    if (!(mc.currentScreen instanceof GuiContainer)) return null;
    GuiContainer screen = (GuiContainer) mc.currentScreen;
    //Copied from GuiScreen.handleMouseInput
    int mouseX = Mouse.getEventX() * screen.width / mc.displayWidth;
    int mouseY = screen.height - Mouse.getEventY() * screen.height / mc.displayHeight - 1;
    return screen.getSlotAtPosition(mouseX, mouseY);
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:10,代碼來源:DocumentationModule.java

示例5: handleDragNDrop

import net.minecraft.client.gui.inventory.GuiContainer; //導入方法依賴的package包/類
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
    Slot slot = gui.getSlotAtPosition(mouseX, mouseY);
    if (slot instanceof SlotDummy && slot.isItemValid(draggedStack) && gui.inventorySlots instanceof ContainerExtended) {
        ((SlotDummy) slot).slotClick(draggedStack, button, NEIClientUtils.shiftKey());
        NEIClientPacketHandler.sendDummySlotSet(slot.slotNumber, slot.getStack());
        return true;
    }
    return false;
}
 
開發者ID:TheCBProject,項目名稱:NotEnoughItems,代碼行數:11,代碼來源:NEIDummySlotHandler.java

示例6: getSlotMouseOver

import net.minecraft.client.gui.inventory.GuiContainer; //導入方法依賴的package包/類
public static Slot getSlotMouseOver(GuiContainer window) {
    Point mousePos = getMousePosition();
    if (objectUnderMouse(window, mousePos.x, mousePos.y)) {
        return null;
    }

    return window.getSlotAtPosition(mousePos.x, mousePos.y);
}
 
開發者ID:TheCBProject,項目名稱:NotEnoughItems,代碼行數:9,代碼來源:GuiHelper.java

示例7: handleDraggedClick

import net.minecraft.client.gui.inventory.GuiContainer; //導入方法依賴的package包/類
private boolean handleDraggedClick(int mousex, int mousey, int button) {
    if (draggedStack == null)
        return false;

    GuiContainer gui = NEIClientUtils.getGuiContainer();
    boolean handled = false;
    for (INEIGuiHandler handler : GuiInfo.guiHandlers)
        if (handler.handleDragNDrop(gui, mousex, mousey, draggedStack, button)) {
            handled = true;
            if (draggedStack.stackSize == 0) {
                draggedStack = null;
                return true;
            }
        }

    if (handled)
        return true;

    Slot overSlot = gui.getSlotAtPosition(mousex, mousey);
    if (overSlot != null && overSlot.isItemValid(draggedStack)) {
        if (NEIClientConfig.canCheatItem(draggedStack)) {
            int contents = overSlot.getHasStack() ? overSlot.getStack().stackSize : 0;
            int add = button == 0 ? draggedStack.stackSize : 1;
            if (overSlot.getHasStack() && !NEIServerUtils.areStacksSameType(draggedStack, overSlot.getStack()))
                contents = 0;
            int total = Math.min(contents + add, Math.min(overSlot.getSlotStackLimit(), draggedStack.getMaxStackSize()));

            if (total > contents) {
                NEIClientUtils.setSlotContents(overSlot.slotNumber, NEIServerUtils.copyStack(draggedStack, total), true);
                NEICPH.sendGiveItem(NEIServerUtils.copyStack(draggedStack, total), false, false);
                draggedStack.stackSize -= total - contents;
            }
            if (draggedStack.stackSize == 0)
                draggedStack = null;
        } else {
            draggedStack = null;
        }
    } else if (mousex < gui.guiLeft || mousey < gui.guiTop || mousex >= gui.guiLeft + gui.xSize || mousey >= gui.guiTop + gui.ySize) {
        draggedStack = null;
    }

    return true;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:44,代碼來源:ItemPanel.java

示例8: handleDraggedClick

import net.minecraft.client.gui.inventory.GuiContainer; //導入方法依賴的package包/類
private boolean handleDraggedClick(int mousex, int mousey, int button) {
    if (draggedStack.isEmpty()) {
        return false;
    }

    GuiContainer gui = NEIClientUtils.getGuiContainer();
    boolean handled = false;
    for (INEIGuiHandler handler : GuiInfo.guiHandlers) {
        if (handler.handleDragNDrop(gui, mousex, mousey, draggedStack, button)) {
            handled = true;
            if (draggedStack.getCount() == 0) {
                draggedStack = ItemStack.EMPTY;
                return true;
            }
        }
    }

    if (handled) {
        return true;
    }

    Slot overSlot = gui.getSlotAtPosition(mousex, mousey);
    if (overSlot != null && overSlot.isItemValid(draggedStack)) {
        if (NEIClientConfig.canCheatItem(draggedStack)) {
            int contents = overSlot.getHasStack() ? overSlot.getStack().getCount() : 0;
            int add = button == 0 ? draggedStack.getCount() : 1;
            if (overSlot.getHasStack() && !NEIServerUtils.areStacksSameType(draggedStack, overSlot.getStack())) {
                contents = 0;
            }
            int total = Math.min(contents + add, Math.min(overSlot.getSlotStackLimit(), draggedStack.getMaxStackSize()));

            if (total > contents) {
                int slotNumber = overSlot.slotNumber;
                if (gui instanceof GuiContainerCreative) {
                    //Because Mojang..
                    slotNumber = slotNumber - gui.inventorySlots.inventorySlots.size() + 9 + 36;
                }
                NEIClientUtils.setSlotContents(slotNumber, NEIServerUtils.copyStack(draggedStack, total), true);
                NEIClientPacketHandler.sendGiveItem(NEIServerUtils.copyStack(draggedStack, total), false, false);
                draggedStack.shrink(total - contents);
            }
            if (draggedStack.getCount() == 0) {
                draggedStack = ItemStack.EMPTY;
            }
        } else {
            draggedStack = ItemStack.EMPTY;
        }
    } else if (mousex < gui.getGuiLeft() || mousey < gui.getGuiTop() || mousex >= gui.getGuiLeft() + gui.getXSize() || mousey >= gui.getGuiTop() + gui.getYSize()) {
        draggedStack = ItemStack.EMPTY;
    }

    return true;
}
 
開發者ID:TheCBProject,項目名稱:NotEnoughItems,代碼行數:54,代碼來源:ItemPanel.java


注:本文中的net.minecraft.client.gui.inventory.GuiContainer.getSlotAtPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。