Search in sources :

Example 56 with InventoryPlayer

use of net.minecraft.entity.player.InventoryPlayer in project ConvenientAdditions by Necr0.

the class ContainerTransmutationTome method onContainerClosed.

@Override
public void onContainerClosed(EntityPlayer playerIn) {
    if (player.getEntityWorld().isRemote)
        return;
    InventoryPlayer inventoryplayer = playerIn.inventory;
    if (!inventoryplayer.getItemStack().isEmpty()) {
        playerIn.dropItem(inventoryplayer.getItemStack(), false);
        inventoryplayer.setItemStack(ItemStack.EMPTY);
    }
    if (!handler.getStackInSlot(0).isEmpty()) {
        playerIn.dropItem(handler.getStackInSlot(0), false);
        handler.setStackInSlot(0, ItemStack.EMPTY);
    }
    if (!handler.getStackInSlot(1).isEmpty()) {
        playerIn.dropItem(handler.getStackInSlot(1), false);
        handler.setStackInSlot(1, ItemStack.EMPTY);
    }
    if (!out.getStackInSlot(0).isEmpty()) {
        playerIn.dropItem(out.getStackInSlot(0), false);
        out.setStackInSlot(0, ItemStack.EMPTY);
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer)

Example 57 with InventoryPlayer

use of net.minecraft.entity.player.InventoryPlayer in project ConvenientAdditions by Necr0.

the class CAGuiContainer method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    super.drawScreen(mouseX, mouseY, partialTicks);
    drawDrawables(partialTicks, mouseX, mouseY);
    drawTooltips(partialTicks, mouseX, mouseY);
    //render tooltip again above widgets
    try {
        InventoryPlayer inventoryplayer = this.mc.player.inventory;
        Field f = GuiContainer.class.getDeclaredField("theSlot");
        f.setAccessible(true);
        Slot theSlot = (Slot) f.get(this);
        if (inventoryplayer.getItemStack().isEmpty() && theSlot != null && theSlot.getHasStack()) {
            ItemStack itemstack1 = theSlot.getStack();
            this.renderToolTip(itemstack1, mouseX, mouseY);
        }
    } catch (Exception e) {
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) Field(java.lang.reflect.Field) Slot(net.minecraft.inventory.Slot) ItemStack(net.minecraft.item.ItemStack) IOException(java.io.IOException)

Example 58 with InventoryPlayer

use of net.minecraft.entity.player.InventoryPlayer in project ConvenientAdditions by Necr0.

the class CAContainer method slotClick.

@Override
public ItemStack slotClick(int index, int button, ClickType mode, EntityPlayer player) {
    InventoryPlayer inventoryplayer = player.inventory;
    ItemStack held = inventoryplayer.getItemStack();
    if (index >= 0) {
        Slot s = getSlot(index);
        if (s instanceof IFakeSlot) {
            return ((IFakeSlot) s).slotClick(this, button, mode, player);
        }
    }
    return super.slotClick(index, button, mode, player);
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) IFakeSlot(convenientadditions.api.gui.container.IFakeSlot) Slot(net.minecraft.inventory.Slot) IFakeSlot(convenientadditions.api.gui.container.IFakeSlot) ItemStack(net.minecraft.item.ItemStack)

Example 59 with InventoryPlayer

use of net.minecraft.entity.player.InventoryPlayer in project Galacticraft by micdoodle8.

the class NEIServerUtils method cycleCreativeInv.

public static void cycleCreativeInv(EntityPlayerMP player, int steps) {
    InventoryPlayer inventory = player.inventory;
    // top down [row][col]
    ItemStack[][] slots = new ItemStack[10][9];
    PlayerSave playerSave = NEIServerConfig.forPlayer(player.getName());
    // get
    System.arraycopy(inventory.mainInventory, 0, slots[9], 0, 9);
    for (int row = 0; row < 3; row++) {
        System.arraycopy(inventory.mainInventory, (row + 1) * 9, slots[row + 6], 0, 9);
    }
    for (int row = 0; row < 6; row++) {
        System.arraycopy(playerSave.creativeInv, row * 9, slots[row], 0, 9);
    }
    ItemStack[][] newslots = new ItemStack[10][];
    // put back
    for (int row = 0; row < 10; row++) {
        newslots[(row + steps + 10) % 10] = slots[row];
    }
    System.arraycopy(newslots[9], 0, inventory.mainInventory, 0, 9);
    for (int row = 0; row < 3; row++) {
        System.arraycopy(newslots[row + 6], 0, inventory.mainInventory, (row + 1) * 9, 9);
    }
    for (int row = 0; row < 6; row++) {
        System.arraycopy(newslots[row], 0, playerSave.creativeInv, row * 9, 9);
    }
    playerSave.setDirty();
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 60 with InventoryPlayer

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

the class ContainerBC_Neptune method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(index);
    Slot firstSlot = this.inventorySlots.get(0);
    int playerInventorySize = 36;
    boolean playerInventoryFirst = firstSlot.inventory instanceof InventoryPlayer;
    if (slot != null && slot.getHasStack()) {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();
        if (inventorySlots.size() == playerInventorySize)
            return ItemStack.EMPTY;
        if (playerInventoryFirst) {
            if (index < playerInventorySize) {
                if (!this.mergeItemStack(itemstack1, playerInventorySize, this.inventorySlots.size(), false)) {
                    return ItemStack.EMPTY;
                }
            } else if (!this.mergeItemStack(itemstack1, 0, playerInventorySize, true)) {
                return ItemStack.EMPTY;
            }
        } else {
            if (index < this.inventorySlots.size() - playerInventorySize) {
                if (!this.mergeItemStack(itemstack1, this.inventorySlots.size() - playerInventorySize, this.inventorySlots.size(), false)) {
                    return ItemStack.EMPTY;
                }
            } else if (!this.mergeItemStack(itemstack1, 0, this.inventorySlots.size() - playerInventorySize, true)) {
                return ItemStack.EMPTY;
            }
        }
        if (itemstack1.isEmpty()) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }
    }
    return itemstack;
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) IPhantomSlot(buildcraft.lib.gui.slot.IPhantomSlot) Slot(net.minecraft.inventory.Slot) 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