本文整理匯總了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;
}