当前位置: 首页>>代码示例>>Java>>正文


Java GuiContainer.getGuiTop方法代码示例

本文整理汇总了Java中net.minecraft.client.gui.inventory.GuiContainer.getGuiTop方法的典型用法代码示例。如果您正苦于以下问题:Java GuiContainer.getGuiTop方法的具体用法?Java GuiContainer.getGuiTop怎么用?Java GuiContainer.getGuiTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.client.gui.inventory.GuiContainer的用法示例。


在下文中一共展示了GuiContainer.getGuiTop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canShiftDropItems

import net.minecraft.client.gui.inventory.GuiContainer; //导入方法依赖的package包/类
private boolean canShiftDropItems(GuiContainer gui)
{
    if (GuiScreen.isShiftKeyDown() == false || Mouse.getEventButton() != 0 ||
        InventoryUtils.isStackEmpty(gui.mc.player.inventory.getItemStack()))
    {
        return false;
    }

    int left = gui.getGuiLeft();
    int top = gui.getGuiTop();
    int xSize = gui.getXSize();
    int ySize = gui.getYSize();
    int mouseAbsX = Mouse.getEventX() * gui.width / gui.mc.displayWidth;
    int mouseAbsY = gui.height - Mouse.getEventY() * gui.height / gui.mc.displayHeight - 1;
    boolean isOutsideGui = mouseAbsX < left || mouseAbsY < top || mouseAbsX >= left + xSize || mouseAbsY >= top + ySize;

    return isOutsideGui && this.getSlotAtPosition(gui, mouseAbsX - left, mouseAbsY - top) == null;
}
 
开发者ID:maruohon,项目名称:itemscroller,代码行数:19,代码来源:InputEventHandler.java

示例2: create

import net.minecraft.client.gui.inventory.GuiContainer; //导入方法依赖的package包/类
public static InfoGuiOverlayDisplayParams create(GuiContainer gui, String guiClassName)
{
    if (gui == null) { return InfoGuiOverlayDisplayParams.EMPTY; }


    // Check for blacklisted gui's
    if (isBlacklisted(gui)) { return InfoGuiOverlayDisplayParams.EMPTY; }


    int overlayX = 0;
    int overlayY = 0;

    if (ModConfig.extraSlotsSide().equals(ModConfig.POSITION_LEFT)) {
        overlayX = gui.getGuiLeft() - GuiExtraSlotsOverlay.GUI_WIDTH - ModConfig.extraSlotsMargin();
    } else if (ModConfig.extraSlotsSide().equals(ModConfig.POSITION_RIGHT)) {
        overlayX = gui.getGuiLeft() + gui.getXSize() + ModConfig.extraSlotsMargin();
    }
    overlayY = gui.getGuiTop() + gui.getYSize() - GuiExtraSlotsOverlay.GUI_HEIGHT - 4;


    // HOTFIX: Chest containers have their height (YSize) wrong
    if (gui instanceof GuiChest || gui instanceof GuiShulkerBox) {
        overlayY -= 1;
    }


    final InfoGuiOverlayDisplayParams displayParams = new InfoGuiOverlayDisplayParams(overlayX, overlayY, true);
    return displayParams;
}
 
开发者ID:sidben,项目名称:VisibleArmorSlots,代码行数:30,代码来源:InfoGuiOverlayDisplayParams.java

示例3: buttonDown

import net.minecraft.client.gui.inventory.GuiContainer; //导入方法依赖的package包/类
public boolean buttonDown(Pair<Float,Float> input) {
	GuiContainer gui = (GuiContainer) Minecraft.getMinecraft().currentScreen;
	if(gui == null) return true;
	Slot cs = gui.getSlotUnderMouse();
	int xStart, yStart;
	if(cs == null) {
		xStart = Mouse.getEventX() * gui.width / Minecraft.getMinecraft().displayWidth;
		yStart = gui.height - Mouse.getEventY() * gui.height / Minecraft.getMinecraft().displayHeight - 1;
	} else {
		xStart = cs.xPos + gui.getGuiLeft();
		yStart = cs.yPos + gui.getGuiTop();
	}
	
	float x = input.getLeft();
	float y = input.getRight();
	
	Slot newSlot = null;
	if(Direction.UP.isTriggered(x, y)) {
		newSlot = search(gui, xStart + (SLOT_WIDTH / 2), yStart, 0, -SLOT_WIDTH, SLOT_WIDTH/2, 0);
	} else if(Direction.DOWN.isTriggered(x, y)) {
		newSlot = search(gui, xStart + SLOT_WIDTH / 2, yStart + SLOT_WIDTH, 0, SLOT_WIDTH, SLOT_WIDTH/2, 0); 
	} else if(Direction.LEFT.isTriggered(x, y)) {
		newSlot = search(gui, xStart, yStart + SLOT_WIDTH / 2, -SLOT_WIDTH, 0, 0, SLOT_WIDTH/2);
	} else if(Direction.RIGHT.isTriggered(x, y)){
		newSlot = search(gui, xStart + SLOT_WIDTH, yStart + SLOT_WIDTH / 2, SLOT_WIDTH, 0, 0, SLOT_WIDTH/2);
	}
	if(newSlot != null) {
		ActionEmulationHelper.moveMouseInGui(newSlot.xPos + SLOT_WIDTH / 2 + gui.getGuiLeft(), newSlot.yPos + SLOT_WIDTH / 2 + gui.getGuiTop(), gui.width, gui.height);
	}
	return true;
}
 
开发者ID:thilokru,项目名称:Controller-Support,代码行数:32,代码来源:ActionContainerSlotChange.java

示例4: getSlotAt

import net.minecraft.client.gui.inventory.GuiContainer; //导入方法依赖的package包/类
private Slot getSlotAt(GuiContainer gui, int x, int y) {
	for(Slot slot : gui.inventorySlots.inventorySlots) {
		if(slot.canBeHovered()) {
			int slotX = slot.xPos + gui.getGuiLeft();
			int slotY = slot.yPos + gui.getGuiTop();
			if(slotX <= x && x <= slotX + SLOT_WIDTH && slotY <= y && y <= slotY + SLOT_WIDTH) {
				return slot;
			}
		}
	}
	return null;
}
 
开发者ID:thilokru,项目名称:Controller-Support,代码行数:13,代码来源:ActionContainerSlotChange.java

示例5: GuiHarshenButton

import net.minecraft.client.gui.inventory.GuiContainer; //导入方法依赖的package包/类
public GuiHarshenButton(int buttonId, GuiContainer parentGui, int x, int y, int width, int height, String buttonText, boolean directionToInventory) {
	super(buttonId, x, parentGui.getGuiTop() + y, width, height, buttonText);
	this.parentGui = parentGui;
	this.directionToInventory = directionToInventory;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:6,代码来源:GuiHarshenButton.java

示例6: mouseClicked

import net.minecraft.client.gui.inventory.GuiContainer; //导入方法依赖的package包/类
@Override
public boolean mouseClicked(GuiScreen screen, int mouseX, int mouseY, int button) {

    if (!(screen instanceof GuiContainer) || !NEIClientConfig.isEnabled() || isSpreading(((GuiContainer) screen))) {
        return false;
    }
    GuiContainer gui = ((GuiContainer) screen);
    Slot slot = GuiHelper.getSlotMouseOver(gui);
    int slotID = -1;

    boolean outsideGui = (mouseX < gui.getGuiLeft() || mouseY < gui.getGuiTop() || mouseX >= gui.getGuiLeft() + gui.getXSize() || mouseY >= gui.getGuiTop() + gui.getYSize()) && slot == null;

    if (slot != null) {
        slotID = slot.slotNumber;
    }

    if (outsideGui) {
        slotID = -999;
    }


    //Shift / Click delete.
    if (deleteMode && slot != null && slot.slotNumber >= 0) {
        if (NEIClientUtils.shiftKey() && button == 0) {
            ItemStack itemstack1 = slot.getStack();
            if (!itemstack1.isEmpty()) {
                NEIClientUtils.deleteItemsOfType(itemstack1);
            }

        } else if (button == 1) {
            NEIClientUtils.decreaseSlotStack(slot.slotNumber);
        } else {
            NEIClientUtils.deleteSlotStack(slot.slotNumber);
        }
        return true;
    }

    //Creative click the slot 64 times because mojang.
    //Seems to already be a thing.. Gonna leave this here and wipe it in a cleanup pass.
    //if (button == 1 && slot instanceof SlotCrafting)//right click
    //{
    //    for (int i1 = 0; i1 < 64; i1++)//click this slot 64 times
    //    {
    //        manager.handleSlotClick(slot.slotNumber, button, ClickType.PICKUP);
    //    }
    //    return true;
    //}

    //Control click slot = give me an item.
    if (NEIClientUtils.controlKey() && slot != null && !slot.getStack().isEmpty() && slot.isItemValid(slot.getStack())) {
        NEIClientUtils.cheatItem(slot.getStack(), button, 1);
        return true;
    }

    //Custom slots or container? No thanx, bia!
    if (GuiInfo.hasCustomSlots(gui) || ItemInfo.fastTransferContainerExemptions.contains(gui.getClass())) {
        return false;
    }
    //Disabled for now.
    //if (slotID >= 0 && NEIClientUtils.shiftKey() && !NEIClientUtils.getHeldItem().isEmpty() && !slot.getHasStack()) {
    //    ItemStack held = NEIClientUtils.getHeldItem();
    //    GuiHelper.clickSlot(container, slot.slotNumber, button, ClickType.PICKUP);
    //    if (slot.isItemValid(held)) {
    //        fastTransferManager.performMassTransfer(container, pickedUpFromSlot, slot.slotNumber, held);
    //    }
    //
    //    return true;
    //}

    if (slotID == -999 && NEIClientUtils.shiftKey() && button == 0 && !NEIClientUtils.getHeldItem().isEmpty()) {
        fastTransferManager.throwAll(gui, pickedUpFromSlot);
        return true;
    }

    return false;
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:77,代码来源:NEIController.java

示例7: 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.getGuiTop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。