Search in sources :

Example 1 with IGridNode

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

the class AETankHandler method getBaseTileEntity.

private TileEntity getBaseTileEntity(IGridNode node) {
    IGrid grid = node.getGrid();
    if (grid == null) {
        return null;
    }
    IGridNode pivot = grid.getPivot();
    if (pivot == null) {
        return null;
    }
    IGridBlock block = pivot.getGridBlock();
    if (block == null) {
        return null;
    }
    DimensionalCoord coord = block.getLocation();
    if (coord == null) {
        return null;
    }
    World world = coord.getWorld();
    if (world == null) {
        return null;
    }
    return world.getTileEntity(coord.x, coord.y, coord.z);
}
Also used : IGridNode(appeng.api.networking.IGridNode) IGridBlock(appeng.api.networking.IGridBlock) IGrid(appeng.api.networking.IGrid) DimensionalCoord(appeng.api.util.DimensionalCoord) World(net.minecraft.world.World)

Example 2 with IGridNode

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

Aggregations

IGridNode (appeng.api.networking.IGridNode)2 IGrid (appeng.api.networking.IGrid)1 IGridBlock (appeng.api.networking.IGridBlock)1 IGridHost (appeng.api.networking.IGridHost)1 DimensionalCoord (appeng.api.util.DimensionalCoord)1 ArrayList (java.util.ArrayList)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)1