@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]); } } }
// 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); } } }