Search in sources :

Example 1 with IAEFluidStack

use of appeng.api.storage.data.IAEFluidStack 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;
}
Also used : HashMap(java.util.HashMap) ITileStorageMonitorable(appeng.api.implementations.tiles.ITileStorageMonitorable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IGridHost(appeng.api.networking.IGridHost) FluidIdentifier(logisticspipes.utils.FluidIdentifier) IStorageMonitorable(appeng.api.storage.IStorageMonitorable) MachineSource(appeng.api.networking.security.MachineSource) IAEFluidStack(appeng.api.storage.data.IAEFluidStack)

Example 2 with IAEFluidStack

use of appeng.api.storage.data.IAEFluidStack 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;
}
Also used : ITileStorageMonitorable(appeng.api.implementations.tiles.ITileStorageMonitorable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IGridHost(appeng.api.networking.IGridHost) IStorageMonitorable(appeng.api.storage.IStorageMonitorable) MachineSource(appeng.api.networking.security.MachineSource) IAEFluidStack(appeng.api.storage.data.IAEFluidStack)

Aggregations

ITileStorageMonitorable (appeng.api.implementations.tiles.ITileStorageMonitorable)2 IGridHost (appeng.api.networking.IGridHost)2 MachineSource (appeng.api.networking.security.MachineSource)2 IStorageMonitorable (appeng.api.storage.IStorageMonitorable)2 IAEFluidStack (appeng.api.storage.data.IAEFluidStack)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 HashMap (java.util.HashMap)1 FluidIdentifier (logisticspipes.utils.FluidIdentifier)1