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;
}
Aggregations