use of appeng.api.networking.security.MachineSource 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;
}
use of appeng.api.networking.security.MachineSource in project LogisticsPipes by RS485.
the class AETankHandler method drainFrom.
@SuppressWarnings("unused")
@Override
public FluidStack drainFrom(TileEntity tile, FluidIdentifier ident, Integer amount, boolean drain) {
if (tile instanceof ITileStorageMonitorable) {
ITileStorageMonitorable mon = (ITileStorageMonitorable) tile;
if (mon == null) {
return null;
}
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();
IAEFluidStack s = AEApi.instance().storage().createFluidStack(ident.makeFluidStack(amount));
IAEFluidStack extracted = fluids.extractItems(s, drain ? Actionable.MODULATE : Actionable.SIMULATE, source);
if (extracted == null) {
return null;
}
return extracted.getFluidStack();
}
}
return null;
}
Aggregations