Search in sources :

Example 1 with IPhantomSlot

use of com.bluepowermod.container.slot.IPhantomSlot in project BluePower by Qmunity.

the class ContainerGhosts method slotClickPhantom.

/**
     * This method is copied from the BuildCraft code, which can be found here: https://github.com/BuildCraft/BuildCraft
     * @author CovertJaguar <http://www.railcraft.info>
     */
private ItemStack slotClickPhantom(Slot slot, int mouseButton, int modifier, EntityPlayer player) {
    ItemStack stack = null;
    if (mouseButton == 2) {
        if (((IPhantomSlot) slot).canAdjust()) {
            slot.putStack(null);
        }
    } else if (mouseButton == 0 || mouseButton == 1) {
        InventoryPlayer playerInv = player.inventory;
        slot.onSlotChanged();
        ItemStack stackSlot = slot.getStack();
        ItemStack stackHeld = playerInv.getItemStack();
        if (stackSlot != null) {
            stack = stackSlot.copy();
        }
        if (stackSlot == null) {
            if (stackHeld != null && slot.isItemValid(stackHeld)) {
                fillPhantomSlot(slot, stackHeld, mouseButton, modifier);
            }
        } else if (stackHeld == null) {
            adjustPhantomSlot(slot, mouseButton, modifier);
            slot.onPickupFromSlot(player, playerInv.getItemStack());
        } else if (slot.isItemValid(stackHeld)) {
            if (canStacksMerge(stackSlot, stackHeld)) {
                adjustPhantomSlot(slot, mouseButton, modifier);
            } else {
                fillPhantomSlot(slot, stackHeld, mouseButton, modifier);
            }
        }
    }
    return stack;
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) IPhantomSlot(com.bluepowermod.container.slot.IPhantomSlot) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IPhantomSlot (com.bluepowermod.container.slot.IPhantomSlot)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 ItemStack (net.minecraft.item.ItemStack)1