Skip to content

MapRenderer 5.46.0 ​

final class · pocketmine\world\map\MapRenderer · source

Draws the terrain seen from above into a map, one map column at a time, the way vanilla does while a player holds the map: pixels within a radius of the player are refreshed, with height shading (brighter when the ground rises towards the south, darker when it falls) and water depth shading. Unloaded chunks are left as they are.

At scales above 0 a pixel covers several blocks; vanilla uses the most common colour of the area, this samples the block in the middle of it to keep the cost per pixel constant.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\world\map\BlockMapColors $colors)

getBrightness() ​

php
public static function getBrightness(int $height, int $northHeight, int $waterDepth, int $pixelX, int $pixelY, int $scale) : int

Returns the shading brightness of a pixel (vanilla MapItem#update): water gets darker with depth, land is brighter when it is higher than the pixel to the north and darker when lower, with a checkerboard dither.

getUpdateRadius() ​

php
public static function getUpdateRadius(int $scale) : int

Returns the radius (in pixels) of the area refreshed around a player holding the map.

getVisibleLayers() ​

php
public function getVisibleLayers(\pocketmine\world\format\Chunk $chunk) : array

Returns the block layers of a chunk that may show on maps, from the top down: subchunks that only contain blocks without a map colour (air, glass...) are left out, so columns don't have to be scanned through them.

renderColumn() ​

php
public function renderColumn(\pocketmine\world\map\MapData $map, \Closure $getChunk, int $pixelX, int $playerPixelX, int $playerPixelY) : int

Refreshes one column of map pixels around a player, like one step of vanilla MapItem#update.

sampleColumn() ​

php
public function sampleColumn(\pocketmine\world\format\Chunk $chunk, int $x, int $z, ?array $layers = null) : ?array

Finds the topmost block of a chunk column that shows on maps.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.