MapRenderer 5.46.0
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()
public function __construct(\pocketmine\world\map\BlockMapColors $colors)getBrightness()
public static function getBrightness(int $height, int $northHeight, int $waterDepth, int $pixelX, int $pixelY, int $scale) : intReturns 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()
public static function getUpdateRadius(int $scale) : intReturns the radius (in pixels) of the area refreshed around a player holding the map.
getVisibleLayers()
public function getVisibleLayers(\pocketmine\world\format\Chunk $chunk) : arrayReturns 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()
public function renderColumn(\pocketmine\world\map\MapData $map, \Closure $getChunk, int $pixelX, int $playerPixelX, int $playerPixelY) : intRefreshes one column of map pixels around a player, like one step of vanilla MapItem#update.
sampleColumn()
public function sampleColumn(\pocketmine\world\format\Chunk $chunk, int $x, int $z, ?array $layers = null) : ?arrayFinds the topmost block of a chunk column that shows on maps.
