当前位置: 首页>>代码示例>>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;未经允许,请勿转载。