本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}