Пример #1
0
 private void highlightBoardSquare(int row, int col) {
   Cuboid sq = getSquare(row, col);
   MaterialData squareHighlightColor = boardStyle.getHighlightMaterial(col + (row % 2) % 2 == 1);
   switch (boardStyle.getHighlightStyle()) {
     case EDGES:
       sq.getFace(CuboidDirection.East).fill(squareHighlightColor);
       sq.getFace(CuboidDirection.North).fill(squareHighlightColor);
       sq.getFace(CuboidDirection.West).fill(squareHighlightColor);
       sq.getFace(CuboidDirection.South).fill(squareHighlightColor);
       break;
     case CORNERS:
       for (Block b : sq.corners()) {
         b.setTypeIdAndData(
             squareHighlightColor.getItemTypeId(), squareHighlightColor.getData(), false);
       }
       break;
     case CHECKERED:
     case CHEQUERED:
       for (Block b : sq) {
         if ((b.getLocation().getBlockX() - b.getLocation().getBlockZ()) % 2 == 0) {
           b.setTypeIdAndData(
               squareHighlightColor.getItemTypeId(), squareHighlightColor.getData(), false);
         }
       }
       break;
     default:
       break;
   }
   if (ChessCraft.getInstance().getDynmapIntegration() != null) {
     ChessCraft.getInstance().getDynmapIntegration().triggerUpdate(sq);
   }
 }
Пример #2
0
 private void highlightBoardSquare(int row, int col, boolean highlight) {
   if (!highlight) {
     paintBoardSquare(row, col, null);
   } else {
     Cuboid sq = getSquare(row, col);
     MaterialWithData squareHighlightColor =
         boardStyle.getHighlightMaterial(col + (row % 2) % 2 == 1);
     switch (boardStyle.getHighlightStyle()) {
       case EDGES:
         sq.getFace(CuboidDirection.East).fill(squareHighlightColor);
         sq.getFace(CuboidDirection.North).fill(squareHighlightColor);
         sq.getFace(CuboidDirection.West).fill(squareHighlightColor);
         sq.getFace(CuboidDirection.South).fill(squareHighlightColor);
         break;
       case CORNERS:
         for (Block b : sq.corners()) {
           squareHighlightColor.applyToBlock(b);
         }
         break;
       case CHECKERED:
       case CHEQUERED:
         for (Block b : sq) {
           if ((b.getLocation().getBlockX() - b.getLocation().getBlockZ()) % 2 == 0) {
             squareHighlightColor.applyToBlock(b.getLocation().getBlock());
           }
         }
         break;
     }
   }
 }
Пример #3
0
  /**
   * Ensure this board isn't built too high and doesn't intersect any other boards
   *
   * @throws ChessException if an intersection would occur
   */
  private void validateBoardPosition() throws ChessException {
    Cuboid bounds = getFullBoard();

    if (bounds.getUpperSW().getBlock().getLocation().getY()
        > bounds.getUpperSW().getWorld().getMaxHeight()) {
      throw new ChessException(Messages.getString("BoardView.boardTooHigh")); // $NON-NLS-1$
    }
    for (BoardView bv : BoardViewManager.getManager().listBoardViews()) {
      if (bv.getA1Square().getWorld() != bounds.getWorld()) {
        continue;
      }
      for (Block b : bounds.corners()) {
        if (bv.getOuterBounds().contains(b)) {
          throw new ChessException(
              Messages.getString("BoardView.boardWouldIntersect", bv.getName())); // $NON-NLS-1$
        }
      }
    }
  }