use of pneumaticCraft.common.util.TileEntityCache in project PneumaticCraft by MineMaarten.
the class ModuleNetworkManager method getConnectedModules.
public Set<TubeModule> getConnectedModules(TubeModule module) {
Set<TubeModule> modules = new HashSet<TubeModule>();
Set<TileEntityPressureTube> traversedTubes = new HashSet<TileEntityPressureTube>();
Stack<TileEntityPressureTube> pendingTubes = new Stack<TileEntityPressureTube>();
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 = ((TileEntityPneumaticBase) ((IPneumaticMachine) tube).getAirHandler()).getTileCache();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
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;
}
Aggregations