Skip to content

MapData 5.46.0 ​

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

The pixels and settings of one map. Pixels are kept as 4 bytes per pixel (R, G, B, A), row by row, like the "colors" array of vanilla Bedrock map data and like the pixels of ClientboundMapItemDataPacket.

Saved with the vanilla Bedrock map data tags (mapId, parentMapId, dimension, fullyExplored, mapLocked, scale, unlimitedTracking, height, width, xCenter, zCenter, colors; Minecraft Wiki "Map item format"), plus the name of the PocketMine world it shows.

Constants ​

MAX_SCALE ​

php
public const MAX_SCALE = 4

SIZE ​

php
public const SIZE = 128

Methods ​

__construct() ​

php
public function __construct(int $id, string $worldName, int $centerX, int $centerZ, int $scale = 0, bool $locked = false, int $parentMapId = -1, ?string $pixels = null)

alignCenter() ​

php
public static function alignCenter(int $x, int $z, int $scale) : array

Returns the map centre for a new map made at the given position. Scale 0 maps are centred on the player (as in Bedrock); bigger maps snap to the vanilla grid, where (0, 0) is in the top-left square of the map at that scale.

fromNbt() ​

php
public static function fromNbt(\pocketmine\nbt\tag\CompoundTag $tag) : self

getCenterX() ​

php
public function getCenterX() : int

getCenterZ() ​

php
public function getCenterZ() : int

getId() ​

php
public function getId() : int

getParentMapId() ​

php
public function getParentMapId() : int

Returns the ID of the map this one was made from (zooming out or locking), or -1

getPixel() ​

php
public function getPixel(int $x, int $y) : int

Returns the colour (0xRRGGBB) of a pixel, or -1 if it was never drawn (transparent).

getPixelArea() ​

php
public function getPixelArea(int $x, int $y, int $width, int $height) : string

Returns the pixels of an area: 4 bytes per pixel (R, G, B, A), row by row.

getPixels() ​

php
public function getPixels() : string

Returns all pixels: 4 bytes per pixel (R, G, B, A), row by row.

getScale() ​

php
public function getScale() : int

getWorldName() ​

php
public function getWorldName() : string

hasChanged() ​

php
public function hasChanged() : bool

isLocked() ​

php
public function isLocked() : bool

setChanged() ​

php
public function setChanged(bool $changed) : void

setLocked() ​

php
public function setLocked(bool $locked) : void

setPixel() ​

php
public function setPixel(int $x, int $y, int $color) : bool

Sets an opaque pixel to the given 0xRRGGBB colour. Returns whether it changed.

takeDirtyArea() ​

php
public function takeDirtyArea() : ?array

Returns the area changed since the last call as [x, y, width, height] and forgets it, or null if nothing changed.

toNbt() ​

php
public function toNbt() : \pocketmine\nbt\tag\CompoundTag

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