PHPackages                             cosmicpe/maprender - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. cosmicpe/maprender

ActiveLibrary[API Development](/categories/api)

cosmicpe/maprender
==================

PocketMine-MP library to render regions in worlds as a 2D topographic map

v0.0.1(1y ago)1521GPL-3.0-onlyPHPPHP ^8.3

Since Mar 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Cosmoverse/MapRender)[ Packagist](https://packagist.org/packages/cosmicpe/maprender)[ RSS](/packages/cosmicpe-maprender/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

MapRender
=========

[](#maprender)

A library for rendering a topographic view of sections within a world in PocketMine-MP.

[![A render of a few world regions from a PocketMine-MP server](https://private-user-images.githubusercontent.com/15074389/428359595-51fe57e6-07ae-4e8a-82d2-2f30d3507d8a.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MjA3MDksIm5iZiI6MTc3NTUyMDQwOSwicGF0aCI6Ii8xNTA3NDM4OS80MjgzNTk1OTUtNTFmZTU3ZTYtMDdhZS00ZThhLTgyZDItMmYzMGQzNTA3ZDhhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA0MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA3VDAwMDY0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk2NDljN2VlN2FiZjY0NDNhMGIwMWJjNTM3ZWMwN2VhYmZmZjNhYWM2NmNhZjAwMDc3MWY5NmU4NzQ0NDI4N2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.PxOOBRKoavp804OFlWV-RTdxBL4fZ0Zkgci_1Y2laMo)](https://private-user-images.githubusercontent.com/15074389/428359595-51fe57e6-07ae-4e8a-82d2-2f30d3507d8a.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MjA3MDksIm5iZiI6MTc3NTUyMDQwOSwicGF0aCI6Ii8xNTA3NDM4OS80MjgzNTk1OTUtNTFmZTU3ZTYtMDdhZS00ZThhLTgyZDItMmYzMGQzNTA3ZDhhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA0MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA3VDAwMDY0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk2NDljN2VlN2FiZjY0NDNhMGIwMWJjNTM3ZWMwN2VhYmZmZjNhYWM2NmNhZjAwMDc3MWY5NmU4NzQ0NDI4N2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.PxOOBRKoavp804OFlWV-RTdxBL4fZ0Zkgci_1Y2laMo)

Features
--------

[](#features)

- Vibrant color palette spanning 800+ blocks
- Represent translucent blocks
- Elevation detail using shadows
- Render asynchronously

Usage
-----

[](#usage)

MapRender uses [SOF3/await-generator](https://github.com/SOF3/await-generator) to perform rendering asynchronously. A MapRender instance may be initialized once and reused. MapRender is stateless, meaning you may invoke `MapRender::render()`concurrently. `render()` returns a GdImage which gives you the ability to export the image as needed, or perhaps further preprocess the image. See [examples](#Examples) for a few ways you can use this. Coordinate parameters `$x1`, `$x2`, `$z1`, and `$z2` are chunk coordinates (not to be confused with block coordinates).

```
use cosmicpe\maprender\MapRender;

$render = MapRender::create($plugin);
$image = yield from $render->render($world, $x1, $z1, $x2, $z2);
$output = $plugin->getDataFolder() . DIRECTORY_SEPARATOR . "map-render.png";
imagepng($image, $output);
```

If you are unfamiliar with await-generator and are looking for a quick setup, use `Await::f2c()` to make a callback wrapper.

```
/** @param Closure(GdImage) : void */
public function render(World $world, int $x1, int $z1, int $x2, int $z2, Closure $callback) : void{
	$render = MapRender::create($plugin);
	$task = $render->render($world, $x1, $z1, $x2, $z2);
	Await::f2c(function() use($task, $callback) : Generator{
		$image = yield from $task;
		$callback($image);
	});
}
```

Examples
--------

[](#examples)

If you are working with block coordinates, use `Chunk::COORD_BIT_SIZE` to infer chunk coordinates. The example below renders a 176x176 image (`((radius x 2) + 1) * 16`) where the center chunk is the spawn chunk of the default world.

```
$radius = 5;
$world = $server->getWorldManager()->getDefaultWorld();
$spawn = $world->getSpawnLocation();
$x = $spawn->getFloorX() >> Chunk::COORD_BIT_SIZE;
$z = $spawn->getFloorZ() >> Chunk::COORD_BIT_SIZE;

$render = MapRender::create($plugin);
$image = yield from $render->render($world, $x - $radius, $z - $radius, $x + $radius, $z + $radius);
$output = $plugin->getDataFolder() . DIRECTORY_SEPARATOR . "map-render.png";
imagepng($image, $output);
```

If you are looking to transport data and hence need to export map image as raw PNG bytes, pass an in-memory stream instead of a file path.

```
$resource = fopen("php://memory", "rb+");
try{
	imagepng($image, $resource);
	fseek($resource, 0);
	$bytes = stream_get_contents($resource);
}finally{
	fclose($resource);
}

$output = $plugin->getDataFolder() . DIRECTORY_SEPARATOR . "map-render.png";
file_put_contents($output, $bytes);
```

By default, every block is represented as a 1x1 pixel. This means a map spanning 5x5 chunks has a resolution of 80x80. You can use `imagescale()` to rescale the image. The example below scales the image by 4x (meaning each block is represented using 4x4 pixels).

```
$width = imagesx($image) * 4;
$image = imagescale($image, $width, -1, IMG_NEAREST_NEIGHBOUR);
imagesavealpha($image, true);
imagepng($image, $output);
```

MapRender has default performance settings to ensure server load is kept minimum and at the same time maps render as quickly as possible. If these settings do not suit your server hardware, tweak them by creating a custom MapRender.

```
$parent = MapRender::create($plugin);

// set custom chunk_loads_per_tick, chunk_gens_per_tick
$chunk_loads_per_tick = 4;
$chunk_gens_per_tick = 1;
$render = new MapRender(
	$parent->plugin,
	$parent->palette,
	$parent->chunks_per_tick,
	$chunk_loads_per_tick,
	$chunk_gens_per_tick,
	$parent->min_subchunk_index,
	$parent->max_subchunk_index
);
```

Sample rendered output
----------------------

[](#sample-rendered-output)

 [![](https://private-user-images.githubusercontent.com/15074389/428706795-8ce701d4-a706-4acf-bbc4-048f9e9511ad.svg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MjA3MDksIm5iZiI6MTc3NTUyMDQwOSwicGF0aCI6Ii8xNTA3NDM4OS80Mjg3MDY3OTUtOGNlNzAxZDQtYTcwNi00YWNmLWJiYzQtMDQ4ZjllOTUxMWFkLnN2Zz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA0MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA3VDAwMDY0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAyYzg3MzU1NmZiODE3YjBhZGMyYWYzMDY4M2Q0ZjUyYzQ1ZjI0OWZlZjIwMzNhYzJmNDQ4ODM3ODQxNGNjNDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.YCH-D4mg6aeYke2pMoFU26CyT1g4W-jDFcaoBjyTNus)](https://private-user-images.githubusercontent.com/15074389/428706795-8ce701d4-a706-4acf-bbc4-048f9e9511ad.svg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1MjA3MDksIm5iZiI6MTc3NTUyMDQwOSwicGF0aCI6Ii8xNTA3NDM4OS80Mjg3MDY3OTUtOGNlNzAxZDQtYTcwNi00YWNmLWJiYzQtMDQ4ZjllOTUxMWFkLnN2Zz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA0MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA3VDAwMDY0OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAyYzg3MzU1NmZiODE3YjBhZGMyYWYzMDY4M2Q0ZjUyYzQ1ZjI0OWZlZjIwMzNhYzJmNDQ4ODM3ODQxNGNjNDUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.YCH-D4mg6aeYke2pMoFU26CyT1g4W-jDFcaoBjyTNus)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance46

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

415d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/247134f60bf8c5c7c8a2f06b0ecea431a052614283aac5093b57bde51039e34a?d=identicon)[muqsit](/maintainers/muqsit)

---

Top Contributors

[![Muqsit](https://avatars.githubusercontent.com/u/15074389?v=4)](https://github.com/Muqsit "Muqsit (18 commits)")[![poggit-bot](https://avatars.githubusercontent.com/u/22427965?v=4)](https://github.com/poggit-bot "poggit-bot (1 commits)")

---

Tags

apiasynchronouslibrarymappluginpmmppocketmine-mprender

### Embed Badge

![Health badge](/badges/cosmicpe-maprender/health.svg)

```
[![Health](https://phpackages.com/badges/cosmicpe-maprender/health.svg)](https://phpackages.com/packages/cosmicpe-maprender)
```

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23914.2M16](/packages/hubspot-api-client)[lstrojny/fxmlrpc

Fast and tiny XML/RPC client with bridges for various HTTP clients

1425.4M30](/packages/lstrojny-fxmlrpc)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
