Skip to content

MapManager 5.46.0 ​

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

Keeps the maps in use, sends them to the clients that ask for them (MapInfoRequestPacket, sent for maps in the inventory and in item frames) and draws the terrain around players holding a map, a few columns per tick.

Drawing is spread over ticks: each holder gets at most COLUMNS_PER_HOLDER map columns per tick (a full scale 0 map is 128 columns), and all holders together stop when TICK_TIME_BUDGET_NS is used up, so maps never stall the tick.

Constants ​

COLUMNS_PER_HOLDER ​

php
public const COLUMNS_PER_HOLDER = 4

Map columns drawn per tick for each player holding a map (vanilla refreshes 1/16 of the columns per tick)

TICK_TIME_BUDGET_NS ​

php
public const TICK_TIME_BUDGET_NS = 2000000

Time all map drawing may take in one tick

Methods ​

__construct() ​

php
public function __construct(\pocketmine\world\map\MapDataStore $store, ?\pocketmine\world\map\BlockMapColors $colors = null)

allocateMapId() ​

php
public function allocateMapId() : int

Reserves a new map ID, for a map that will be created later (e.g. by a cartography table operation).

createLockedCopy() ​

php
public function createLockedCopy(\pocketmine\world\map\MapData $source, int $newId) : \pocketmine\world\map\MapData

Creates a locked copy of a map (cartography table with a glass pane), which is never drawn on again.

createMap() ​

php
public function createMap(\pocketmine\world\World $world, int $x, int $z, int $scale = 0) : \pocketmine\world\map\MapData

Creates a new map of the given world around the given position, with a new ID.

createPlayerMarker() ​

php
public static function createPlayerMarker(\pocketmine\world\map\MapData $map, float $x, float $z, float $yaw) : ?\pocketmine\network\mcpe\protocol\types\MapDecoration

Returns the marker of a player on a map, or null if the player is too far away to be shown.

createScaledMap() ​

php
public function createScaledMap(\pocketmine\world\map\MapData $source, int $newId) : \pocketmine\world\map\MapData

Creates the zoomed-out version of a map (cartography table or crafting with paper): a blank map with the next scale, on the vanilla grid around the centre of the source map.

getMap() ​

php
public function getMap(int $id) : ?\pocketmine\world\map\MapData

Returns the map with the given ID, loading it if needed, or null if it doesn't exist.

getPixelPosition() ​

php
public static function getPixelPosition(\pocketmine\world\map\MapData $map, float $x, float $z) : array

Returns the map pixel a world position is on (may be outside the map).

getRenderer() ​

php
public function getRenderer() : \pocketmine\world\map\MapRenderer

getStore() ​

php
public function getStore() : \pocketmine\world\map\MapDataStore

handleMapInfoRequest() ​

php
public function handleMapInfoRequest(\pocketmine\player\Player $player, int $mapId) : void

Called when a client asks for the data of a map it doesn't have (map in its inventory or in an item frame).

saveAll() ​

php
public function saveAll() : void

Saves the maps that changed since they were last saved.

saveIfLoaded() ​

php
public static function saveIfLoaded() : void

Saves the changed maps if the manager was used. Called when the server stops.

scheduleInventorySync() ​

php
public function scheduleInventorySync(\pocketmine\player\Player $player) : void

Sends the whole inventory of the player again on the next tick, for changes the client can't predict.

tick() ​

php
public function tick(int $currentTick) : void

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