Java Code Examples for net.minecraft.inventory.ClickType#QUICK_CRAFT

The following examples show how to use net.minecraft.inventory.ClickType#QUICK_CRAFT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContainerInserter.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
    if (this.tef.isFiltered())
    {
        if (this.filterSlots.contains(slotNum))
        {
            this.fakeSlotClick(slotNum, dragType, clickType, player);
            return ItemStack.EMPTY;
        }

        // (Starting) or ending a drag and the dragged slots include at least one of our fake slots
        if (clickType == ClickType.QUICK_CRAFT && slotNum == -999)
        {
            for (int i : this.draggedSlots)
            {
                if (this.filterSlots.contains(i))
                {
                    this.fakeSlotClick(i, dragType, clickType, player);
                    return ItemStack.EMPTY;
                }
            }
        }
    }

    return super.slotClick(slotNum, dragType, clickType, player);
}
 
Example 2
Source File: ContainerPickupManager.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
    if (this.filterSlots.contains(slotNum))
    {
        this.fakeSlotClick(slotNum, dragType, clickType, player);
        return ItemStack.EMPTY;
    }

    // (Starting) or ending a drag and the dragged slots include at least one of our fake slots
    if (clickType == ClickType.QUICK_CRAFT && slotNum == -999)
    {
        for (int i : this.draggedSlots)
        {
            if (this.filterSlots.contains(i))
            {
                this.fakeSlotClick(i, dragType, clickType, player);
                return ItemStack.EMPTY;
            }
        }
    }

    ItemStack stack = super.slotClick(slotNum, dragType, clickType, player);

    ItemStack modularStackPost = this.getContainerItem();

    if (player.getEntityWorld().isRemote == false && modularStackPost.isEmpty() == false &&
        modularStackPost.getItem() == EnderUtilitiesItems.PICKUP_MANAGER)
    {
        boolean sent = ((ItemPickupManager) modularStackPost.getItem()).tryTransportItemsFromTransportSlot(
                this.inventoryItemTransmit, player, modularStackPost);

        // The change is not picked up by detectAndSendChanges() because the items are transported out
        // immediately, so the client side container will get out of sync without a forced sync
        if (sent && player instanceof EntityPlayerMP)
        {
            PacketHandler.INSTANCE.sendTo(new MessageSyncSlot(this.windowId, 0, this.getSlot(0).getStack()), (EntityPlayerMP) player);
        }
    }

    this.detectAndSendChanges();

    return stack;
}
 
Example 3
Source File: ContainerQuickStackerAdvanced.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack slotClick(int slotNum, int dragType, ClickType clickType, EntityPlayer player)
{
    if (this.filterSlots.contains(slotNum))
    {
        this.fakeSlotClick(slotNum, dragType, clickType, player);
        return ItemStack.EMPTY;
    }

    // (Starting) or ending a drag and the dragged slots include at least one of our fake slots
    if (clickType == ClickType.QUICK_CRAFT && slotNum == -999)
    {
        for (int i : this.draggedSlots)
        {
            if (this.filterSlots.contains(i))
            {
                this.fakeSlotClick(i, dragType, clickType, player);
                return ItemStack.EMPTY;
            }
        }
    }
    // Middle click
    else if (clickType == ClickType.CLONE && dragType == 2)
    {
        int invSlotNum = this.getSlot(slotNum) != null ? this.getSlot(slotNum).getSlotIndex() : -1;

        if (invSlotNum == -1 || (invSlotNum >= 36 && invSlotNum != 40))
        {
            return ItemStack.EMPTY;
        }

        long mask = this.teqsa.getEnabledSlotsMask();
        mask ^= (0x1L << invSlotNum);
        this.teqsa.setEnabledSlotsMask(mask);

        return ItemStack.EMPTY;
    }

    ItemStack stack = super.slotClick(slotNum, dragType, clickType, player);

    if (player instanceof EntityPlayerMP)
    {
        this.detectAndSendChanges();
    }

    return stack;
}