/** * Gets mythic material name. * * @param matData the mat data * @return the mythic material name */ public String getMythicMaterialName(MaterialData matData) { String comb = String.format( "%s;%s", String.valueOf(matData.getItemTypeId()), String.valueOf(matData.getData())); String comb2; if (matData.getData() == (byte) 0) { comb2 = String.valueOf(matData.getItemTypeId()); } else { comb2 = comb; } String mythicMatName = getPlugin() .getConfigurationManager() .getConfiguration(MythicConfigurationFile.LANGUAGE) .getString(comb.toLowerCase()); if (mythicMatName == null) { mythicMatName = getPlugin() .getConfigurationManager() .getConfiguration(MythicConfigurationFile.LANGUAGE) .getString(comb2.toLowerCase()); if (mythicMatName == null) { mythicMatName = getMinecraftMaterialName(matData.getItemType()); } } return StringUtils.getInitCappedString(mythicMatName.split(" ")); }
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); } }
@Override public void changeBlock(Block block) { if (block.getTypeId() == match.getItemTypeId() && (match.getData() == 0 || block.getData() == match.getData())) { player.sendBlockChange(block.getLocation(), item.getItemType(), item.getData()); } }
/** * 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); } } }
@Override public void setRegion( int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material) { setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.getItemTypeId(), material.getData()); }
@Override public void setBlock(int x, int y, int z, MaterialData material) { setBlock(x, y, z, material.getItemTypeId(), material.getData()); }
@Override public boolean equals(MaterialData matData) { return matData.getItemTypeId() == type && matData.getData() == data; }