Search in sources :

Example 1 with ItemFrameInfo

use of com.bergerkiller.bukkit.common.internal.CommonMapController.ItemFrameInfo in project BKCommonLib by bergerhealer.

the class MapDisplay method preRunInitialize.

// called when setRunning(true) is called, right before onAttached
private void preRunInitialize() {
    // Figure out what item frame tiles exist on the server
    this.tiles.clear();
    for (ItemFrameInfo itemFrame : this.info.itemFrames) {
        MapUUID uuid = itemFrame.lastMapUUID;
        if (uuid != null && (uuid.getTileX() != 0 || uuid.getTileY() != 0)) {
            if (!this.containsTile(uuid.getTileX(), uuid.getTileY())) {
                this.tiles.add(new MapDisplayTile(this, uuid.getTileX(), uuid.getTileY()));
            }
        }
    }
    // Tile 0,0 always exists (held map)
    if (!this.containsTile(0, 0)) {
        this.tiles.add(0, new MapDisplayTile(this, 0, 0));
    }
    // Calculate the dimensions from the tiles and further initialize the buffers
    int minTileX = Integer.MAX_VALUE;
    int minTileY = Integer.MAX_VALUE;
    int maxTileX = 0;
    int maxTileY = 0;
    for (MapDisplayTile tile : this.tiles) {
        if (tile.tileX < minTileX)
            minTileX = tile.tileX;
        if (tile.tileX > maxTileX)
            maxTileX = tile.tileX;
        if (tile.tileY < minTileY)
            minTileY = tile.tileY;
        if (tile.tileY > maxTileY)
            maxTileY = tile.tileY;
    }
    this.width = (maxTileX - minTileX + 1) * 128;
    this.height = (maxTileY - minTileY + 1) * 128;
    this.zbuffer = new byte[this.width * this.height];
    this.livebuffer = new byte[this.width * this.height];
    this.layerStack = new Layer(this);
}
Also used : ItemFrameInfo(com.bergerkiller.bukkit.common.internal.CommonMapController.ItemFrameInfo) MapUUID(com.bergerkiller.bukkit.common.map.util.MapUUID)

Aggregations

ItemFrameInfo (com.bergerkiller.bukkit.common.internal.CommonMapController.ItemFrameInfo)1 MapUUID (com.bergerkiller.bukkit.common.map.util.MapUUID)1