Java Code Examples for org.bukkit.map.MapCanvas#setPixel()

The following examples show how to use org.bukkit.map.MapCanvas#setPixel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CraftMapRenderer.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
    // Map
    for (int x = 0; x < 128; ++x) {
        for (int y = 0; y < 128; ++y) {
            canvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
        }
    }

    // Cursors
    MapCursorCollection cursors = canvas.getCursors();
    while (cursors.size() > 0) {
        cursors.removeCursor(cursors.getCursor(0));
    }

    for (Object key : worldMap.mapDecorations.keySet()) {
        // If this cursor is for a player check visibility with vanish system
        Player other = Bukkit.getPlayerExact((String) key);
        if (other != null && !player.canSee(other)) {
            continue;
        }

        MapDecoration decoration = worldMap.mapDecorations.get(key);
        cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.getImage());
    }
}
 
Example 2
Source File: ImageMapRenderer.java    From MCAuthenticator with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void render(MapView mapView, MapCanvas mapCanvas, Player player) {
    for (int x = 0; x < 128; x++) {
        for (int z = 0; z < 128; z++) {
            mapCanvas.setPixel(x, z, bitMatrix.get(x, z) ? FILL_COLOR : MapPalette.WHITE);
        }
    }
}
 
Example 3
Source File: CraftMapRenderer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void render(MapView map, MapCanvas canvas, Player player) {
    if(CauldronCommand.debug) {
    System.out.println("Default Map Render called!");
    for (StackTraceElement ste : Thread.currentThread().getStackTrace()) {
        System.out.println(ste);
    } }


    // Map
    for (int x = 0; x < 128; ++x) {
        for (int y = 0; y < 128; ++y) {
            canvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
        }
    }

    // Cursors
    MapCursorCollection cursors = canvas.getCursors();
    while (cursors.size() > 0) {
        cursors.removeCursor(cursors.getCursor(0));
    }

    for (UUID key : worldMap.playersVisibleOnMap.keySet()) { // Spigot string -> uuid
        // If this cursor is for a player check visibility with vanish system
        Player other = Bukkit.getPlayer(key); // Spigot
        if (other != null && !player.canSee(other)) {
            continue;
        }

        net.minecraft.world.storage.MapData.MapCoord decoration = (net.minecraft.world.storage.MapData.MapCoord) worldMap.playersVisibleOnMap.get(key);
        cursors.addCursor(decoration.centerX, decoration.centerZ, (byte) (decoration.iconRotation & 15), decoration.iconSize);
    }
}
 
Example 4
Source File: GraphRenderer.java    From LagMonitor with MIT License 4 votes vote down vote up
protected void clearBar(MapCanvas canvas, int posX) {
    //resets the complete y coordinates on this x in order to free unused
    for (int yPos = 0; yPos < MAX_HEIGHT; yPos++) {
        canvas.setPixel(posX, yPos, (byte) 0);
    }
}
 
Example 5
Source File: GraphRenderer.java    From LagMonitor with MIT License 4 votes vote down vote up
protected void fillBar(MapCanvas canvas, int xPos, int yStart, byte color) {
    for (int yPos = yStart; yPos < MAX_HEIGHT; yPos++) {
        canvas.setPixel(xPos, yPos, color);
    }
}
 
Example 6
Source File: GraphRenderer.java    From LagMonitor with MIT License 4 votes vote down vote up
protected void clearBar(MapCanvas canvas, int posX) {
    //resets the complete y coordinates on this x in order to free unused
    for (int yPos = 0; yPos < MAX_HEIGHT; yPos++) {
        canvas.setPixel(posX, yPos, (byte) 0);
    }
}
 
Example 7
Source File: GraphRenderer.java    From LagMonitor with MIT License 4 votes vote down vote up
protected void fillBar(MapCanvas canvas, int xPos, int yStart, byte color) {
    for (int yPos = yStart; yPos < MAX_HEIGHT; yPos++) {
        canvas.setPixel(xPos, yPos, color);
    }
}