Search in sources :

Example 1 with ItemStackList

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

the class RemoteStorageTileEntity method compact.

// Compact slots.
public void compact(int id) {
    int si = findRemoteIndex(id);
    if (si == -1) {
        return;
    }
    ItemStackList s = findStacksForId(id);
    InventoryHelper.compactStacks(s, 0, maxsize[si]);
    updateStackCount(si);
    markDirty();
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList)

Example 2 with ItemStackList

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

the class RemoteStorageTileEntity method removeStackFromSlotRemote.

public ItemStack removeStackFromSlotRemote(int si, int index) {
    if (index >= slots[si].size()) {
        return ItemStack.EMPTY;
    }
    ItemStackList stacks = slots[si];
    if (stacks.get(index).isEmpty()) {
        return ItemStack.EMPTY;
    }
    ItemStack old = stacks.get(index);
    stacks.set(index, ItemStack.EMPTY);
    numStacks[si]--;
    StorageModuleItem.updateStackSize(getStackInSlot(si), numStacks[si]);
    markDirty();
    return old;
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ItemStackList

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

the class RemoteStorageTileEntity method updateStackCount.

private void updateStackCount(int si) {
    numStacks[si] = 0;
    ItemStackList stacks = slots[si];
    for (ItemStack stack : stacks) {
        if (!stack.isEmpty()) {
            numStacks[si]++;
        }
    }
}
Also used : ItemStackList(mcjty.lib.varia.ItemStackList) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ItemStackList

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

the class ModularStorageTileEntity method isItemValidForSlot.

@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
    if (index >= getSizeInventory()) {
        return false;
    }
    switch(index) {
        case ModularStorageContainer.SLOT_STORAGE_MODULE:
            return !stack.isEmpty() && ModularStorageSetup.storageModuleItem == stack.getItem();
        case ModularStorageContainer.SLOT_FILTER_MODULE:
            return !stack.isEmpty() && stack.getItem() instanceof StorageFilterItem;
        case ModularStorageContainer.SLOT_TYPE_MODULE:
            return !stack.isEmpty() && stack.getItem() instanceof StorageTypeItem;
    }
    if (index < ModularStorageContainer.SLOT_STORAGE) {
        return true;
    }
    if (isStorageAvailableRemotely(index)) {
        index -= ModularStorageContainer.SLOT_STORAGE;
        RemoteStorageTileEntity storageTileEntity = getRemoteStorage(remoteId);
        if (storageTileEntity == null) {
            return false;
        }
        ItemStackList stacks = storageTileEntity.findStacksForId(remoteId);
        if (index >= stacks.size()) {
            return false;
        }
    }
    if (inventoryHelper.containsItem(ModularStorageContainer.SLOT_FILTER_MODULE)) {
        getFilterCache();
        if (filterCache != null) {
            return filterCache.match(stack);
        }
    }
    return true;
}
Also used : StorageFilterItem(mcjty.rftools.items.storage.StorageFilterItem) StorageTypeItem(mcjty.rftools.items.storage.StorageTypeItem) ItemStackList(mcjty.lib.varia.ItemStackList)

Example 5 with ItemStackList

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

the class InventoryAccessSettings 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