Search in sources :

Example 6 with InventoryPlayer

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

the class SlotFakeWithAmount method slotClick.

@Override
public ItemStack slotClick(Container container, int button, ClickType mode, EntityPlayer player) {
    int adder = 0;
    InventoryPlayer inventoryplayer = player.inventory;
    ItemStack held = inventoryplayer.getItemStack();
    if (mode == ClickType.THROW) {
        if (button == 0)
            slotAdd(-1);
        else
            slotAdd(-64);
    } else if (mode == ClickType.SWAP) {
        return ItemStack.EMPTY;
    } else if ((mode == ClickType.PICKUP || mode == ClickType.PICKUP_ALL) && (button == 0 || button == 1)) {
        ItemStack stack = getStack();
        if (!stack.isEmpty() && isItemValid(held)) {
            if (button == 0) {
                adder = held.getCount();
            } else if (button == 1) {
                adder = 1;
            }
            slotAdd(adder);
        } else if (!held.isEmpty()) {
            this.putStack(held.copy());
        } else if (!stack.isEmpty() && held.isEmpty()) {
            adder = button == 0 ? 1 : -1;
            slotAdd(adder);
        }
    } else if ((mode == ClickType.QUICK_MOVE) && (button == 0 || button == 1)) {
        adder = button == 0 ? 8 : -8;
        slotAdd(adder);
    }
    container.detectAndSendChanges();
    return ItemStack.EMPTY;
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 7 with InventoryPlayer

use of net.minecraft.entity.player.InventoryPlayer in project Charset by CharsetMC.

the class ContainerPocketTable method addSlotToContainer.

@Override
protected Slot addSlotToContainer(Slot slot) {
    if (slot.inventory instanceof InventoryPlayer) {
        if (slot.isHere(slot.inventory, heldPos)) {
            slot = new SlotBlocked(slot.inventory, slot.getSlotIndex(), slot.xPos, slot.yPos);
        }
        if (slot.getSlotIndex() >= 9 && (slot.getSlotIndex() % 9) >= 6) {
            slot = new Slot(slot.inventory, slot.getSlotIndex(), slot.xPos, slot.yPos) {

                @Override
                public void onSlotChanged() {
                    super.onSlotChanged();
                    updateCraft();
                }
            };
            craftingSlots.add(slot);
        } else {
            nonCraftingInventorySlots.add(slot);
            if (slot.getSlotIndex() < 9) {
                hotbarSlots.add(slot);
            } else {
                mainInvSlots.add(slot);
            }
            if (slot.getSlotIndex() < 9 && slot.getHasStack() && slot.getStack().getItem() == CharsetCraftingPocket.pocketTable) {
                slot = new Slot(slot.inventory, slot.getSlotIndex(), slot.xPos, slot.yPos) {

                    @Override
                    public boolean canTakeStack(EntityPlayer playerIn) {
                        return false;
                    }
                };
            }
        }
    }
    return super.addSlotToContainer(slot);
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) SlotBlocked(pl.asie.charset.lib.ui.SlotBlocked) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 8 with InventoryPlayer

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

the class SlotUtil method slotClickPhantom.

public static ItemStack slotClickPhantom(SlotForestry slot, int mouseButton, ClickType clickTypeIn, EntityPlayer player) {
    ItemStack stack = ItemStack.EMPTY;
    ItemStack stackSlot = slot.getStack();
    if (!stackSlot.isEmpty()) {
        stack = stackSlot.copy();
    }
    if (mouseButton == 2) {
        fillPhantomSlot(slot, ItemStack.EMPTY, mouseButton);
    } else if (mouseButton == 0 || mouseButton == 1) {
        InventoryPlayer playerInv = player.inventory;
        ItemStack stackHeld = playerInv.getItemStack();
        if (stackSlot.isEmpty()) {
            if (!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) {
                fillPhantomSlot(slot, stackHeld, mouseButton);
            }
        } else if (stackHeld.isEmpty()) {
            adjustPhantomSlot(slot, mouseButton, clickTypeIn);
        } else if (slot.isItemValid(stackHeld)) {
            if (ItemStackUtil.isIdenticalItem(stackSlot, stackHeld)) {
                adjustPhantomSlot(slot, mouseButton, clickTypeIn);
            } else {
                fillPhantomSlot(slot, stackHeld, mouseButton);
            }
        }
    } else if (mouseButton == 5) {
        InventoryPlayer playerInv = player.inventory;
        ItemStack stackHeld = playerInv.getItemStack();
        if (!slot.getHasStack()) {
            fillPhantomSlot(slot, stackHeld, mouseButton);
        }
    }
    return stack;
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 9 with InventoryPlayer

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

the class GuiForestry method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    ledgerManager.drawTooltips(mouseX, mouseY);
    InventoryPlayer playerInv = mc.player.inventory;
    if (playerInv.getItemStack().isEmpty()) {
        GuiUtil.drawToolTips(this, widgetManager.getWidgets(), mouseX, mouseY);
        GuiUtil.drawToolTips(this, buttonList, mouseX, mouseY);
        GuiUtil.drawToolTips(this, inventorySlots.inventorySlots, mouseX, mouseY);
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer)

Example 10 with InventoryPlayer

use of net.minecraft.entity.player.InventoryPlayer in project minecolonies by Minecolonies.

the class WindowBuildTool method onOpened.

/**
 * Called when the window is opened.
 * Sets up the buttons for either hut mode or decoration mode.
 */
@Override
public void onOpened() {
    if (Settings.instance.isStaticSchematicMode()) {
        sections.add(Structures.SCHEMATICS_PREFIX);
        setStructureName(staticSchematicName);
    } else {
        Structures.loadScannedStyleMaps();
        sections.clear();
        final InventoryPlayer inventory = this.mc.player.inventory;
        final List<String> allSections = Structures.getSections();
        for (final String section : allSections) {
            if (section.equals(Structures.SCHEMATICS_PREFIX) || section.equals(Structures.SCHEMATICS_SCAN) || inventoryHasHut(inventory, section)) {
                sections.add(section);
            }
        }
        if (Minecraft.getMinecraft().player.capabilities.isCreativeMode) {
            findPaneOfTypeByID(BUTTON_PASTE, Button.class).setVisible(true);
            findPaneOfTypeByID(BUTTON_PASTE_NICE, Button.class).setVisible(true);
        } else {
            findPaneOfTypeByID(BUTTON_PASTE, Button.class).setVisible(false);
            findPaneOfTypeByID(BUTTON_PASTE_NICE, Button.class).setVisible(false);
        }
        setStructureName(Settings.instance.getStructureName());
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) Button(com.minecolonies.blockout.controls.Button)

Aggregations

InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)81 ItemStack (net.minecraft.item.ItemStack)56 Slot (net.minecraft.inventory.Slot)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)8 Item (net.minecraft.item.Item)6 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)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