Search in sources :

Example 1 with IGridHost

use of appeng.api.networking.IGridHost 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 IGridHost

use of appeng.api.networking.IGridHost in project LogisticsPipes by RS485.

the class AETankHandler method getBaseTilesFor.

@Override
public List<TileEntity> getBaseTilesFor(TileEntity tile) {
    List<TileEntity> tiles = new ArrayList<>(1);
    if (tile instanceof IGridHost) {
        IGridHost host = (IGridHost) tile;
        IGridNode node = host.getGridNode(ForgeDirection.UNKNOWN);
        if (node != null) {
            TileEntity base = getBaseTileEntity(node);
            if (base != null) {
                tiles.add(base);
                return tiles;
            }
        }
    }
    tiles.add(tile);
    return tiles;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IGridNode(appeng.api.networking.IGridNode) ArrayList(java.util.ArrayList) IGridHost(appeng.api.networking.IGridHost)

Example 3 with IGridHost

use of appeng.api.networking.IGridHost 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

IGridHost (appeng.api.networking.IGridHost)3 ITileStorageMonitorable (appeng.api.implementations.tiles.ITileStorageMonitorable)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 IGridNode (appeng.api.networking.IGridNode)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 FluidIdentifier (logisticspipes.utils.FluidIdentifier)1 TileEntity (net.minecraft.tileentity.TileEntity)1