Java Code Examples for net.minecraft.client.gui.inventory.GuiContainer#getSlotAtPosition()
The following examples show how to use
net.minecraft.client.gui.inventory.GuiContainer#getSlotAtPosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NEIController.java From NotEnoughItems with MIT License | 6 votes |
@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) || !NEIClientConfig.isMouseScrollTransferEnabled()) { return false; } Point mousePos = getMousePosition(); Slot mouseover = container.getSlotAtPosition(mousePos.x, mousePos.y); if (mouseover != null && mouseover.getHasStack() && !ItemInfo.fastTransferContainerExemptions.contains(container.getClass())) { if(NEIClientConfig.shouldInvertMouseScrollTransfer()) { scrolled = -scrolled; } if (scrolled > 0) { fastTransferManager.transferItem(container, mouseover.slotNumber); } else { fastTransferManager.retrieveItem(container, mouseover.slotNumber); } return true; } } return false; }
Example 2
Source File: NEIDummySlotHandler.java From NotEnoughItems with MIT License | 5 votes |
@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; }
Example 3
Source File: GuiHelper.java From NotEnoughItems with MIT License | 5 votes |
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); }
Example 4
Source File: NEIDummySlotHandler.java From NotEnoughItems with MIT License | 5 votes |
@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; }
Example 5
Source File: GuiContainerManager.java From NotEnoughItems with MIT License | 5 votes |
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); }
Example 6
Source File: ItemPanel.java From NotEnoughItems with MIT License | 4 votes |
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; }
Example 7
Source File: ItemPanel.java From NotEnoughItems with MIT License | 4 votes |
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; }