use of appeng.api.storage.IStorageMonitorable in project LogisticsPipes by RS485.
the class AEInterfaceInventoryHandler method getItems.
@Override
public Set<ItemIdentifier> getItems() {
Set<ItemIdentifier> result = new TreeSet<>();
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());
result.add(ident);
}
return result;
}
use of appeng.api.storage.IStorageMonitorable in project LogisticsPipes by RS485.
the class AEInterfaceInventoryHandler method getMultipleItems.
@Override
public ItemStack getMultipleItems(ItemIdentifier item, int count) {
IStorageMonitorable tmp = tile.getMonitorable(dir, source);
if (tmp == null || tmp.getItemInventory() == null) {
return null;
}
IAEItemStack stack = AEApi.instance().storage().createItemStack(item.makeNormalStack(count));
IAEItemStack extract = tmp.getItemInventory().extractItems(stack, Actionable.MODULATE, source);
if (extract == null) {
return null;
}
return extract.getItemStack();
}
use of appeng.api.storage.IStorageMonitorable 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 appeng.api.storage.IStorageMonitorable in project LogisticsPipes by RS485.
the class LPActionSource method add.
@Override
@Nonnull
public ItemStack add(@Nonnull ItemStack stack, EnumFacing from, boolean doAdd) {
ItemStack st = stack.copy();
IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
IAEItemStack tst = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(stack);
IStorageMonitorable tmp = acc.getInventory(source);
if (tmp == null || tmp.getInventory(channel) == null) {
return st;
}
IAEItemStack overflow = tmp.getInventory(channel).injectItems(tst, Actionable.MODULATE, source);
if (overflow != null) {
st.setCount((int) (st.getCount() - overflow.getStackSize()));
}
return st;
}
use of appeng.api.storage.IStorageMonitorable in project LogisticsPipes by RS485.
the class AETankHandler method getAvailableLiquid.
@SuppressWarnings("unused")
@Override
public Map<FluidIdentifier, Long> getAvailableLiquid(TileEntity tile) {
Map<FluidIdentifier, Long> map = new HashMap<>();
if (tile instanceof ITileStorageMonitorable) {
ITileStorageMonitorable mon = (ITileStorageMonitorable) tile;
if (mon == null) {
return map;
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
MachineSource source = new MachineSource(new LPActionHost(((IGridHost) tile).getGridNode(dir)));
IStorageMonitorable monitor = mon.getMonitorable(dir, source);
if (monitor == null || monitor.getFluidInventory() == null) {
continue;
}
IMEMonitor<IAEFluidStack> fluids = monitor.getFluidInventory();
for (IAEFluidStack stack : fluids.getStorageList()) {
if (SimpleServiceLocator.extraCellsProxy.canSeeFluidInNetwork(stack.getFluid())) {
map.put(FluidIdentifier.get(stack.getFluid(), stack.getTagCompound() != null ? stack.getTagCompound().getNBTTagCompoundCopy() : null, null), stack.getStackSize());
}
}
return map;
}
}
return map;
}
Aggregations