///// Multiblock Connection Base Logic @Override public Set<MultiblockControllerBase> attachToNeighbors() { Set<MultiblockControllerBase> controllers = null; MultiblockControllerBase bestController = null; // Look for a compatible controller in our neighboring parts. IMultiblockPart[] partsToCheck = getNeighboringParts(); for (IMultiblockPart neighborPart : partsToCheck) { if (neighborPart.isConnected()) { MultiblockControllerBase candidate = neighborPart.getMultiblockController(); if (!candidate.getClass().equals(this.getMultiblockControllerType())) { // Skip multiblocks with incompatible types continue; } if (controllers == null) { controllers = new HashSet<MultiblockControllerBase>(); bestController = candidate; } else if (!controllers.contains(candidate) && candidate.shouldConsume(bestController)) { bestController = candidate; } controllers.add(candidate); } } // If we've located a valid neighboring controller, attach to it. if (bestController != null) { // attachBlock will call onAttached, which will set the controller. this.controller = bestController; bestController.attachBlock(this); } return controllers; }