Skip to content

Player ​

class · pocketmine\player\Player · source

Extends Human
Implements CommandSender, ChunkListener, IPlayer, NeverSavedWithChunkEntity

Main class that handles networking, recovery, and packet sending to the server part

Constants ​

DEFAULT_FLIGHT_SPEED_MULTIPLIER ​

php
public const DEFAULT_FLIGHT_SPEED_MULTIPLIER = 0.05

TAG_FIRST_PLAYED ​

php
public const TAG_FIRST_PLAYED = "firstPlayed"

TAG_LAST_KNOWN_XUID ​

php
public const TAG_LAST_KNOWN_XUID = "LastKnownXUID"

TAG_LAST_PLAYED ​

php
public const TAG_LAST_PLAYED = "lastPlayed"

TAG_LEVEL ​

php
public const TAG_LEVEL = "Level"

TAG_TIME_SINCE_REST 5.46.0 ​

php
public const TAG_TIME_SINCE_REST = "TimeSinceRest"

TAG_WARDEN_SPAWN_TRACKER 5.46.0 ​

php
public const TAG_WARDEN_SPAWN_TRACKER = "WardenSpawnTracker"

Properties ​

$allowFlight protected ​

php
protected bool $allowFlight

$authenticated protected ​

php
protected bool $authenticated

$autoJump protected ​

php
protected bool $autoJump

$blockBreakHandler protected ​

php
protected ?\pocketmine\player\SurvivalBlockBreakHandler $blockBreakHandler

$blockCollision protected ​

php
protected bool $blockCollision

$blocking 5.46.0 protected ​

php
protected bool $blocking

Whether the raised shield is currently blocking (raised for at least Shield::BLOCK_DELAY_TICKS).

$chunkLoader protected ​

php
protected \pocketmine\world\ChunkLoader $chunkLoader

$chunkSelector protected ​

php
protected \pocketmine\player\ChunkSelector $chunkSelector

$chunkTicker protected ​

php
protected \pocketmine\world\ChunkTicker $chunkTicker

$chunksPerTick protected ​

php
protected int $chunksPerTick

$craftingGrid protected ​

php
protected \pocketmine\inventory\PlayerCraftingInventory $craftingGrid

$creativeInventory protected ​

php
protected \pocketmine\inventory\CreativeInventory $creativeInventory

$currentWindow protected ​

php
protected ?\pocketmine\inventory\Inventory $currentWindow

$cursorInventory protected ​

php
protected \pocketmine\inventory\PlayerCursorInventory $cursorInventory

$displayName protected ​

php
protected string $displayName

$firstPlayed protected ​

php
protected int $firstPlayed

$flightSpeedMultiplier protected ​

php
protected float $flightSpeedMultiplier

$flying protected ​

php
protected bool $flying

$formIdCounter protected ​

php
protected int $formIdCounter

$forms protected ​

php
protected array $forms

$gamemode protected ​

php
protected \pocketmine\player\GameMode $gamemode

$glideTicks 5.46.0 protected ​

php
protected int $glideTicks

Ticks spent gliding since the player started, used for elytra durability loss.

$hiddenPlayers protected ​

php
protected array $hiddenPlayers

$inAirTicks protected ​

php
protected int $inAirTicks

$lastGlideHorizontalSpeed 5.46.0 protected ​

php
protected float $lastGlideHorizontalSpeed

Horizontal distance moved during the previous tick while gliding, used for kinetic (fly into wall) damage.

$lastGlideTickPosition 5.46.0 protected ​

php
protected ?\pocketmine\math\Vector3 $lastGlideTickPosition

$lastMovementProcess protected ​

php
protected ?float $lastMovementProcess

$lastPlayed protected ​

php
protected int $lastPlayed

$lastSpearChargeHitTick 5.46.0 protected ​

php
protected int $lastSpearChargeHitTick

Server tick of the last spear charge hit.

$lineHeight protected ​

php
protected ?int $lineHeight

$loadQueue protected ​

php
protected array $loadQueue

$locale protected ​

php
protected string $locale

$logger protected ​

php
protected \Logger $logger

$messageCounter protected ​

php
protected int $messageCounter

$moveRateLimit protected ​

php
protected float $moveRateLimit

$networkSession protected ​

php
protected ?\pocketmine\network\mcpe\NetworkSession $networkSession

$nextChunkOrderRun protected ​

php
protected int $nextChunkOrderRun

$permanentWindows protected ​

php
protected array $permanentWindows

$playerInfo protected ​

php
protected \pocketmine\player\PlayerInfo $playerInfo

$previousTickPosition 5.46.0 protected ​

php
protected ?\pocketmine\math\Vector3 $previousTickPosition

$shieldRaisedTick 5.46.0 protected ​

php
protected int $shieldRaisedTick

Server tick on which the player raised a shield, or -1 if no shield is raised.

$sleeping protected ​

php
protected ?\pocketmine\math\Vector3 $sleeping

$sneakPressed protected ​

php
protected bool $sneakPressed

$spawnChunkLoadCount protected ​

php
protected int $spawnChunkLoadCount

$spawnThreshold protected ​

php
protected int $spawnThreshold

$spawned ​

php
public bool $spawned

$startAction protected ​

php
protected int $startAction

$stepHeight protected ​

php
protected float $stepHeight

$tickMovement 5.46.0 protected ​

php
protected \pocketmine\math\Vector3 $tickMovement

Distance moved during the last tick (blocks/tick), measured from the positions the client reported.

$timeSinceRest 5.46.0 protected ​

php
protected int $timeSinceRest

Ticks since the player last entered a bed or died (Bedrock "Time Since Last Rest", used by phantom spawning).

$usedChunks protected ​

php
protected array $usedChunks

$usedItemsCooldown protected ​

php
protected array $usedItemsCooldown

$username protected ​

php
protected string $username

$viewDistance protected ​

php
protected int $viewDistance

$xuid protected ​

php
protected string $xuid

Methods ​

__construct() ​

php
public function __construct(\pocketmine\Server $server, \pocketmine\network\mcpe\NetworkSession $session, \pocketmine\player\PlayerInfo $playerInfo, bool $authenticated, \pocketmine\entity\Location $spawnLocation, ?\pocketmine\nbt\tag\CompoundTag $namedtag)

__debugInfo() ​

php
public function __debugInfo() : array

__destruct() ​

php
public function __destruct()

actuallyRespawn() protected ​

php
protected function actuallyRespawn() : void

addDefaultWindows() protected ​

php
protected function addDefaultWindows() : void

addPermanentInventories() protected ​

php
protected function addPermanentInventories(\pocketmine\inventory\Inventory ...$inventories) : void

applyPostDamageEffects() protected ​

php
protected function applyPostDamageEffects(\pocketmine\event\entity\EntityDamageEvent $source) : void

attack() ​

php
public function attack(\pocketmine\event\entity\EntityDamageEvent $source) : void

attackBlock() ​

php
public function attackBlock(\pocketmine\math\Vector3 $pos, int $face) : bool

Performs a left-click (attack) action on the block.

attackEntity() ​

php
public function attackEntity(\pocketmine\entity\Entity $entity) : bool

Attacks the given entity with the currently-held item. TODO: move this up the class hierarchy

breakBlock() ​

php
public function breakBlock(\pocketmine\math\Vector3 $pos) : bool

Breaks the block at the given position using the currently-held item.

broadcastAnimation() ​

php
public function broadcastAnimation(\pocketmine\entity\animation\Animation $animation, ?array $targets = null) : void

broadcastMovement() 5.46.0 protected ​

php
protected function broadcastMovement(bool $teleport = false) : void

Sends this player's movement to viewers, less often to the ones far away (see player.movement-broadcast in pocketmine.yml): with N players in view every movement goes to every viewer every tick, which is N^2 packets. Teleports always go to everyone.

broadcastSound() ​

php
public function broadcastSound(\pocketmine\world\sound\Sound $sound, ?array $targets = null) : void

calculateFallDamage() protected ​

php
protected function calculateFallDamage(float $fallDistance) : float

calculateKineticDamage() 5.46.0 ​

php
public static function calculateKineticDamage(float $previousHorizontalSpeed, float $horizontalSpeed) : float

Damage taken when a gliding entity loses horizontal speed by hitting a wall: (speed lost in blocks/tick) * 10 - 3 (https://minecraft.wiki/w/Elytra, "Kinetic damage").

canBeCollidedWith() ​

php
public function canBeCollidedWith() : bool

canBeMovedByCurrents() ​

php
public function canBeMovedByCurrents() : bool

canBeRenamed() ​

php
public function canBeRenamed() : bool

canBlockWithShield() 5.46.0 protected ​

php
protected function canBlockWithShield(\pocketmine\event\entity\EntityDamageEvent $source) : bool

Returns whether the given damage would be stopped by the player's raised shield: melee and projectile attacks whose source is in front of the player.

canBreathe() ​

php
public function canBreathe() : bool

canCollideWith() ​

php
public function canCollideWith(\pocketmine\entity\Entity $entity) : bool

canEat() ​

php
public function canEat() : bool

canInteract() ​

php
public function canInteract(\pocketmine\math\Vector3 $pos, float $maxDistance, float $maxDiff = \M_SQRT3 / 2) : bool

Returns whether the player can interact with the specified position. This checks distance and direction.

canSaveWithChunk() ​

php
public function canSaveWithChunk() : bool

canSee() ​

php
public function canSee(\pocketmine\player\Player $player) : bool

changeSkin() ​

php
public function changeSkin(\pocketmine\entity\Skin $skin, string $newSkinName, string $oldSkinName) : bool

Called when a player changes their skin. Plugin developers should not use this, use setSkin() and sendSkin() instead.

chat() ​

php
public function chat(string $message) : bool

Sends a chat message as this player. If the message begins with a / (forward-slash) it will be treated as a command.

checkGroundState() protected ​

php
protected function checkGroundState(float $wantedX, float $wantedY, float $wantedZ, float $dx, float $dy, float $dz) : void

checkItemCooldowns() protected ​

php
protected function checkItemCooldowns() : void

checkNearEntities() protected ​

php
protected function checkNearEntities() : void

closeAllForms() ​

php
public function closeAllForms() : void

Closes the current viewing form and forms in queue.

completeChargingHeldItem() 5.46.0 ​

php
public function completeChargingHeldItem() : bool

Called when the client reports that the Chargeable item it is using finished charging (e.g. a crossbow). Stops using the item and loads it if it was charged for long enough.

consumeHeldItem() ​

php
public function consumeHeldItem() : bool

Consumes the currently-held item.

continueBreakBlock() ​

php
public function continueBreakBlock(\pocketmine\math\Vector3 $pos, int $face) : void

destroyCycles() protected ​

php
protected function destroyCycles() : void

disconnect() ​

php
public function disconnect(\pocketmine\lang\Translatable|string $reason, \pocketmine\lang\Translatable|string|null $quitMessage = null, \pocketmine\lang\Translatable|string|null $disconnectScreenMessage = null) : void

Removes the player from the server. This cannot be cancelled. This is used for remote disconnects and for uninterruptible disconnects (for example, when the server shuts down).

Note for plugin developers: Prefer kick() instead of this method. That way other plugins can have a say in whether the player is removed or not.

Note for internals developers: Do not call this from network sessions. It will cause a feedback loop.

doChunkRequests() ​

php
public function doChunkRequests() : void

Ticks the chunk-requesting mechanism.

doFirstSpawn() ​

php
public function doFirstSpawn() : void

Called by the network system when the pre-spawn sequence is completed (e.g. after sending spawn chunks). This fires join events and broadcasts join messages to other online players.

dropItem() ​

php
public function dropItem(\pocketmine\item\Item $item) : void

Drops an item on the ground in front of the player.

emote() ​

php
public function emote(string $emoteId) : void

getAllowFlight() ​

php
public function getAllowFlight() : bool

Returns whether the player is allowed to toggle its flight state.

If false, the player is locked in its current flight mode (flying/not flying), and attempts by the player to enter or exit flight mode will be prevented.

getCraftingGrid() ​

php
public function getCraftingGrid() : \pocketmine\crafting\CraftingGrid

getCreativeInventory() ​

php
public function getCreativeInventory() : \pocketmine\inventory\CreativeInventory

Returns the creative inventory shown to the player. Unless changed by a plugin, this is usually the same for all players.

getCurrentWindow() ​

php
public function getCurrentWindow() : ?\pocketmine\inventory\Inventory

Returns the inventory the player is currently viewing. This might be a chest, furnace, or any other container.

getCursorInventory() ​

php
public function getCursorInventory() : \pocketmine\inventory\PlayerCursorInventory

getDeathPosition() ​

php
public function getDeathPosition() : ?\pocketmine\world\Position

getDisplayName() ​

php
public function getDisplayName() : string

Returns the "friendly" display name of this player to use in the chat.

getDrops() ​

php
public function getDrops() : array

getFirstPlayed() ​

php
public function getFirstPlayed() : ?int

TODO: not sure this should be nullable

getFlightSpeedMultiplier() ​

php
public function getFlightSpeedMultiplier() : float

Returns the player's flight speed multiplier.

Normal flying speed in blocks-per-tick is (multiplier * 10) blocks per tick. When sprint-flying, this is doubled to 20.

If set to zero, the player will not be able to move in the xz plane when flying. Negative values will invert the controls.

getGamemode() ​

php
public function getGamemode() : \pocketmine\player\GameMode

getHeldShield() 5.46.0 ​

php
public function getHeldShield() : ?\pocketmine\item\Shield

Returns the shield the player would raise: the one in the main hand, or else the one in the off hand.

getInAirTicks() ​

php
public function getInAirTicks() : int

getInteractiveTag() 5.46.0 ​

php
public function getInteractiveTag() : string

getItemCooldownExpiry() ​

php
public function getItemCooldownExpiry(\pocketmine\item\Item $item) : int

Returns the server tick on which the player's cooldown period expires for the given item.

getItemUseDuration() ​

php
public function getItemUseDuration() : int

Returns how long the player has been using their currently-held item for. Used for determining arrow shoot force for bows.

getLanguage() ​

php
public function getLanguage() : \pocketmine\lang\Language

Returns the language used to translate messages sent to this player. This is the player's game language if per-player languages are enabled and a translation exists for it, otherwise the server language.

getLastPlayed() ​

php
public function getLastPlayed() : ?int

TODO: not sure this should be nullable

getLeaveMessage() ​

php
public function getLeaveMessage() : \pocketmine\lang\Translatable|string

getLocale() ​

php
public function getLocale() : string

Returns the player's locale, e.g. en_US.

getName() ​

php
public function getName() : string

Gets the username

getNetworkSession() ​

php
public function getNetworkSession() : \pocketmine\network\mcpe\NetworkSession

getPlayerInfo() ​

php
public function getPlayerInfo() : \pocketmine\player\PlayerInfo

Returns an object containing information about the player, such as their username, skin, and misc extra client-specific data.

getSaveData() ​

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

getScreenLineHeight() ​

php
public function getScreenLineHeight() : int

getServer() ​

php
public function getServer() : \pocketmine\Server

getSleepingPosition() 5.46.0 ​

php
public function getSleepingPosition() : ?\pocketmine\math\Vector3

Position of the bed the player is sleeping in, or null when awake.

getSpawn() ​

php
public function getSpawn()

getTickMovement() 5.46.0 ​

php
public function getTickMovement() : \pocketmine\math\Vector3

Returns how far the player moved during the last tick (blocks/tick), as reported by the client.

getTimeSinceRest() 5.46.0 ​

php
public function getTimeSinceRest() : int

Returns the number of ticks since the player last entered a bed or died (Bedrock "Time Since Last Rest"). Phantoms spawn around players who have not rested for 3 days (72000 ticks).

getUniqueId() ​

php
public function getUniqueId() : \Ramsey\Uuid\UuidInterface

Returns the player's UUID. This should be the preferred method to identify a player. It does not change if the player changes their username.

All players will have a UUID, regardless of whether they are logged into Xbox Live or not. However, note that non-XBL players can fake their UUIDs.

getUsedChunkStatus() ​

php
public function getUsedChunkStatus(int $chunkX, int $chunkZ) : ?\pocketmine\player\UsedChunkStatus

Returns a usage status of the given chunk, or null if the player is not using the given chunk.

getUsedChunks() ​

php
public function getUsedChunks() : array

getViewDistance() ​

php
public function getViewDistance() : int

getWardenSpawnTracker() 5.46.0 ​

php
public function getWardenSpawnTracker() : \pocketmine\entity\monster\WardenSpawnTracker

Returns the player's warning level towards wardens, raised by sculk shriekers (see \pocketmine\block\SculkShrieker).

getXpDropAmount() ​

php
public function getXpDropAmount() : int

getXuid() ​

php
public function getXuid() : string

If the player is logged into Xbox Live, returns their Xbox user ID (XUID) as a string. Returns an empty string if the player is not logged into Xbox Live.

handleMovement() ​

php
public function handleMovement(\pocketmine\math\Vector3 $newPos) : void

Attempts to move the player to the given coordinates. Unless you have some particularly specialized logic, you probably want to use teleport() instead of this.

This is used for processing movements sent by the player over network.

hasAutoJump() ​

php
public function hasAutoJump() : bool

hasBlockCollision() ​

php
public function hasBlockCollision() : bool

Returns whether blocks may obstruct the player's movement. If false, the player can move through any block unobstructed.

hasFiniteResources() ​

php
public function hasFiniteResources() : bool

TODO: make this a dynamic ability instead of being hardcoded

hasItemCooldown() ​

php
public function hasItemCooldown(\pocketmine\item\Item $item) : bool

Returns whether the player has a cooldown period left before it can use the given item again.

hasPlayedBefore() ​

php
public function hasPlayedBefore() : bool

hasReceivedChunk() ​

php
public function hasReceivedChunk(int $chunkX, int $chunkZ) : bool

Returns whether the target chunk has been sent to this player.

hasUsableElytra() 5.46.0 ​

php
public function hasUsableElytra() : bool

Returns whether the player wears an elytra in the chest slot that can be used to glide (more than 1 durability left).

hasValidCustomSpawn() ​

php
public function hasValidCustomSpawn() : bool

hidePlayer() ​

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

initEntity() protected ​

php
protected function initEntity(\pocketmine\nbt\tag\CompoundTag $nbt) : void

initHumanData() protected ​

php
protected function initHumanData(\pocketmine\nbt\tag\CompoundTag $nbt) : void

interactBlock() ​

php
public function interactBlock(\pocketmine\math\Vector3 $pos, int $face, \pocketmine\math\Vector3 $clickOffset) : bool

Touches the block at the given position with the currently-held item.

interactEntity() ​

php
public function interactEntity(\pocketmine\entity\Entity $entity, \pocketmine\math\Vector3 $clickPos) : bool

Interacts with the given entity using the currently-held item.

internalSetGameMode() protected ​

php
protected function internalSetGameMode(\pocketmine\player\GameMode $gameMode) : void

isAdventure() ​

php
public function isAdventure(bool $literal = false) : bool

NOTE: Because Adventure and Spectator Mode share some similar behaviour, this method will also return true if the player is in Spectator Mode. Supply the $literal parameter as true to force a literal Adventure Mode check.

isAuthenticated() ​

php
public function isAuthenticated() : bool

isBlocking() 5.46.0 ​

php
public function isBlocking() : bool

Returns whether the player is blocking with a raised shield.

isConnected() ​

php
public function isConnected() : bool

isCreative() ​

php
public function isCreative(bool $literal = false) : bool

NOTE: Because Creative and Spectator Mode share some similar behaviour, this method will also return true if the player is in Spectator Mode. Supply the $literal parameter as true to force a literal Creative Mode check.

isFlying() ​

php
public function isFlying() : bool

isOnline() ​

php
public function isOnline() : bool

isSleeping() ​

php
public function isSleeping() : bool

isSneakPressed() ​

php
public function isSneakPressed() : bool

Returns whether the player is pressing the sneak key. The player may still be sneaking even if this is false due to gameplay mechanics (e.g. releasing sneak while in a 1.5 block high space).

isSpectator() ​

php
public function isSpectator() : bool

isSurvival() ​

php
public function isSurvival(bool $literal = false) : bool

NOTE: Because Survival and Adventure Mode share some similar behaviour, this method will also return true if the player is in Adventure Mode. Supply the $literal parameter as true to force a literal Survival Mode check.

isUsingChunk() ​

php
public function isUsingChunk(int $chunkX, int $chunkZ) : bool

Returns whether the player is using the chunk with the given coordinates, irrespective of whether the chunk has been sent yet.

isUsingItem() ​

php
public function isUsingItem() : bool

Returns whether the player is currently using an item (right-click and hold).

isValidUserName() ​

php
public static function isValidUserName(?string $name) : bool

Validates the given username.

jump() ​

php
public function jump() : void

kick() ​

php
public function kick(\pocketmine\lang\Translatable|string $reason = "", \pocketmine\lang\Translatable|string|null $quitMessage = null, \pocketmine\lang\Translatable|string|null $disconnectScreenMessage = null) : bool

Kicks a player from the server

lowerShield() 5.46.0 ​

php
public function lowerShield() : void

Lowers the shield, if raised; it needs to be raised for Shield::BLOCK_DELAY_TICKS again to block.

missSwing() ​

php
public function missSwing() : void

Performs actions associated with the attack action (left-click) without a target entity. Under normal circumstances, this will just play the no-damage attack sound and the arm-swing animation.

onBlockChanged() ​

php
public function onBlockChanged(\pocketmine\math\Vector3 $block) : void

onChunkChanged() ​

php
public function onChunkChanged(int $chunkX, int $chunkZ, \pocketmine\world\format\Chunk $chunk) : void

onChunkUnloaded() ​

php
public function onChunkUnloaded(int $chunkX, int $chunkZ, \pocketmine\world\format\Chunk $chunk) : void

onDeath() protected ​

php
protected function onDeath() : void

onDeathUpdate() protected ​

php
protected function onDeathUpdate(int $tickDiff) : bool

onDispose() protected ​

php
protected function onDispose() : void

onFormSubmit() ​

php
public function onFormSubmit(int $formId, mixed $responseData) : bool

onShieldBlock() 5.46.0 protected ​

php
protected function onShieldBlock(\pocketmine\event\entity\EntityDamageByEntityEvent $source) : void

Applies the effects of a blocked attack: shield durability, sound, knocking back melee attackers and axes disabling the shield.

onSpearJab() 5.46.0 protected ​

php
protected function onSpearJab(\pocketmine\item\Spear $spear) : void

Called when the player jabs with a spear (attack button, hitting an entity or not): starts the use cooldown shared by all spears and applies Lunge.

onUpdate() ​

php
public function onUpdate(int $currentTick) : bool

openSignEditor() ​

php
public function openSignEditor(\pocketmine\math\Vector3 $position, bool $frontFace = true) : void

Opens the player's sign editor GUI for the sign at the given position.

orderChunks() protected ​

php
protected function orderChunks() : void

Calculates which new chunks this player needs to use, and which currently-used chunks it needs to stop using. This is based on factors including the player's current render radius and current position.

pickBlock() ​

php
public function pickBlock(\pocketmine\math\Vector3 $pos, bool $addTileNBT) : bool

pickEntity() ​

php
public function pickEntity(int $entityId) : bool

processMostRecentMovements() protected ​

php
protected function processMostRecentMovements() : void

Fires movement events and synchronizes player movement, every tick.

releaseHeldItem() ​

php
public function releaseHeldItem() : bool

removeCurrentWindow() ​

php
public function removeCurrentWindow() : void

removePermanentInventories() protected ​

php
protected function removePermanentInventories() : void

removeTitles() ​

php
public function removeTitles() : void

Removes the title from the client's screen.

requestChunks() protected ​

php
protected function requestChunks() : void

Requests chunks from the world to be sent, up to a set limit every tick. This operates on the results of the most recent chunk order.

resetFallDistance() ​

php
public function resetFallDistance() : void

resetItemCooldown() ​

php
public function resetItemCooldown(\pocketmine\item\Item $item, ?int $ticks = null) : void

Resets the player's cooldown time for the given item back to the maximum.

resetTitles() ​

php
public function resetTitles() : void

Resets the title duration settings to defaults and removes any existing titles.

respawn() ​

php
public function respawn() : void

revertMovement() protected ​

php
protected function revertMovement(\pocketmine\entity\Location $from) : void

save() ​

php
public function save() : void

Handles player data saving

selectHotbarSlot() ​

php
public function selectHotbarSlot(int $hotbarSlot) : bool

sendActionBarMessage() ​

php
public function sendActionBarMessage(string $message) : void

Adds small text to the user's screen.

sendData() ​

php
public function sendData(?array $targets, ?array $data = null) : void

sendForm() ​

php
public function sendForm(\pocketmine\form\Form $form) : void

Sends a Form to the player, or queue to send it if a form is already open.

sendJukeboxPopup() ​

php
public function sendJukeboxPopup(\pocketmine\lang\Translatable|string $message) : void

sendMessage() ​

php
public function sendMessage(\pocketmine\lang\Translatable|string $message) : void

Sends a direct chat message to a player

sendPopup() ​

php
public function sendPopup(string $message) : void

Sends a popup message to the player

TODO: add translation type popups

sendPosition() protected ​

php
protected function sendPosition(\pocketmine\math\Vector3 $pos, ?float $yaw = null, ?float $pitch = null, int $mode = \pocketmine\network\mcpe\protocol\MovePlayerPacket::MODE_NORMAL) : void

TODO: remove this

sendSkin() ​

php
public function sendSkin(?array $targets = null) : void

{@inheritdoc}

If null is given, will additionally send the skin to the player itself as well as its viewers.

sendSubTitle() ​

php
public function sendSubTitle(string $subtitle) : void

Sets the subtitle message, without sending a title.

sendTip() ​

php
public function sendTip(string $message) : void

sendTitle() ​

php
public function sendTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1) : void

Adds a title text to the user's screen, with an optional subtitle.

sendToastNotification() ​

php
public function sendToastNotification(string $title, string $body) : void

Sends a toast message to the player, or queue to send it if a toast message is already shown.

setAllowFlight() ​

php
public function setAllowFlight(bool $value) : void

Sets whether the player is allowed to toggle flight mode.

If set to false, the player will be locked in its current flight mode (flying/not flying), and attempts by the player to enter or exit flight mode will be prevented.

Note: Setting this to false DOES NOT change whether the player is currently flying. Use Player::setFlying() for that purpose.

setAutoJump() ​

php
public function setAutoJump(bool $value) : void

setCanSaveWithChunk() ​

php
public function setCanSaveWithChunk(bool $value) : void

setCreativeInventory() ​

php
public function setCreativeInventory(\pocketmine\inventory\CreativeInventory $inventory) : void

To set a custom creative inventory, you need to make a clone of a CreativeInventory instance.

setCurrentWindow() ​

php
public function setCurrentWindow(\pocketmine\inventory\Inventory $inventory) : bool

Opens an inventory window to the player. Returns if it was successful.

setDeathPosition() ​

php
public function setDeathPosition(?\pocketmine\math\Vector3 $pos) : void

setDisplayName() ​

php
public function setDisplayName(string $name) : void

setFlightSpeedMultiplier() ​

php
public function setFlightSpeedMultiplier(float $flightSpeedMultiplier) : void

Sets the player's flight speed multiplier.

Normal flying speed in blocks-per-tick is (multiplier * 10) blocks per tick. When sprint-flying, this is doubled to 20.

If set to zero, the player will not be able to move in the xz plane when flying. Negative values will invert the controls.

Note: Movement speed attribute does not influence flight speed.

setFlying() ​

php
public function setFlying(bool $value) : void

setGamemode() ​

php
public function setGamemode(\pocketmine\player\GameMode $gm) : bool

Sets the provided gamemode.

setGliding() 5.46.0 ​

php
public function setGliding(bool $value = true) : void

setHasBlockCollision() ​

php
public function setHasBlockCollision(bool $value) : void

Sets whether the player's movement may be obstructed by blocks with collision boxes. If set to false, the player can move through any block unobstructed.

Note: Enabling flight mode in conjunction with this is recommended. A non-flying player will simply fall through the ground into the void.

setInteractiveTag() 5.46.0 ​

php
public function setInteractiveTag(string $tag) : void

Sets the text of the interaction button shown to the player (touch controls), e.g. "action.interact.ride.horse", or "" for none. Updated when the client reports the entity it points at (InteractPacket MOUSEOVER).

setMotion() ​

php
public function setMotion(\pocketmine\math\Vector3 $motion) : bool

setPosition() protected ​

php
protected function setPosition(\pocketmine\math\Vector3 $pos) : bool

setScreenLineHeight() ​

php
public function setScreenLineHeight(?int $height) : void

setSneakPressed() ​

php
public function setSneakPressed(bool $sneakPressed) : void

setSpawn() ​

php
public function setSpawn(?\pocketmine\math\Vector3 $pos) : void

Sets the spawnpoint of the player (and the compass direction) to a Vector3, or set it on another world with a Position object

setTimeSinceRest() 5.46.0 ​

php
public function setTimeSinceRest(int $ticks) : void

setTitleDuration() ​

php
public function setTitleDuration(int $fadeIn, int $stay, int $fadeOut) : void

Sets the title duration.

setUsingItem() ​

php
public function setUsingItem(bool $value) : void

setViewDistance() ​

php
public function setViewDistance(int $distance) : void

showPlayer() ​

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

sleepOn() ​

php
public function sleepOn(\pocketmine\math\Vector3 $pos) : bool

spawnEntitiesOnAllChunks() protected ​

php
protected function spawnEntitiesOnAllChunks() : void

spawnEntitiesOnChunk() protected ​

php
protected function spawnEntitiesOnChunk(int $chunkX, int $chunkZ) : void

spawnTo() ​

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

stopBreakBlock() ​

php
public function stopBreakBlock(\pocketmine\math\Vector3 $pos) : void

stopSleep() ​

php
public function stopSleep() : void

syncNetworkData() protected ​

php
protected function syncNetworkData(\pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection $properties) : void

teleport() ​

php
public function teleport(\pocketmine\math\Vector3 $pos, ?float $yaw = null, ?float $pitch = null) : bool

tickGliding() 5.46.0 protected ​

php
protected function tickGliding() : void

Elytra upkeep, run every tick: 1 durability per second of gliding (vanilla), gliding stops when the elytra is removed or worn down to 1 durability, and flying into a wall hurts (kinetic energy).

tickShield() 5.46.0 protected ​

php
protected function tickShield() : void

On Bedrock the shield is raised by sneaking with it in either hand (or by using it from the main hand) and blocks after a short delay.

tickSpearCharge() 5.46.0 protected ​

php
protected function tickSpearCharge(\pocketmine\item\Spear $spear) : void

Spear charge attack, run every tick while the player holds "use" with a spear: once the activation delay has passed, hits the first entity the spear points at, dealing damage proportional to the relative speed.

toggleFlight() ​

php
public function toggleFlight(bool $fly) : bool

toggleGlide() ​

php
public function toggleGlide(bool $glide) : bool

toggleSneak() ​

php
public function toggleSneak(bool $sneak, bool $sneakPressed = true) : bool

toggleSprint() ​

php
public function toggleSprint(bool $sprint) : bool

toggleSwim() ​

php
public function toggleSwim(bool $swim) : bool

transfer() ​

php
public function transfer(string $address, int $port = 19132, \pocketmine\lang\Translatable|string|null $message = null) : bool

Transfers a player to another server.

tryChangeMovement() protected ​

php
protected function tryChangeMovement() : void

unloadChunk() protected ​

php
protected function unloadChunk(int $x, int $z, ?\pocketmine\world\World $world = null) : void

updateFallState() 5.46.0 protected ​

php
protected function updateFallState(float $distanceThisTick, bool $onGround) : ?float

updateMovement() protected ​

php
protected function updateMovement(bool $teleport = false) : void

useHeldItem() ​

php
public function useHeldItem() : bool

Activates the item in hand, for example throwing a projectile.

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