Search in sources :

Example 81 with InventoryPlayer

use of net.minecraft.entity.player.InventoryPlayer in project Railcraft by Railcraft.

the class RailcraftContainer method slotClickPhantom.

protected ItemStack slotClickPhantom(SlotRailcraft slot, int mouseButton, ClickType clickType, EntityPlayer player) {
    ItemStack stack = InvTools.emptyStack();
    if (mouseButton == 2) {
        if (slot.canAdjustPhantom())
            slot.putStack(ItemStack.EMPTY);
    } else if (mouseButton == 0 || mouseButton == 1) {
        InventoryPlayer playerInv = player.inventory;
        slot.onSlotChanged();
        ItemStack stackSlot = slot.getStack();
        ItemStack stackHeld = playerInv.getItemStack();
        if (!InvTools.isEmpty(stackSlot))
            stack = stackSlot.copy();
        if (InvTools.isEmpty(stackSlot)) {
            if (!InvTools.isEmpty(stackHeld) && slot.isItemValid(stackHeld))
                fillPhantomSlot(slot, stackHeld, mouseButton);
        } else if (InvTools.isEmpty(stackHeld)) {
            adjustPhantomSlot(slot, mouseButton, clickType);
            slot.onTake(player, playerInv.getItemStack());
        } else if (slot.isItemValid(stackHeld))
            if (InvTools.isItemEqual(stackSlot, stackHeld))
                adjustPhantomSlot(slot, mouseButton, clickType);
            else
                fillPhantomSlot(slot, stackHeld, mouseButton);
    }
    return stack;
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 82 with InventoryPlayer

use of net.minecraft.entity.player.InventoryPlayer in project PneumaticCraft by MineMaarten.

the class ContainerPneumaticBase method slotClickPhantom.

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) ItemStack(net.minecraft.item.ItemStack)

Example 83 with InventoryPlayer

use of net.minecraft.entity.player.InventoryPlayer in project ForestryMC by ForestryMC.

the class ContainerForestry method slotClickPhantom.

private ItemStack slotClickPhantom(Slot slot, int mouseButton, int modifier, EntityPlayer player) {
    ItemStack stack = null;
    ItemStack stackSlot = slot.getStack();
    if (stackSlot != null) {
        stack = stackSlot.copy();
    }
    if (mouseButton == 2) {
        fillPhantomSlot(slot, null, mouseButton, modifier);
    } else if (mouseButton == 0 || mouseButton == 1) {
        InventoryPlayer playerInv = player.inventory;
        ItemStack stackHeld = playerInv.getItemStack();
        if (stackSlot == null) {
            if (stackHeld != null && slot.isItemValid(stackHeld)) {
                fillPhantomSlot(slot, stackHeld, mouseButton, modifier);
            }
        } else if (stackHeld == null) {
            adjustPhantomSlot(slot, mouseButton, modifier);
        } else if (slot.isItemValid(stackHeld)) {
            if (StackUtils.isIdenticalItem(stackSlot, stackHeld)) {
                adjustPhantomSlot(slot, mouseButton, modifier);
            } else {
                fillPhantomSlot(slot, stackHeld, mouseButton, modifier);
            }
        }
    } else if (mouseButton == 5) {
        InventoryPlayer playerInv = player.inventory;
        ItemStack stackHeld = playerInv.getItemStack();
        if (!slot.getHasStack()) {
            fillPhantomSlot(slot, stackHeld, mouseButton, modifier);
        }
    }
    return stack;
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) ItemStack(net.minecraft.item.ItemStack)

Aggregations

InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)83 ItemStack (net.minecraft.item.ItemStack)57 Slot (net.minecraft.inventory.Slot)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)9 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)7 Item (net.minecraft.item.Item)6 ArrayList (java.util.ArrayList)5 Nonnull (javax.annotation.Nonnull)4 IFuzzySlot (logisticspipes.interfaces.IFuzzySlot)4 Button (com.minecolonies.blockout.controls.Button)3 EntityItem (net.minecraft.entity.item.EntityItem)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 IPhantomSlot (buildcraft.lib.gui.slot.IPhantomSlot)2 TileProjectTable (com.bluepowermod.tile.tier1.TileProjectTable)2 ItemIcon (com.minecolonies.blockout.controls.ItemIcon)2 Label (com.minecolonies.blockout.controls.Label)2 BuildingBuilderResource (com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource)2 GameProfile (com.mojang.authlib.GameProfile)2 LinkedList (java.util.LinkedList)2