Search in sources :

Example 1 with StorageFilterItem

use of mcjty.rftools.items.storage.StorageFilterItem 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)

Aggregations

ItemStackList (mcjty.lib.varia.ItemStackList)1 StorageFilterItem (mcjty.rftools.items.storage.StorageFilterItem)1 StorageTypeItem (mcjty.rftools.items.storage.StorageTypeItem)1