Ejemplo n.º 1
0
  private Block getBeaconMinBlock(World world) {
    int middle = (int) Math.floor(Coord.getCellSize() / 2.0);
    int radiusCenterExpansion = TownyWarConfig.getBeaconRadius() - 1;
    int fromCorner = middle - radiusCenterExpansion;
    int maxY = world.getMaxHeight();

    int x = (getX() * Coord.getCellSize()) + fromCorner;
    int y = maxY - TownyWarConfig.getBeaconSize();
    int z = (getZ() * Coord.getCellSize()) + fromCorner;

    return world.getBlockAt(x, y, z);
  }
Ejemplo n.º 2
0
  public void loadBeacon() {
    beaconFlagBlocks = new ArrayList<Block>();
    beaconWireframeBlocks = new ArrayList<Block>();

    if (!TownyWarConfig.isDrawingBeacon()) return;

    int beaconSize = TownyWarConfig.getBeaconSize();
    if (Coord.getCellSize() < beaconSize) return;

    Block minBlock = getBeaconMinBlock(getFlagBaseBlock().getWorld());
    if (flagBaseBlock.getY() + 4 > minBlock.getY()) return;

    int outerEdge = beaconSize - 1;
    for (int y = 0; y < beaconSize; y++) {
      for (int z = 0; z < beaconSize; z++) {
        for (int x = 0; x < beaconSize; x++) {
          Block block =
              flagBaseBlock
                  .getWorld()
                  .getBlockAt(minBlock.getX() + x, minBlock.getY() + y, minBlock.getZ() + z);
          if (block.isEmpty()) {
            int edgeCount = getEdgeCount(x, y, z, outerEdge);
            if (edgeCount == 1) {
              beaconFlagBlocks.add(block);
            } else if (edgeCount > 1) {
              beaconWireframeBlocks.add(block);
            }
          }
        }
      }
    }
  }