Пример #1
0
 @Override
 public void render(Screen screen, MapCanvas canvas) {
   if (canvas.getMapView() != this.map) map = canvas.getMapView();
   Arrays.fill(getBuffer(canvas), (byte) -1);
   for (RenderPriority priority : RenderPriority.values()) {
     if (!renderers.containsKey(priority)) continue;
     for (CanvasRenderer renderer : renderers.get(priority)) {
       if (!renderer.isRendering()) continue;
       directRender(screen, renderer, canvas);
     }
   }
   merge(buffer.buffer, getBuffer(canvas));
 }
Пример #2
0
  @Override
  public void render(MapView view, MapCanvas canvas, Player player) {
    if (renderTask == null) return;

    ChunkInfoRenderingRequest request = renderedRequests.get(view.getId());
    if (request == null) {
      request =
          new ChunkInfoRenderingRequest(
              view.getId(), view.getCenterX(), view.getCenterZ(), view.getWorld().getName());
      renderedRequests.put(view.getId(), request);
      renderTask.add(request);
    }

    MapCursor cursor;

    final Location location = player.getLocation();
    final int playerX = ((location.getBlockX() - view.getCenterX()) >> 3) /*
                                                                               * +
                                                                               * 128
                                                                               */;
    final int playerZ = ((location.getBlockZ() - view.getCenterZ()) >> 3) /*
                                                                               * +
                                                                               * 128
                                                                               */;
    if (playerX < 128 && playerX >= -128 && playerZ < 128 || playerZ >= -128) {
      final byte direction = (byte) (((int) location.getYaw() + 360) % 360 * 16 / 360);
      if (canvas.getCursors().size() == 0) {
        canvas
            .getCursors()
            .addCursor(playerX, playerZ, direction, MapCursor.Type.WHITE_POINTER.getValue());
      } else {
        cursor = canvas.getCursors().getCursor(0);
        cursor.setDirection(direction);
        cursor.setX((byte) (playerX));
        cursor.setY((byte) (playerZ));
      }
    }

    if (!request.isDone()) return;

    final byte[][] data = request.getData();
    for (int ii = 0; ii < 2; ii++) {
      int currentLine = request.nextLine();
      for (int i = 0; i < 128; i++) {
        canvas.setPixel(i, currentLine, data[currentLine][i]);
      }
    }
  }
 private void setCanvasSquare(byte color, int x, int z, int size) {
   for (int t = x; t < (x + size); t++) {
     for (int ta = z; ta < (z + size); ta++) {
       canvas.setPixel(t, ta, color);
     }
   }
 }
Пример #4
0
  @Override
  public void render(MapView view, MapCanvas canvas, Player player) {
    if (imageRendered) {
      return;
    }

    canvas.drawImage(0, 0, image);
    this.imageRendered = true;
  }
  @Override
  public void render(MapView map, MapCanvas canvas, Player p) {

    Byte lastWildernessColor = MapPalette.BROWN;
    Boolean firstCycle = true;

    renderIndex++;
    if (((renderIndex % MAP_SECOND_DELAY) * 20) != 0) return;
    renderIndex = 0;

    // if (p.getItemInHand().getType() != Material.MAP)
    // return;

    this.canvas = canvas;

    TownChunk[][] chunkArray = new TownChunk[7][5];
    TownChunk[][] oldChunkArray = new TownChunk[7][5];
    Chunk playerChunk = p.getLocation().getChunk();

    int playerX = playerChunk.getX();
    int playerZ = playerChunk.getZ();

    ArrayList<TownChunk> chunks = IOManager.getChunks();
    if (chunks != null) {
      for (TownChunk tc : chunks)
        if ((tc.getX() <= (playerX + 3))
            && (tc.getX() >= (playerX - 3))
            && (tc.getZ() <= (playerZ + 2))
            && (tc.getZ() >= (playerZ - 2))) {
          chunkArray[(playerX - tc.getX()) + 3][(playerZ - tc.getZ()) + 2] = tc;
        }
    }

    canvas.drawText(1, 9, MinecraftFont.Font, "Wilderness is gray");
    canvas.drawText(1, 19, MinecraftFont.Font, "Your town is green");
    canvas.drawText(1, 29, MinecraftFont.Font, "Other towns are blue");

    for (int x = 0; x < 7; x++) {
      for (int y = 0; y < 5; y++) {

        Byte color = null;
        TownChunk tc = chunkArray[x][y];
        TownChunk otc = oldChunkArray[x][y];
        Town t = null;

        if ((tc == otc) && (firstCycle == false)) return;

        if (tc == null) // No townchunk, aka wilderness
        {
          if (lastWildernessColor == MapPalette.DARK_GRAY) {
            color = MapPalette.GRAY_1;
            lastWildernessColor = MapPalette.GRAY_1;
          } else {
            color = MapPalette.DARK_GRAY;
            lastWildernessColor = MapPalette.DARK_GRAY;
          }
        } else {
          Town playerTown = IOManager.getPlayerTown(p);
          t = IOManager.getTown(tc.getTown());
          if ((playerTown != null) && (t == playerTown)) {
            color = MapPalette.LIGHT_GREEN; // TownChunk belongs to players town
          } else {
            color = MapPalette.BLUE; // Other Town
          }
          if (lastWildernessColor == MapPalette.DARK_GRAY) {
            lastWildernessColor = MapPalette.GRAY_1;
          } else {
            lastWildernessColor = MapPalette.DARK_GRAY;
          }
        }

        setCanvasSquare(color, (x * 18) + 1, 109 - (y * 18), 18);
        MapCursorCollection cursors = canvas.getCursors();
        for (int i = 0; i < cursors.size(); i++) {
          cursors.removeCursor(cursors.getCursor(i));
        }

        // MapCursor mc = new MapCursor((byte) 0, (byte) 36, (byte) 15, (byte) 0, true);
        // cursors.addCursor(mc);
        oldChunkArray[x][y] = chunkArray[x][y];
      }
    }
    firstCycle = false;
    // oldChunkArray = chunkArray;
  }
Пример #6
0
  // This method gets called at 20tps whenever a map is in a players inventory. Bail out as quickly
  // as possible if we
  // shouldn't do anything with it.
  // https://bukkit.atlassian.net/browse/BUKKIT-476
  @Override
  public void render(MapView map, MapCanvas canvas, Player player) {
    if (map.getCenterX() == Courier.MAGIC_NUMBER
        && map.getId() != plugin.getCourierdb().getCourierMapId()) {
      // it's a Courier map in an ItemFrame. We get called when it's in a loaded chunk. Player
      // doesn't
      // even need to be near it. Performance issues galore ...
      Letter letter = plugin.getTracker().getLetter(map.getCenterZ());
      if (letter != null && letter.getDirty()) {
        plugin
            .getCConfig()
            .clog(
                Level.FINE,
                "Rendering a Courier ItemFrame Letter ("
                    + letter.getId()
                    + ") on Map ("
                    + map.getId()
                    + ")");
        for (int j = 0; j < CANVAS_HEIGHT; j++) {
          for (int i = 0; i < CANVAS_WIDTH; i++) {
            canvas.setPixel(i, j, clearImage[j * 128 + i]);
            //                        canvas.setPixel(i, j, MapPalette.TRANSPARENT);
            //                        canvas.setPixel(i, j, MapPalette.LIGHT_BROWN);
          }
        }

        int drawPos = HEADER_POS;

        if (letter.getHeader() != null) {
          canvas.drawText(
              0, MinecraftFont.Font.getHeight() * drawPos, MinecraftFont.Font, letter.getHeader());
          LetterRenderer.drawLine(
              canvas,
              10,
              MinecraftFont.Font.getHeight() * (drawPos + 1)
                  + (int) (MinecraftFont.Font.getHeight() * 0.4),
              CANVAS_WIDTH - 11,
              MapPalette.DARK_BROWN);
          drawPos = BODY_POS;
        }

        canvas.drawText(
            letter.getLeftMarkerPos(),
            MinecraftFont.Font.getHeight(),
            MinecraftFont.Font,
            letter.getLeftMarker());
        canvas.drawText(
            letter.getRightMarkerPos(),
            MinecraftFont.Font.getHeight(),
            MinecraftFont.Font,
            letter.getRightMarker());

        if (letter.getMessage() != null) {
          canvas.drawText(
              0,
              MinecraftFont.Font.getHeight() * drawPos,
              MinecraftFont.Font,
              Letter.MESSAGE_COLOR + letter.getMessage());
        }

        if (letter.getDisplayDate() != null) {
          canvas.drawText(
              letter.getDisplayDatePos(),
              0,
              MinecraftFont.Font,
              Letter.DATE_COLOR + letter.getDisplayDate());
        }
        letter.setDirty(false);
        player.sendMap(map);
      }
    }
  }