Search in sources :

Example 1 with TileEntityCache

use of me.desht.pneumaticcraft.common.util.TileEntityCache in project pnc-repressurized by TeamPneumatic.

the class ModuleNetworkManager method getConnectedModules.

Set<TubeModule> getConnectedModules(TubeModule module) {
    Set<TubeModule> modules = new HashSet<>();
    Set<TileEntityPressureTube> traversedTubes = new HashSet<>();
    Stack<TileEntityPressureTube> pendingTubes = new Stack<>();
    pendingTubes.push((TileEntityPressureTube) module.getTube());
    while (!pendingTubes.isEmpty()) {
        TileEntityPressureTube tube = pendingTubes.pop();
        for (TubeModule m : tube.modules) {
            if (m != null)
                modules.add(m);
        }
        TileEntityCache[] cache = ((AirHandler) tube.getAirHandler(null)).getTileCache();
        for (EnumFacing d : EnumFacing.VALUES) {
            if (tube.sidesConnected[d.ordinal()]) {
                TileEntityPressureTube newTube = ModInteractionUtils.getInstance().getTube(cache[d.ordinal()].getTileEntity());
                if (newTube != null && !traversedTubes.contains(newTube)) {
                    pendingTubes.add(newTube);
                    traversedTubes.add(newTube);
                }
            }
        }
    }
    return modules;
}
Also used : AirHandler(me.desht.pneumaticcraft.common.pressure.AirHandler) EnumFacing(net.minecraft.util.EnumFacing) TileEntityPressureTube(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube) TileEntityCache(me.desht.pneumaticcraft.common.util.TileEntityCache) HashSet(java.util.HashSet) Stack(java.util.Stack)

Aggregations

HashSet (java.util.HashSet)1 Stack (java.util.Stack)1 AirHandler (me.desht.pneumaticcraft.common.pressure.AirHandler)1 TileEntityPressureTube (me.desht.pneumaticcraft.common.tileentity.TileEntityPressureTube)1 TileEntityCache (me.desht.pneumaticcraft.common.util.TileEntityCache)1 EnumFacing (net.minecraft.util.EnumFacing)1