Java 类net.minecraft.inventory.ClickType 实例源码

项目:MineCamera    文件:ContainerPictureBook.java   
@Nullable
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
    if (!player.getEntityWorld().isRemote) {
        if (slotId == 1 && getSlot(1) != null && getSlot(1).getHasStack()) {
            listPid.remove(index);
            if (index +1>=totalPictureNum) {
                index--;
            }
            totalPictureNum--;
            if(totalPictureNum==0){
                index=-1;
            }
        }
    }
    ItemStack i = super.slotClick(slotId, dragType, clickTypeIn, player);
    saveToNBT(player);
    return i;
}
项目:pnc-repressurized    文件:ContainerPneumaticBase.java   
private void adjustPhantomSlot(Slot slot, ClickType clickType, int dragType) {
    if (!((IPhantomSlot) slot).canAdjust()) {
        return;
    }
    ItemStack stackSlot = slot.getStack().copy();
    if (dragType == 1) {
        if (clickType == ClickType.QUICK_MOVE) {
            stackSlot.setCount(Math.min(stackSlot.getCount() * 2, slot.getSlotStackLimit())); // shift-r-click: double stack size
        } else {
            stackSlot.setCount(Math.min(stackSlot.getCount() + 1, slot.getSlotStackLimit())); // r-click: increase stack size
        }
    } else if (dragType == 0) {
        if (clickType == ClickType.QUICK_MOVE) {
            stackSlot.setCount(stackSlot.getCount() / 2); // shift-l-click: half stack size
        } else {
            stackSlot.shrink(1); // l-click: decrease stack size
        }
    }
    slot.putStack(stackSlot);
}
项目:DankNull    文件:GuiDankNull.java   
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
    if (keyCode == 1 || mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode)) {
        mc.player.closeScreen();
    }

    //this.checkHotbarKeys(keyCode);

    if (theSlot != null && theSlot.getHasStack()) {
        if (mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode)) {
            handleMouseClick(theSlot, theSlot.slotNumber, 0, ClickType.CLONE);
        }
        else if (mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode)) {
            handleMouseClick(theSlot, theSlot.slotNumber, isCtrlKeyDown() && !(theSlot instanceof SlotDankNull) ? 1 : 0, ClickType.THROW);
        }
    }
}
项目:Clef    文件:ContainerInstrumentPlayer.java   
@Nullable
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player)
{
    if(inventorySlots.get(slotId) != null)
    {
        if(!inventorySlots.get(slotId).getStack().isEmpty())
        {
            if(!player.world.isRemote)
            {
                InventoryHelper.spawnItemStack(player.world, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, inventorySlots.get(slotId).getStack());
            }
            player.world.playSound(null, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((player.world.rand.nextFloat() - player.world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
            inventorySlots.get(slotId).putStack(ItemStack.EMPTY);
            inventory.setInventorySlotContents(slotId, ItemStack.EMPTY);
            inventory.markDirty();
        }
    }
    return super.slotClick(slotId, dragType, clickTypeIn, player);
}
项目:Backmemed    文件:AutoEat.java   
private void eatFood() {

    for(int slot = 44; slot >= 9; slot--) {
        ItemStack stack = Wrapper.getPlayer().inventoryContainer.getSlot(slot).getStack();


        if(stack != null) {
            if(slot >= 36 && slot <= 44) {
                if(stack.getItem() instanceof ItemFood 
                        && !(stack.getItem() instanceof ItemAppleGold)) {
                    Wrapper.getPlayer().inventory.currentItem = slot - 36;
                    Wrapper.getMinecraft().gameSettings.keyBindUseItem.pressed = true;
                    return;
                }
            } else if(stack.getItem() instanceof ItemFood 
                    && !(stack.getItem() instanceof ItemAppleGold)) {
                int itemSlot = slot;
                int currentSlot = Wrapper.getPlayer().inventory.currentItem + 36;
                Wrapper.getMinecraft().playerController.windowClick(0, slot, 0, ClickType.PICKUP, Wrapper.getPlayer());
                Wrapper.getMinecraft().playerController.windowClick(0, currentSlot, 0, ClickType.PICKUP, Wrapper.getPlayer());
                Wrapper.getMinecraft().playerController.windowClick(0, slot, 0, ClickType.PICKUP, Wrapper.getPlayer());
                return;
            }
        }
    }
}
项目:Backmemed    文件:GuiContainer.java   
/**
 * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
 * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
 */
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
    if (keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode())
    {
        this.mc.player.closeScreen();
    }

    this.checkHotbarKeys(keyCode);

    if (this.theSlot != null && this.theSlot.getHasStack())
    {
        if (keyCode == this.mc.gameSettings.keyBindPickBlock.getKeyCode())
        {
            this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, ClickType.CLONE);
        }
        else if (keyCode == this.mc.gameSettings.keyBindDrop.getKeyCode())
        {
            this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
        }
    }
}
项目:Backmemed    文件:GuiContainer.java   
/**
 * Checks whether a hotbar key (to swap the hovered item with an item in the hotbar) has been pressed. If so, it
 * swaps the given items.
 * Returns true if a hotbar key was pressed.
 */
protected boolean checkHotbarKeys(int keyCode)
{
    if (this.mc.player.inventory.getItemStack().func_190926_b() && this.theSlot != null)
    {
        for (int i = 0; i < 9; ++i)
        {
            if (keyCode == this.mc.gameSettings.keyBindsHotbar[i].getKeyCode())
            {
                this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, i, ClickType.SWAP);
                return true;
            }
        }
    }

    return false;
}
项目:CustomWorldGen    文件:GuiContainer.java   
/**
 * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
 * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
 */
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
    if (keyCode == 1 || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode))
    {
        this.mc.thePlayer.closeScreen();
    }

    this.checkHotbarKeys(keyCode);

    if (this.theSlot != null && this.theSlot.getHasStack())
    {
        if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode))
        {
            this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, ClickType.CLONE);
        }
        else if (this.mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode))
        {
            this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
        }
    }
}
项目:CustomWorldGen    文件:GuiContainer.java   
/**
 * Checks whether a hotbar key (to swap the hovered item with an item in the hotbar) has been pressed. If so, it
 * swaps the given items.
 * Returns true if a hotbar key was pressed.
 */
protected boolean checkHotbarKeys(int keyCode)
{
    if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null)
    {
        for (int i = 0; i < 9; ++i)
        {
            if (this.mc.gameSettings.keyBindsHotbar[i].isActiveAndMatches(keyCode))
            {
                this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, i, ClickType.SWAP);
                return true;
            }
        }
    }

    return false;
}
项目:CrystalMod    文件:ContainerStocker.java   
@Override
   public ItemStack slotClick(int id, int clickedButton, ClickType clickType, EntityPlayer player) {
       Slot slot = id >= 0 ? getSlot(id) : null;
       if(slot !=null){
        if(slot instanceof SlotGhost){
            if(ItemStackTools.isValid(slot.getStack())){
                slot.putStack(ItemStackTools.getEmptyStack());
            } else {
                if(ItemStackTools.isValid(player.inventory.getItemStack())){
                    slot.putStack(ItemUtil.copy(player.inventory.getItemStack(), 1));
                }
            }
            return player.inventory.getItemStack();
        }
       }
       return super.slotClick(id, clickedButton, clickType, player);
}
项目:ItsJustaCharm1.10.2Dead    文件:ContainerConstructionTable.java   
@Override
public ItemStack slotClick(int slot, int dragType, ClickType clickType, EntityPlayer player) {
    if (slot == 0) {
        ItemStack stack = inventorySlots.get(0).getStack();
        if (stack != null) {
            Item item = stack.getItem();
            if (item instanceof ICraftAchievement) {
                player.addStat(((ICraftAchievement) item).getAchievementOnCraft(stack, player, tile));
            } else if (item instanceof ItemBlock && Block.getBlockFromItem(item) instanceof ICraftAchievement) {
                player.addStat(((ICraftAchievement) Block.getBlockFromItem(item)).getAchievementOnCraft(stack, player, tile));
            }
        }
        if (dragType > 0) dragType = 0;
    }
    return super.slotClick(slot, dragType, clickType, player);
}
项目:CheataClientSrc    文件:ChestStealer.java   
@Override
public void onUpdate() {
    if(mc.thePlayer.openContainer != null){
        if(mc.thePlayer.openContainer instanceof ContainerChest){
            ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer;
            int i;
            for(i = 0; i<chest.numRows*9;i++){
                if(mc.thePlayer.openContainer == null){
                    break;
                }
                Slot slot =(Slot)chest.inventorySlots.get(i);
                if(slot.getStack() == null)
                    continue;
                if(!timer.check((float)(delay == 0 ? 1 : delay))){
                    return;
                }
                mc.playerController.func_187098_a(chest.windowId, i, 0, ClickType.QUICK_MOVE, mc.thePlayer);
            }
        }
    }
}
项目:ARKCraft    文件:ContainerEngram.java   
@Override
public ItemStack slotClick(int slotId, int clickedButton, ClickType mode, EntityPlayer playerIn)
{
    if (slotId >= 0)
    {
        Slot s = getSlot(slotId);
        if (s instanceof EngramSlot && clickedButton == 0)
        {
            s.onPickupFromSlot(playerIn, playerIn.inventory.getCurrentItem());
            //TODO: check
            if (mode == ClickType.PICKUP_ALL && selected != null && ARKPlayer.get(playerIn).canLearnEngram(selected.getId())
                    && !playerIn.world.isRemote)
            {
                enchantItem(playerIn, 1);
            }
            return playerIn.inventory.getCurrentItem();
        }
    }
    return super.slotClick(slotId, clickedButton, mode, playerIn);
}
项目:NotEnoughItems    文件:GuiContainer.java   
/**
 * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
 * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
 */
protected void keyTyped(char typedChar, int keyCode) throws IOException {

    if (manager.lastKeyTyped(keyCode, typedChar)) {
        return;
    }

    if (keyCode == 1 || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode)) {
        this.mc.thePlayer.closeScreen();
    }

    this.checkHotbarKeys(keyCode);

    if (this.theSlot != null && this.theSlot.getHasStack()) {
        if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode)) {
            managerHandleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, ClickType.CLONE);
        } else if (this.mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode)) {
            managerHandleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
        }
    }
}
项目:NotEnoughItems    文件:DefaultOverlayHandler.java   
@SuppressWarnings ("unchecked")
private boolean clearIngredients(GuiContainer gui, List<PositionedStack> ingreds) {
    for (PositionedStack pstack : ingreds) {
        for (Slot slot : gui.inventorySlots.inventorySlots) {
            if (slot.xPos == pstack.relx + offsetx && slot.yPos == pstack.rely + offsety) {
                if (!slot.getHasStack()) {
                    continue;
                }

                FastTransferManager.clickSlot(gui, slot.slotNumber, 0, ClickType.QUICK_MOVE);
                if (slot.getHasStack()) {
                    return false;
                }
            }
        }
    }

    return true;
}
项目:NotEnoughItems    文件:ContainerPotionCreator.java   
@Override
public ItemStack slotClick(ContainerExtended container, EntityPlayer player, int button, ClickType clickType) {
    ItemStack held = player.inventory.getItemStack();
    if (button == 0 && clickType == ClickType.QUICK_MOVE) {
        NEIClientUtils.cheatItem(getStack(), button, -1);
    } else if (button == 1) {
        putStack(ItemStack.EMPTY);
    } else if (!held.isEmpty()) {
        if (isItemValid(held)) {
            putStack(ItemUtils.copyStack(held, 1));
            player.inventory.setItemStack(ItemStack.EMPTY);
        }
    } else if (getHasStack()) {
        player.inventory.setItemStack(getStack());
    }

    return ItemStack.EMPTY;
}
项目:EZStorage2    文件:ContainerStorageCoreCrafting.java   
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
    // if (clickTypeIn == ClickType.QUICK_CRAFT) {
    if (slotId >= 0 && slotId < inventorySlots.size()) {
        Slot slotObject = inventorySlots.get(slotId);
        if (slotObject != null && slotObject instanceof SlotCrafting) { // user clicked on result slot
            ItemStack[] recipe = new ItemStack[9];
            for (int i = 0; i < 9; i++) {
                recipe[i] = this.craftMatrix.getStackInSlot(i);
            }

            ItemStack result = super.slotClick(slotId, dragType, clickTypeIn, player);
            if (result != null) {
                tryToPopulateCraftingGrid(recipe, player);
            }
            return result;
        }
    }
    // }
    return super.slotClick(slotId, dragType, clickTypeIn, player);
}
项目:MoarSigns    文件:GuiPreview.java   
@Override
protected void handleMouseClick(Slot slot, int slotId, int mouseButton, ClickType type) {
    if (slot != null && slot.getHasStack()) {
        ItemStack stack = slot.getStack();

        sign = new TileEntityMoarSign();
        String texture = ItemMoarSign.getTextureFromNBTFull(stack.getTagCompound());
        SignInfo info = SignRegistry.get(texture);

        sign.setWorldObj(FMLClientHandler.instance().getWorldClient());
        sign.isMetal = info.isMetal;
        sign.setBlockType(info.isMetal ? ModBlocks.SIGN_STANDING_METAL : ModBlocks.SIGN_STANDING_WOOD);
        ITextComponent[] components = new ITextComponent[]{null, new TextComponentString(Localization.GUI.PREVIEW.EXAMPLE_TEXT_1.translate()), new TextComponentString(Localization.GUI.PREVIEW.EXAMPLE_TEXT_2.translate()), null};
        System.arraycopy(components, 0, sign.signText, 0, sign.signText.length);
        sign.setResourceLocation(texture);
    }
}
项目:enderutilities    文件:ContainerQuickStacker.java   
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
    ItemStack stack = ItemQuickStacker.getEnabledItem(player);

    // Middle click
    if (clickType == ClickType.CLONE && dragType == 2 && stack.isEmpty() == false)
    {
        int invSlotNum = this.getSlot(slotNum) != null ? this.getSlot(slotNum).getSlotIndex() : -1;

        if (invSlotNum != -1)
        {
            byte selected = NBTUtils.getByte(stack, ItemQuickStacker.TAG_NAME_CONTAINER, ItemQuickStacker.TAG_NAME_PRESET_SELECTION);
            long mask = NBTUtils.getLong(stack, ItemQuickStacker.TAG_NAME_CONTAINER, ItemQuickStacker.TAG_NAME_PRESET + selected);
            mask ^= (0x1L << invSlotNum);
            NBTUtils.setLong(stack, ItemQuickStacker.TAG_NAME_CONTAINER, ItemQuickStacker.TAG_NAME_PRESET + selected, mask);
        }

        return ItemStack.EMPTY;
    }

    return super.slotClick(slotNum, dragType, clickType, player);
}
项目:ExpandedRailsMod    文件:GuiContainer.java   
/**
 * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
 * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
 */
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
    if (keyCode == 1 || this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode))
    {
        this.mc.thePlayer.closeScreen();
    }

    this.checkHotbarKeys(keyCode);

    if (this.theSlot != null && this.theSlot.getHasStack())
    {
        if (this.mc.gameSettings.keyBindPickBlock.isActiveAndMatches(keyCode))
        {
            this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, ClickType.CLONE);
        }
        else if (this.mc.gameSettings.keyBindDrop.isActiveAndMatches(keyCode))
        {
            this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, ClickType.THROW);
        }
    }
}
项目:ExpandedRailsMod    文件:GuiContainer.java   
/**
 * Checks whether a hotbar key (to swap the hovered item with an item in the hotbar) has been pressed. If so, it
 * swaps the given items.
 * Returns true if a hotbar key was pressed.
 */
protected boolean checkHotbarKeys(int keyCode)
{
    if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null)
    {
        for (int i = 0; i < 9; ++i)
        {
            if (this.mc.gameSettings.keyBindsHotbar[i].isActiveAndMatches(keyCode))
            {
                this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, i, ClickType.SWAP);
                return true;
            }
        }
    }

    return false;
}
项目:Project-Zed    文件:ContainerStorageUnit.java   
@Nullable
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
    if (slotId == 1) {
        if (te.getStackInSlot(slotId) == null)
            super.slotClick(slotId, dragType, clickTypeIn, player);
        else {
            final TileEntityIndustrialStorageUnit tileEntity = (TileEntityIndustrialStorageUnit) te;

            ItemStack slotStack = tileEntity.getStackInSlot(slotId);

            if (dragType == 0) {
                tileEntity.getBigItemStack().removeAmount(slotStack.stackSize);
            }

            else if (dragType == 1) {
                slotStack.stackSize >>>= 1;
                tileEntity.getBigItemStack().removeAmount(slotStack.stackSize);
            }

            super.slotClick(slotId, dragType, clickTypeIn, player);
        }
    }

    return super.slotClick(slotId, dragType, clickTypeIn, player);
}
项目:OpenModsLib    文件:FakeSlot.java   
@Override
public ItemStack onClick(EntityPlayer player, int dragType, ClickType clickType) {
    if (clickType == ClickType.CLONE && player.capabilities.isCreativeMode) {
        ItemStack contents = getStack();
        if (!contents.isEmpty()) {
            ItemStack tmp = contents.copy();
            tmp.setCount(tmp.getMaxStackSize());
            player.inventory.setItemStack(tmp);
            return tmp;
        }
    }

    ItemStack held = player.inventory.getItemStack();

    ItemStack place = ItemStack.EMPTY;

    if (!held.isEmpty()) {
        place = held.copy();
        if (!keepSize) place.setCount(1);
    }

    inventory.setInventorySlotContents(slotNumber, place);
    onSlotChanged();
    return place;
}
项目:MineCamera    文件:ContainerCamera.java   
@Override
@Nullable
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
    ItemStack i = super.slotClick(slotId, dragType, clickTypeIn, player);
    saveToNBT(player);
    return i;
}
项目:pnc-repressurized    文件:GuiInventorySearcher.java   
@Override
protected void handleMouseClick(Slot par1Slot, int par2, int par3, ClickType par4) {
    if (par1Slot != null) {
        if (par1Slot.slotNumber == 36) {
            par1Slot.putStack(ItemStack.EMPTY);
        } else {
            setSearchStack(par1Slot.getStack());
        }
    }
}
项目:pnc-repressurized    文件:GuiSearcher.java   
@Override
protected void handleMouseClick(Slot par1Slot, int par2, int par3, ClickType par4) {
    if (par1Slot != null) {
        if (par1Slot.slotNumber == 48) {
            par1Slot.putStack(ItemStack.EMPTY);
        } else {
            inventory.setStackInSlot(48, par1Slot.getStack());
        }
    }
}
项目:pnc-repressurized    文件:GuiLogisticsBase.java   
@Override
protected void handleMouseClick(Slot slot, int slotId, int clickedButton, ClickType clickType) {
    if (slot instanceof SlotPhantom && Minecraft.getMinecraft().player.inventory.getItemStack().isEmpty() && !slot.getHasStack() && clickedButton == 1) {
        editingSlot = slot.getSlotIndex();
        Minecraft.getMinecraft().displayGuiScreen(searchGui = new GuiSearcher(Minecraft.getMinecraft().player));
    } else {
        super.handleMouseClick(slot, slotId, clickedButton, clickType);
    }
}
项目:pnc-repressurized    文件:ContainerPneumaticBase.java   
@Nonnull
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickType, EntityPlayer player) {
    Slot slot = slotId < 0 ? null : inventorySlots.get(slotId);
    if (slot instanceof IPhantomSlot) {
        return slotClickPhantom(slot, dragType, clickType, player);
    }
    return super.slotClick(slotId, dragType, clickType, player);

}
项目:pnc-repressurized    文件:ContainerPneumaticBase.java   
@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;
}
项目:pnc-repressurized    文件:ContainerPneumaticBase.java   
private void fillPhantomSlot(Slot slot, ItemStack stackHeld, ClickType clickType, int dragType) {
    if (!((IPhantomSlot) slot).canAdjust()) {
        return;
    }
    int stackSize = dragType == 0 ? stackHeld.getCount() : 1;
    if (stackSize > slot.getSlotStackLimit()) {
        stackSize = slot.getSlotStackLimit();
    }
    ItemStack phantomStack = stackHeld.copy();
    phantomStack.setCount(stackSize);

    slot.putStack(phantomStack);
}
项目:Never-Enough-Currency    文件:ContainerItem.java   
/**
 * You should override this method to prevent the player from moving the
 * stack that opened the inventory, otherwise if the player moves it, the
 * inventory will not be able to save properly
 */
@Override
public ItemStack slotClick(int slot, int dragType, ClickType clickTypeIn, EntityPlayer player) {
    // this will prevent the player from interacting with the item that
    // opened the inventory:
    if (slot >= 0 && getSlot(slot).getStack() != ItemStack.EMPTY && (getSlot(slot).getStack().getItem() instanceof ItemWallet)) {
        return ItemStack.EMPTY;
    }
    return super.slotClick(slot, dragType, clickTypeIn, player);
}
项目:Anima-Mundi    文件:ContainerSorter.java   
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player)
{
    if(slotId != -999 && getSlot(slotId) != null && getSlot(slotId) instanceof SlotSorter)
    {
        if(getSlot(slotId).getHasStack())
        {
            getSlot(slotId).putStack(ItemStack.EMPTY);
        }

        //TY mcjty
        ItemStack clickedStack = player.inventory.getItemStack();
        if(!clickedStack.isEmpty())
        {
            ItemStack copy = clickedStack.copy();
            copy.setCount(1);
            getSlot(slotId).putStack(copy);
        }
        detectAndSendChanges();
        return ItemStack.EMPTY;
    }

    if(slotId != -999 && getSlot(slotId) instanceof SlotDefaultSort)
    {
        if(dragType == 0)
        {
            te.incrementDefaultSort();
        }
        else
        {
            te.decrementDefaultSort();
        }
    }

    return super.slotClick(slotId, dragType, clickTypeIn, player);
}
项目:Zombe-Modpack    文件:PlayerControllerMP.java   
/**
 * Handles slot clicks, sends a packet to the server.
 */
public ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player)
{
    short short1 = player.openContainer.getNextTransactionID(player.inventory);
    ItemStack itemstack = player.openContainer.slotClick(slotId, mouseButton, type, player);
    this.connection.sendPacket(new CPacketClickWindow(windowId, slotId, mouseButton, type, itemstack, short1));
    return itemstack;
}
项目:Clef    文件:GuiPlayTrackBlock.java   
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
    super.mouseClicked(mouseX, mouseY, mouseButton);
    if (mouseButton == 0 || mouseButton == 1)
    {
        Slot slot = this.getSlotAtPosition(mouseX, mouseY);
        if(slot != null)
        {
            handleMouseClick(slot, slot.slotNumber, mouseButton, ClickType.PICKUP);
        }
    }
}
项目:EMC    文件:ITotem.java   
public static void swapItems(int one, int two, int windowId) {
    Minecraft.getMinecraft().playerController.windowClick(windowId, one, 0, ClickType.SWAP,
            Minecraft.getMinecraft().player);
    Minecraft.getMinecraft().playerController.windowClick(windowId, two, 0, ClickType.SWAP,
            Minecraft.getMinecraft().player);
    Minecraft.getMinecraft().playerController.updateController();
}
项目:EMC    文件:IPlayerController.java   
public static void windowClick(int windowID, int id, int next, IClickType type) {
    ClickType t = ClickType.THROW;
    if (type.equals(IClickType.THROW)) {
        t = ClickType.THROW;
    } else if (type.equals(IClickType.QUICK_MOVE)) {
        t = ClickType.QUICK_MOVE;
    } else {
        return;
    }
    Minecraft.getMinecraft().playerController.windowClick(windowID, id, next, t,
            Minecraft.getMinecraft().player);
}
项目:Backmemed    文件:AutoTotem.java   
public void replaceTotem(int inventoryIndex) {
    if (Wrapper.getPlayer().openContainer instanceof ContainerPlayer) {
        Wrapper.getMinecraft().playerController.windowClick(0, inventoryIndex < 9 ? inventoryIndex + 36 : inventoryIndex, 0, ClickType.PICKUP, Wrapper.getPlayer());
        Wrapper.getMinecraft().playerController.windowClick(0, 45, 0, ClickType.PICKUP, Wrapper.getPlayer());
        Wrapper.getMinecraft().playerController.windowClick(0, inventoryIndex < 9 ? inventoryIndex + 36 : inventoryIndex, 0, ClickType.PICKUP, Wrapper.getPlayer());
    }
}
项目:Backmemed    文件:CPacketClickWindow.java   
public CPacketClickWindow(int windowIdIn, int slotIdIn, int usedButtonIn, ClickType modeIn, ItemStack clickedItemIn, short actionNumberIn)
{
    this.windowId = windowIdIn;
    this.slotId = slotIdIn;
    this.usedButton = usedButtonIn;
    this.clickedItem = clickedItemIn.func_190926_b() ? ItemStack.field_190927_a : clickedItemIn.copy();
    this.actionNumber = actionNumberIn;
    this.mode = modeIn;
}
项目:Backmemed    文件:CPacketClickWindow.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.windowId = buf.readByte();
    this.slotId = buf.readShort();
    this.usedButton = buf.readByte();
    this.actionNumber = buf.readShort();
    this.mode = (ClickType)buf.readEnumValue(ClickType.class);
    this.clickedItem = buf.readItemStackFromBuffer();
}
项目:Backmemed    文件:PlayerControllerMP.java   
/**
 * Handles slot clicks, sends a packet to the server.
 */
public ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, EntityPlayer player)
{
    short short1 = player.openContainer.getNextTransactionID(player.inventory);
    ItemStack itemstack = player.openContainer.slotClick(slotId, mouseButton, type, player);
    this.connection.sendPacket(new CPacketClickWindow(windowId, slotId, mouseButton, type, itemstack, short1));
    return itemstack;
}