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); } }
/** * Use Bresenham's algorithm to draw line between two squares on the board * * @param from Square index of the first square * @param to Square index of the second square * @param isHighlighting True if drawing a highlight, false if erasing it */ private void drawHighlightLine(int from, int to, boolean isHighlighting) { if (from < 0 || to < 0 || from >= 64 || to >= 64) { return; } Cuboid s1 = getSquare(Chess.sqiToRow(from), Chess.sqiToCol(from)); Cuboid s2 = getSquare(Chess.sqiToRow(to), Chess.sqiToCol(to)); Location loc1 = s1.getRelativeBlock(s1.getSizeX() / 2, 0, s1.getSizeZ() / 2).getLocation(); Location loc2 = s2.getRelativeBlock(s2.getSizeX() / 2, 0, s2.getSizeZ() / 2).getLocation(); int dx = Math.abs(loc1.getBlockX() - loc2.getBlockX()); int dz = Math.abs(loc1.getBlockZ() - loc2.getBlockZ()); int sx = loc1.getBlockX() < loc2.getBlockX() ? 1 : -1; int sz = loc1.getBlockZ() < loc2.getBlockZ() ? 1 : -1; int err = dx - dz; while (loc1.getBlockX() != loc2.getBlockX() || loc1.getBlockZ() != loc2.getBlockZ()) { int sqi = getSquareAt(loc1); MaterialData m = isHighlighting ? boardStyle.getHighlightMaterial(Chess.isWhiteSquare(sqi)) : (Chess.isWhiteSquare(sqi) ? boardStyle.getWhiteSquareMaterial() : boardStyle.getBlackSquareMaterial()); loc1.getBlock().setTypeIdAndData(m.getItemTypeId(), m.getData(), false); int e2 = 2 * err; if (e2 > -dz) { err -= dz; loc1.add(sx, 0, 0); } if (e2 < dx) { err += dx; loc1.add(0, 0, sz); } } }