MapManager 5.46.0
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
public const COLUMNS_PER_HOLDER = 4Map columns drawn per tick for each player holding a map (vanilla refreshes 1/16 of the columns per tick)
TICK_TIME_BUDGET_NS
public const TICK_TIME_BUDGET_NS = 2000000Time all map drawing may take in one tick
Methods
__construct()
public function __construct(\pocketmine\world\map\MapDataStore $store, ?\pocketmine\world\map\BlockMapColors $colors = null)allocateMapId()
public function allocateMapId() : intReserves a new map ID, for a map that will be created later (e.g. by a cartography table operation).
createLockedCopy()
public function createLockedCopy(\pocketmine\world\map\MapData $source, int $newId) : \pocketmine\world\map\MapDataCreates a locked copy of a map (cartography table with a glass pane), which is never drawn on again.
createMap()
public function createMap(\pocketmine\world\World $world, int $x, int $z, int $scale = 0) : \pocketmine\world\map\MapDataCreates a new map of the given world around the given position, with a new ID.
createPlayerMarker()
public static function createPlayerMarker(\pocketmine\world\map\MapData $map, float $x, float $z, float $yaw) : ?\pocketmine\network\mcpe\protocol\types\MapDecorationReturns the marker of a player on a map, or null if the player is too far away to be shown.
createScaledMap()
public function createScaledMap(\pocketmine\world\map\MapData $source, int $newId) : \pocketmine\world\map\MapDataCreates 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()
public function getMap(int $id) : ?\pocketmine\world\map\MapDataReturns the map with the given ID, loading it if needed, or null if it doesn't exist.
getPixelPosition()
public static function getPixelPosition(\pocketmine\world\map\MapData $map, float $x, float $z) : arrayReturns the map pixel a world position is on (may be outside the map).
getRenderer()
public function getRenderer() : \pocketmine\world\map\MapRenderergetStore()
public function getStore() : \pocketmine\world\map\MapDataStorehandleMapInfoRequest()
public function handleMapInfoRequest(\pocketmine\player\Player $player, int $mapId) : voidCalled when a client asks for the data of a map it doesn't have (map in its inventory or in an item frame).
saveAll()
public function saveAll() : voidSaves the maps that changed since they were last saved.
saveIfLoaded()
public static function saveIfLoaded() : voidSaves the changed maps if the manager was used. Called when the server stops.
scheduleInventorySync()
public function scheduleInventorySync(\pocketmine\player\Player $player) : voidSends the whole inventory of the player again on the next tick, for changes the client can't predict.
tick()
public function tick(int $currentTick) : void