示例#1
0
 private void paintBoardSquare(int row, int col, MassBlockUpdate mbu) {
   Cuboid square = getSquare(row, col);
   boolean black = (col + (row % 2)) % 2 == 0;
   if (mbu == null) {
     square.fill(
         black ? boardStyle.getBlackSquareMaterial() : boardStyle.getWhiteSquareMaterial());
   } else {
     square.fill(
         black ? boardStyle.getBlackSquareMaterial() : boardStyle.getWhiteSquareMaterial(), mbu);
   }
 }
 private void paintBoardSquare(int row, int col, MassBlockUpdate mbu) {
   Cuboid square = getSquare(row, col);
   boolean black = (col + (row % 2)) % 2 == 0;
   if (mbu == null) {
     square.fill(
         black ? boardStyle.getBlackSquareMaterial() : boardStyle.getWhiteSquareMaterial());
   } else {
     square.fill(
         black ? boardStyle.getBlackSquareMaterial() : boardStyle.getWhiteSquareMaterial(), mbu);
   }
   if (ChessCraft.getInstance().getDynmapIntegration() != null) {
     ChessCraft.getInstance().getDynmapIntegration().triggerUpdate(square);
   }
 }
  /**
   * Draw the chess piece represented by stone into the given row and column. The actual blocks
   * drawn depend on the board's current chess set.
   *
   * @param row
   * @param col
   * @param stone
   */
  public void paintChessPiece(int row, int col, int stone) {
    // for entity sets, just check that the entity is still at (row,col)
    // for block sets, get the stone and paste its data into the region at (row,col)
    ChessSet cSet = designer != null ? designer.getChessSet() : chessSet;
    if (cSet.hasMovablePieces()) {
      // we don't paint movable pieces; moveChessPiece() can handle those
      return;
    }
    Cuboid region = getPieceRegion(row, col);
    MassBlockUpdate mbu =
        CraftMassBlockUpdate.createMassBlockUpdater(
            ChessCraft.getInstance(), getBoard().getWorld());
    region.fill(0, (byte) 0, mbu);
    if (stone != Chess.NO_STONE) {
      ChessStone cStone = cSet.getStone(stone, getRotation());
      if (cStone != null) {
        cStone.paint(region, mbu);
      } else {
        LogUtils.severe("unknown chess stone " + stone);
      }
    }

    region.expand(CuboidDirection.Down, 1).forceLightLevel(boardStyle.getLightLevel());
    mbu.notifyClients();
    if (ChessCraft.getInstance().getDynmapIntegration() != null) {
      ChessCraft.getInstance().getDynmapIntegration().triggerUpdate(region);
    }
  }
 /** Clear full area associated with this board */
 void clearAll() {
   MassBlockUpdate mbu =
       CraftMassBlockUpdate.createMassBlockUpdater(
           ChessCraft.getInstance(), getBoard().getWorld());
   fullBoard.fill(0, (byte) 0, mbu);
   mbu.notifyClients();
   if (ChessCraft.getInstance().getDynmapIntegration() != null) {
     ChessCraft.getInstance().getDynmapIntegration().triggerUpdate(fullBoard);
   }
 }
 /** Board is in designer mode - paint some markers on unused squares */
 private void paintDesignIndicators(MassBlockUpdate mbu) {
   Wool marker = new Wool(DyeColor.RED); // make configurable?
   for (int row = 0; row < 8; ++row) {
     for (int col = 0; col < 8; ++col) {
       if (row < 2 && col < 5 || row == 6 && col == 0 || row == 7 && col < 5) {
         continue;
       }
       Cuboid sq =
           getSquare(row, col).shift(CuboidDirection.Up, 1).inset(CuboidDirection.Horizontal, 1);
       sq.fill(marker, mbu);
     }
   }
 }
示例#6
0
 /** Board is in designer mode - paint some markers on unused squares */
 private void paintDesignIndicators(MassBlockUpdate mbu) {
   MaterialWithData marker = MaterialWithData.get("wool:red"); // configurable?
   for (int row = 0; row < 8; ++row) {
     for (int col = 0; col < 8; ++col) {
       if (row < 2 && col < 5) {
         continue;
       }
       Cuboid sq =
           getSquare(row, col).shift(CuboidDirection.Up, 1).inset(CuboidDirection.Horizontal, 1);
       sq.fill(marker, mbu);
     }
   }
 }
  private void paintStruts(MassBlockUpdate mbu) {
    MaterialData struts = boardStyle.getStrutsMaterial();

    // vertical struts at the frame corners
    Cuboid c =
        new Cuboid(frameBoard.getLowerNE())
            .shift(CuboidDirection.Up, 1)
            .expand(CuboidDirection.Up, boardStyle.getHeight());
    c.fill(struts, mbu);
    c = c.shift(CuboidDirection.South, frameBoard.getSizeX() - 1);
    c.fill(struts, mbu);
    c = c.shift(CuboidDirection.West, frameBoard.getSizeZ() - 1);
    c.fill(struts, mbu);
    c = c.shift(CuboidDirection.North, frameBoard.getSizeZ() - 1);
    c.fill(struts, mbu);

    // horizontal struts along roof edge
    Cuboid roof = frameBoard.shift(CuboidDirection.Up, boardStyle.getHeight() + 1);
    roof.getFace(CuboidDirection.East).fill(struts, mbu);
    roof.getFace(CuboidDirection.North).fill(struts, mbu);
    roof.getFace(CuboidDirection.West).fill(struts, mbu);
    roof.getFace(CuboidDirection.South).fill(struts, mbu);
  }
示例#8
0
 /** Paint everything! (board, frame, enclosure, control panel, lighting) */
 void paintAll(MassBlockUpdate mbu) {
   if (designer == null) {
     fullBoard.fill(0, (byte) 0, mbu);
   }
   paintEnclosure(mbu);
   paintFrame(mbu);
   paintBoard(mbu);
   if (designer != null) {
     paintDesignIndicators(mbu);
   }
   if (fromSquare >= 0 || toSquare >= 0) {
     highlightSquares(fromSquare, toSquare);
   }
   fullBoard.forceLightLevel(boardStyle.getLightLevel());
 }
示例#9
0
  /**
   * Draw the chess piece represented by stone into the given row and column. The actual blocks
   * drawn depend on the board's current chess set.
   *
   * @param row
   * @param col
   * @param stone
   */
  public void paintChessPiece(int row, int col, int stone) {
    Cuboid region = getPieceRegion(row, col);
    MassBlockUpdate mbu = CraftMassBlockUpdate.createMassBlockUpdater(getBoard().getWorld());
    region.fill(0, (byte) 0, mbu);
    ChessSet cSet = designer != null ? designer.getChessSet() : chessPieceSet;
    if (stone != Chess.NO_STONE) {
      ChessStone cStone = cSet.getStone(stone, getRotation());
      if (cStone != null) {
        paintChessPiece(region, cStone, mbu);
      } else {
        LogUtils.severe("unknown piece: " + stone);
      }
    }

    region.expand(CuboidDirection.Down, 1).forceLightLevel(boardStyle.getLightLevel());
    mbu.notifyClients();
  }
示例#10
0
 /** Paint everything! (board, frame, enclosure, control panel, lighting) */
 void paintAll(MassBlockUpdate mbu) {
   if (designer == null) {
     fullBoard.fill(0, (byte) 0, mbu);
   }
   paintEnclosure(mbu);
   paintFrame(mbu);
   paintBoard(mbu);
   if (designer != null) {
     paintDesignIndicators(mbu);
   }
   if (fromSquare >= 0 || toSquare >= 0) {
     highlightSquares(fromSquare, toSquare);
   }
   fullBoard.forceLightLevel(boardStyle.getLightLevel());
   redrawNeeded = false;
   if (ChessCraft.getInstance().getDynmapIntegration() != null) {
     ChessCraft.getInstance().getDynmapIntegration().triggerUpdate(fullBoard);
   }
 }
示例#11
0
 /** Clear full area associated with this board */
 void clearAll() {
   MassBlockUpdate mbu = CraftMassBlockUpdate.createMassBlockUpdater(getBoard().getWorld());
   fullBoard.fill(0, (byte) 0, mbu);
   mbu.notifyClients();
 }