Beispiel #1
0
 /**
  * Generates all neighbours around this rail
  *
  * @param deep whether to perform a deep search
  */
 public void genNeighbours(boolean deep) {
   if (deep) {
     for (BlockFace direction : BlockFaces.NESW) {
       MinecartTrackLogic logic = this.getLogic(direction);
       if (logic != null) {
         logic.parent = this;
         logic.direction = direction;
         // find out what connections this rail has
         logic.genNeighbours(false);
         if (logic.neighbours.size() >= 2) {
           continue; // already connected to two misc track pieces
         }
         MinecartTrackLogic self = logic.getLogic(logic.direction.getOpposite());
         self.parent = logic;
         self.direction = logic.direction.getOpposite();
         logic.neighbours.add(self);
         this.neighbours.add(logic);
       }
     }
   } else {
     for (BlockFace direction : this.getState().getDirections()) {
       if (direction == this.direction.getOpposite()) {
         continue;
       }
       MinecartTrackLogic logic = this.getLogic(direction);
       if (logic != null) {
         logic.parent = this;
         logic.direction = direction;
         if (logic.getState().isConnected(direction.getOpposite())) {
           this.neighbours.add(logic);
         }
       }
     }
   }
 }