use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class AEInterfaceInventoryHandler method decrStackSize.
@Override
public ItemStack decrStackSize(int i, int j) {
if (cached == null) {
initCache();
}
Entry<ItemIdentifier, Integer> entry = cached.get(i);
ItemStack extracted = getMultipleItems(entry.getKey(), j);
entry.setValue(entry.getValue() - j);
return extracted;
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class AEInterfaceInventoryHandler method getItemsAndCount.
private Map<ItemIdentifier, Integer> getItemsAndCount(boolean linked) {
Map<ItemIdentifier, Integer> result;
if (linked) {
result = new LinkedHashMap<>();
} else {
result = new HashMap<>();
}
IStorageMonitorable tmp = tile.getMonitorable(dir, source);
if (tmp == null || tmp.getItemInventory() == null || tmp.getItemInventory().getStorageList() == null) {
return result;
}
for (IAEItemStack items : tmp.getItemInventory().getStorageList()) {
ItemIdentifier ident = ItemIdentifier.get(items.getItemStack());
Integer count = result.get(ident);
if (count != null) {
result.put(ident, (int) (count + items.getStackSize() - (hideOnePerStack ? 1 : 0)));
} else {
result.put(ident, (int) (items.getStackSize() - (hideOnePerStack ? 1 : 0)));
}
}
return result;
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class BarrelInventoryHandler method getItemsAndCount.
@Override
public HashMap<ItemIdentifier, Integer> getItemsAndCount() {
HashMap<ItemIdentifier, Integer> map = new HashMap<ItemIdentifier, Integer>();
try {
ItemStack itemStack = (ItemStack) BarrelInventoryHandler.item.get(_tile);
if (itemStack != null) {
int value = (Integer) BarrelInventoryHandler.getItemCount.invoke(_tile, new Object[] {});
map.put(ItemIdentifier.get(itemStack), value - (_hideOnePerStack ? 1 : 0));
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return map;
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class ServerRouter method updateInterests.
@Override
public void updateInterests() {
if (--ticksUntillNextInventoryCheck > 0) {
return;
}
ticksUntillNextInventoryCheck = ServerRouter.REFRESH_TIME;
if (ServerRouter.iterated++ % simpleID == 0) {
// randomly wait 1 extra tick - just so that every router doesn't tick at the same time
ticksUntillNextInventoryCheck++;
}
if (ServerRouter.iterated >= ServerRouter.getBiggestSimpleID()) {
ServerRouter.iterated = 0;
}
CoreRoutedPipe pipe = getPipe();
if (pipe == null) {
return;
}
if (pipe.hasGenericInterests()) {
declareGenericInterest();
} else {
removeGenericInterest();
}
Set<ItemIdentifier> newInterests = pipe.getSpecificInterests();
if (newInterests == null) {
newInterests = new TreeSet<>();
}
if (!newInterests.equals(_hasInterestIn)) {
for (ItemIdentifier i : _hasInterestIn) {
if (!newInterests.contains(i)) {
removeInterest(i);
}
}
newInterests.stream().filter(i -> !_hasInterestIn.contains(i)).forEach(this::addInterest);
_hasInterestIn = newInterests;
}
}
use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.
the class CrateInventoryHandler method getItemsAndCount.
private Map<ItemIdentifier, Integer> getItemsAndCount(boolean linked) {
HashMap<ItemIdentifier, Integer> map = new HashMap<>((int) (_tile.getUniqueItems() * 1.5));
for (ItemStack stack : _tile.getContents()) {
ItemIdentifier itemId = ItemIdentifier.get(stack);
int stackSize = stack.stackSize - (_hideOnePerStack ? 1 : 0);
Integer m = map.get(itemId);
if (m == null) {
map.put(itemId, stackSize);
} else {
map.put(itemId, m + stackSize);
}
}
return map;
}
Aggregations