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();
}
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;
}
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]++;
}
}
}
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;
}
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;
}
Aggregations