當前位置: 首頁>>代碼示例>>Java>>正文


Java Slot.isItemValid方法代碼示例

本文整理匯總了Java中net.minecraft.inventory.Slot.isItemValid方法的典型用法代碼示例。如果您正苦於以下問題:Java Slot.isItemValid方法的具體用法?Java Slot.isItemValid怎麽用?Java Slot.isItemValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.inventory.Slot的用法示例。


在下文中一共展示了Slot.isItemValid方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: slotClickPhantom

import net.minecraft.inventory.Slot; //導入方法依賴的package包/類
@Nonnull
private ItemStack slotClickPhantom(Slot slot, int dragType, ClickType clickType, EntityPlayer player) {
    ItemStack stack = ItemStack.EMPTY;

    if (clickType == ClickType.CLONE && dragType == 2) {
        // middle-click: clear slot
        if (((IPhantomSlot) slot).canAdjust()) {
            slot.putStack(ItemStack.EMPTY);
        }
    } else if ((clickType == ClickType.PICKUP || clickType == ClickType.QUICK_MOVE) && (dragType == 0 || dragType == 1)) {
        // left or right-click...
        InventoryPlayer playerInv = player.inventory;
        slot.onSlotChanged();
        ItemStack stackSlot = slot.getStack();
        ItemStack stackHeld = playerInv.getItemStack();

        stack = stackSlot.copy();
        if (stackSlot.isEmpty()) {
            if (!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) {
                fillPhantomSlot(slot, stackHeld, clickType, dragType);
            }
        } else if (stackHeld.isEmpty()) {
            adjustPhantomSlot(slot, clickType, dragType);
            slot.onTake(player, playerInv.getItemStack());
        } else if (slot.isItemValid(stackHeld)) {
            if (canStacksMerge(stackSlot, stackHeld)) {
                adjustPhantomSlot(slot, clickType, dragType);
            } else {
                fillPhantomSlot(slot, stackHeld, clickType, dragType);
            }
        }
    }
    return stack;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:35,代碼來源:ContainerPneumaticBase.java

示例2: mouseClickMove

import net.minecraft.inventory.Slot; //導入方法依賴的package包/類
/**
 * Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,
 * lastButtonClicked & timeSinceMouseClick.
 */
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
    Slot slot = this.getSlotAtPosition(mouseX, mouseY);
    ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();

    if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
    {
        if (clickedMouseButton == 0 || clickedMouseButton == 1)
        {
            if (this.draggedStack == null)
            {
                if (slot != this.clickedSlot && this.clickedSlot.getStack() != null)
                {
                    this.draggedStack = this.clickedSlot.getStack().copy();
                }
            }
            else if (this.draggedStack.stackSize > 1 && slot != null && Container.canAddItemToSlot(slot, this.draggedStack, false))
            {
                long i = Minecraft.getSystemTime();

                if (this.currentDragTargetSlot == slot)
                {
                    if (i - this.dragItemDropDelay > 500L)
                    {
                        this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
                        this.handleMouseClick(slot, slot.slotNumber, 1, 0);
                        this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0);
                        this.dragItemDropDelay = i + 750L;
                        --this.draggedStack.stackSize;
                    }
                }
                else
                {
                    this.currentDragTargetSlot = slot;
                    this.dragItemDropDelay = i;
                }
            }
        }
    }
    else if (this.dragSplitting && slot != null && itemstack != null && itemstack.stackSize > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
    {
        this.dragSplittingSlots.add(slot);
        this.updateDragSplitting();
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:50,代碼來源:GuiContainer.java

示例3: mouseClickMove

import net.minecraft.inventory.Slot; //導入方法依賴的package包/類
/**
 * Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,
 * lastButtonClicked & timeSinceMouseClick.
 */
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
    Slot slot = this.getSlotAtPosition(mouseX, mouseY);
    ItemStack itemstack = this.mc.player.inventory.getItemStack();

    if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
    {
        if (clickedMouseButton == 0 || clickedMouseButton == 1)
        {
            if (this.draggedStack.func_190926_b())
            {
                if (slot != this.clickedSlot && !this.clickedSlot.getStack().func_190926_b())
                {
                    this.draggedStack = this.clickedSlot.getStack().copy();
                }
            }
            else if (this.draggedStack.func_190916_E() > 1 && slot != null && Container.canAddItemToSlot(slot, this.draggedStack, false))
            {
                long i = Minecraft.getSystemTime();

                if (this.currentDragTargetSlot == slot)
                {
                    if (i - this.dragItemDropDelay > 500L)
                    {
                        this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
                        this.handleMouseClick(slot, slot.slotNumber, 1, ClickType.PICKUP);
                        this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
                        this.dragItemDropDelay = i + 750L;
                        this.draggedStack.func_190918_g(1);
                    }
                }
                else
                {
                    this.currentDragTargetSlot = slot;
                    this.dragItemDropDelay = i;
                }
            }
        }
    }
    else if (this.dragSplitting && slot != null && !itemstack.func_190926_b() && (itemstack.func_190916_E() > this.dragSplittingSlots.size() || this.dragSplittingLimit == 2) && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
    {
        this.dragSplittingSlots.add(slot);
        this.updateDragSplitting();
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:50,代碼來源:GuiContainer.java

示例4: mouseClickMove

import net.minecraft.inventory.Slot; //導入方法依賴的package包/類
/**
 * Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,
 * lastButtonClicked & timeSinceMouseClick.
 */
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick)
{
    Slot slot = this.getSlotAtPosition(mouseX, mouseY);
    ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();

    if (this.clickedSlot != null && this.mc.gameSettings.touchscreen)
    {
        if (clickedMouseButton == 0 || clickedMouseButton == 1)
        {
            if (this.draggedStack == null)
            {
                if (slot != this.clickedSlot && this.clickedSlot.getStack() != null)
                {
                    this.draggedStack = this.clickedSlot.getStack().copy();
                }
            }
            else if (this.draggedStack.stackSize > 1 && slot != null && Container.canAddItemToSlot(slot, this.draggedStack, false))
            {
                long i = Minecraft.getSystemTime();

                if (this.currentDragTargetSlot == slot)
                {
                    if (i - this.dragItemDropDelay > 500L)
                    {
                        this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
                        this.handleMouseClick(slot, slot.slotNumber, 1, ClickType.PICKUP);
                        this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, ClickType.PICKUP);
                        this.dragItemDropDelay = i + 750L;
                        --this.draggedStack.stackSize;
                    }
                }
                else
                {
                    this.currentDragTargetSlot = slot;
                    this.dragItemDropDelay = i;
                }
            }
        }
    }
    else if (this.dragSplitting && slot != null && itemstack != null && itemstack.stackSize > this.dragSplittingSlots.size() && Container.canAddItemToSlot(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot))
    {
        this.dragSplittingSlots.add(slot);
        this.updateDragSplitting();
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:50,代碼來源:GuiContainer.java


注:本文中的net.minecraft.inventory.Slot.isItemValid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。