Search in sources :

Example 6 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.

the class ModifierInventory method setInventorySlotContents.

@Override
public void setInventorySlotContents(int index, ItemStack stack) {
    NBTTagCompound tagCompound = entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound();
    ItemStackList stacks = ModifierItem.getItemStacks(tagCompound);
    if (index >= stacks.size()) {
        return;
    }
    stacks.set(index, stack);
    if (!stack.isEmpty() && stack.getCount() > getInventoryStackLimit()) {
        stack.setCount(getInventoryStackLimit());
    }
    convertItemsToNBT(tagCompound, stacks);
    markDirty();
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 7 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.

the class ModifierInventory method decrStackSize.

@Override
public ItemStack decrStackSize(int index, int amount) {
    NBTTagCompound tagCompound = entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound();
    ItemStackList stacks = ModifierItem.getItemStacks(tagCompound);
    if (index >= stacks.size()) {
        return ItemStack.EMPTY;
    }
    if (!stacks.get(index).isEmpty()) {
        if (stacks.get(index).getCount() <= amount) {
            ItemStack old = stacks.get(index);
            stacks.set(index, ItemStack.EMPTY);
            convertItemsToNBT(tagCompound, stacks);
            markDirty();
            return old;
        }
        ItemStack its = stacks.get(index).splitStack(amount);
        if (stacks.get(index).isEmpty()) {
            stacks.set(index, ItemStack.EMPTY);
            convertItemsToNBT(tagCompound, stacks);
        }
        markDirty();
        return its;
    }
    return ItemStack.EMPTY;
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 8 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.

the class ModifierInventory method getStackInSlot.

@Override
public ItemStack getStackInSlot(int index) {
    NBTTagCompound tagCompound = entityPlayer.getHeldItem(EnumHand.MAIN_HAND).getTagCompound();
    ItemStackList stacks = ModifierItem.getItemStacks(tagCompound);
    return stacks.get(index);
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 9 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project RFToolsControl by McJty.

the class CraftingStationTileEntity method request.

public boolean request(ItemStack item, @Nullable Inventory destination) {
    for (BlockPos p : processorList) {
        TileEntity te = getWorld().getTileEntity(p);
        if (te instanceof ProcessorTileEntity) {
            ProcessorTileEntity processor = (ProcessorTileEntity) te;
            ItemStackList items = ItemStackList.create();
            processor.getCraftableItems(items);
            for (ItemStack i : items) {
                if (item.isItemEqual(i)) {
                    String ticket = getNewTicket(destination);
                    if (!checkRequestAmount()) {
                        return false;
                    }
                    activeCraftingRequests.add(new CraftingRequest(ticket, i, 1));
                    processor.fireCraftEvent(ticket, i);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) GenericTileEntity(mcjty.lib.entity.GenericTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) ItemStackList(mcjty.lib.varia.ItemStackList) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 10 with ItemStackList

use of mcjty.lib.varia.ItemStackList in project XNet by McJty.

the class ItemConnectorSettings method getMatcher.

public Predicate<ItemStack> getMatcher() {
    if (matcher == null) {
        ItemStackList filterList = ItemStackList.create();
        for (ItemStack stack : filters) {
            if (!stack.isEmpty()) {
                filterList.add(stack);
            }
        }
        if (filterList.isEmpty()) {
            matcher = itemStack -> true;
        } else {
            ItemFilterCache filterCache = new ItemFilterCache(metaMode, oredictMode, blacklist, nbtMode, filterList);
            matcher = filterCache::match;
        }
    }
    return matcher;
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStackList (mcjty.lib.varia.ItemStackList)30 ItemStack (net.minecraft.item.ItemStack)21 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)9 TileEntity (net.minecraft.tileentity.TileEntity)5 BlockPos (net.minecraft.util.math.BlockPos)5 GenericTileEntity (mcjty.lib.entity.GenericTileEntity)4 ProcessorTileEntity (mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity)4 NBTTagList (net.minecraft.nbt.NBTTagList)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Nonnull (javax.annotation.Nonnull)1 InventoryHelper (mcjty.lib.container.InventoryHelper)1 BlockRenderEvent (mcjty.lib.gui.events.BlockRenderEvent)1 RFTools (mcjty.rftools.RFTools)1 ModularStorageTileEntity (mcjty.rftools.blocks.storage.ModularStorageTileEntity)1 GenericRFToolsItem (mcjty.rftools.items.GenericRFToolsItem)1 FILTER_SLOTS (mcjty.rftools.items.storage.StorageFilterContainer.FILTER_SLOTS)1