Documentation

Player extends Human
in package
implements CommandSender, ChunkListener, IPlayer Uses PermissibleDelegateTrait, ChunkListenerNoOpTrait

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

Interfaces, Classes, Traits and Enums

CommandSender
ChunkListener
This interface allows you to listen for events occurring on or in specific chunks. This will receive events for any chunks which it is registered to listen to.
IPlayer

Table of Contents

MOTION_THRESHOLD  = 1.0E-5
DEFAULT_BREATH_TICKS  = 300
STEP_CLIP_MULTIPLIER  = 0.4
MOVE_BACKLOG_SIZE  = 100 * self::MOVES_PER_TICK
MOVES_PER_TICK  = 2
$boundingBox  : AxisAlignedBB
$canCollide  : bool
$deadTicks  : int
$fallDistance  : float
$isCollided  : bool
$isCollidedHorizontally  : bool
$isCollidedVertically  : bool
$keepMovement  : bool
$lastUpdate  : int
$noDamageTicks  : int
$onGround  : bool
$size  : EntitySizeInfo
$spawned  : bool
$ticksLived  : int
$absorptionAttr  : Attribute
$allowFlight  : bool
$alwaysShowNameTag  : bool
$armorInventory  : ArmorInventory
$attackTime  : int
$attributeMap  : AttributeMap
$authenticated  : bool
$autoJump  : bool
$blockBreakHandler  : SurvivalBlockBreakHandler|null
$blocksAround  : array<string|int, Block>|null
$breathing  : bool
$breathTicks  : int
$canClimb  : bool
$canClimbWalls  : bool
$chunkLoader  : PlayerChunkLoader
$chunkSelector  : ChunkSelector
$chunksPerTick  : int
$closed  : bool
$craftingGrid  : PlayerCraftingInventory
$currentWindow  : Inventory|null
$cursorInventory  : PlayerCursorInventory
$displayName  : string
$drag  : float
$effectManager  : EffectManager
$enderInventory  : PlayerEnderInventory
$fireTicks  : int
$firstPlayed  : int
$flying  : bool
$forceMovementUpdate  : bool
$formIdCounter  : int
$forms  : array<string|int, mixed>
$gamemode  : GameMode
$gravity  : float
$gravityEnabled  : bool
$hasSpawned  : array<string|int, Player>
$healthAttr  : Attribute
$hiddenPlayers  : array<string|int, mixed>
$hungerManager  : HungerManager
$id  : int
$immobile  : bool
$inAirTicks  : int
$inventory  : PlayerInventory
$invisible  : bool
$isStatic  : bool
$jumpVelocity  : float
$justCreated  : bool
$knockbackResistanceAttr  : Attribute
$lastDamageCause  : EntityDamageEvent|null
$lastLocation  : Location
$lastMotion  : Vector3
$lastMovementProcess  : float|null
$lastPlayed  : int
$lineHeight  : int|null
$loadQueue  : array<string|int, mixed>
$locale  : string
$location  : Location
$logger  : Logger
$maxBreathTicks  : int
$maxDeadTicks  : int
$messageCounter  : int
$motion  : Vector3
$moveRateLimit  : float
$moveSpeedAttr  : Attribute
$nameTag  : string
$nameTagVisible  : bool
$networkPropertiesDirty  : bool
$networkSession  : NetworkSession|null
$nextChunkOrderRun  : int
$offHandInventory  : PlayerOffHandInventory
$ownerId  : int|null
$permanentWindows  : array<string|int, mixed>
$playerInfo  : PlayerInfo
$scale  : float
$scoreTag  : string
$server  : Server
$silent  : bool
$skin  : Skin
$sleeping  : Vector3|null
$sneaking  : bool
$spawnChunkLoadCount  : int
$spawnThreshold  : int
$sprinting  : bool
$startAction  : int
$stepHeight  : float
$targetId  : int|null
$timings  : TimingsHandler
$usedChunks  : array<string|int, mixed>
$usedItemsCooldown  : array<string|int, mixed>
$username  : string
$uuid  : UuidInterface
$viewDistance  : int
$xpManager  : ExperienceManager
$xpSeed  : int
$xuid  : string
$ySize  : float
$activeChunkGenerationRequests  : array<string|int, mixed>
$closeInFlight  : bool
$entityCount  : int
$health  : float
$lastEmoteTick  : int
$maxHealth  : int
$needsDespawn  : bool
$networkProperties  : EntityMetadataCollection
$perm  : Permissible
$respawnLocked  : bool
$savedWithChunk  : bool
$spawnPosition  : Position|null
__construct()  : mixed
__debugInfo()  : array<string|int, mixed>
__destruct()  : mixed
__toString()  : mixed
addAttachment()  : PermissionAttachment
addMotion()  : void
Adds the given values to the entity's motion vector.
applyDamageModifiers()  : void
Called prior to EntityDamageEvent execution to apply modifications to the event's damage, such as reduction due to effects or armour.
attack()  : void
attackBlock()  : bool
Performs a left-click (attack) action on the block.
attackEntity()  : bool
Attacks the given entity with the currently-held item.
breakBlock()  : bool
Breaks the block at the given position using the currently-held item.
broadcastAnimation()  : void
broadcastSound()  : void
canBeCollidedWith()  : bool
canBeMovedByCurrents()  : bool
canBreathe()  : bool
canClimb()  : bool
Returns whether the entity is able to climb blocks such as ladders or vines.
canClimbWalls()  : bool
Returns whether this entity is climbing a block. By default this is only true if the entity is climbing a ladder or vine or similar block.
canCollideWith()  : bool
canInteract()  : bool
Returns whether the player can interact with the specified position. This checks distance and direction.
canSaveWithChunk()  : bool
canSee()  : bool
changeSkin()  : bool
Called when a player changes their skin.
chat()  : bool
Sends a chat message as this player. If the message begins with a / (forward-slash) it will be treated as a command.
close()  : void
Closes the entity and frees attached references.
consumeHeldItem()  : bool
Consumes the currently-held item.
consumeObject()  : bool
Causes the mob to consume the given Consumable object, applying applicable effects, health bonuses, food bonuses, etc.
continueBreakBlock()  : void
damageArmor()  : void
Damages the worn armour according to the amount of damage given. Each 4 points (rounded down) deals 1 damage point to each armour piece, but never less than 1 total.
despawnFrom()  : void
despawnFromAll()  : void
disconnect()  : void
Removes the player from the server. This cannot be cancelled.
doChunkRequests()  : void
Ticks the chunk-requesting mechanism.
doFirstSpawn()  : void
Called by the network system when the pre-spawn sequence is completed (e.g. after sending spawn chunks).
dropItem()  : void
Drops an item on the ground in front of the player.
emote()  : void
extinguish()  : void
flagForDespawn()  : void
Flags the entity to be removed from the world on the next tick.
getAbsorption()  : float
getAirSupplyTicks()  : int
Returns the number of ticks remaining in the entity's air supply. Note that the entity may survive longer than this amount of time without damage due to enchantments such as Respiration.
getAllowFlight()  : bool
getArmorInventory()  : ArmorInventory
getArmorPoints()  : int
Returns how many armour points this mob has. Armour points provide a percentage reduction to damage.
getAttributeMap()  : AttributeMap
getBoundingBox()  : AxisAlignedBB
getCraftingGrid()  : CraftingGrid
getCurrentWindow()  : Inventory|null
Returns the inventory the player is currently viewing. This might be a chest, furnace, or any other container.
getCursorInventory()  : PlayerCursorInventory
getDirectionPlane()  : Vector2
getDirectionVector()  : Vector3
getDisplayName()  : string
Returns the "friendly" display name of this player to use in the chat.
getDrops()  : array<string|int, Item>
getEffectivePermissions()  : array<string|int, PermissionAttachmentInfo>
getEffects()  : EffectManager
getEnderInventory()  : PlayerEnderInventory
getEyeHeight()  : float
getEyePos()  : Vector3
getFallDistance()  : float
getFireTicks()  : int
getFirstPlayed()  : int|null
TODO: not sure this should be nullable
getGamemode()  : GameMode
getHealth()  : float
getHighestArmorEnchantmentLevel()  : int
Returns the highest level of the specified enchantment on any armour piece that the entity is currently wearing.
getHorizontalFacing()  : int
getHungerManager()  : HungerManager
getId()  : int
getInAirTicks()  : int
getInventory()  : PlayerInventory
Get the object related inventory
getItemCooldownExpiry()  : int
Returns the server tick on which the player's cooldown period expires for the given item.
getItemUseDuration()  : int
Returns how long the player has been using their currently-held item for. Used for determining arrow shoot force for bows.
getJumpVelocity()  : float
Returns the initial upwards velocity of a jumping entity in blocks/tick, including additional velocity due to effects.
getLanguage()  : Language
getLastDamageCause()  : EntityDamageEvent|null
getLastPlayed()  : int|null
TODO: not sure this should be nullable
getLeaveMessage()  : Translatable|string
getLineOfSight()  : array<string|int, Block>
getLocale()  : string
Returns the player's locale, e.g. en_US.
getLocation()  : Location
getMaxAirSupplyTicks()  : int
Returns the maximum amount of air ticks the entity's air supply can contain.
getMaxHealth()  : int
getMotion()  : Vector3
getMovementSpeed()  : float
getName()  : string
Gets the username
getNameTag()  : string
getNetworkProperties()  : EntityMetadataCollection
getNetworkSession()  : NetworkSession
getNetworkTypeId()  : string
getOffHandInventory()  : PlayerOffHandInventory
getOffsetPosition()  : Vector3
getOwningEntity()  : Entity|null
Returns the owning entity, or null if the entity was not found.
getOwningEntityId()  : int|null
Returns the entity ID of the owning entity, or null if the entity doesn't have an owner.
getPermissionRecalculationCallbacks()  : ObjectSet|array<string|int, Closure>
getPlayerInfo()  : PlayerInfo
Returns an object containing information about the player, such as their username, skin, and misc extra client-specific data.
getPosition()  : Position
getSaveData()  : CompoundTag
getScale()  : float
getScoreTag()  : string|null
getScreenLineHeight()  : int
Returns the line height of the command-sender's screen. Used for determining sizes for command output pagination such as in the /help command.
getServer()  : Server
getSkin()  : Skin
Returns a Skin object containing information about this human's skin.
getSpawn()  : Position
getTargetBlock()  : Block|null
getTargetEntity()  : Entity|null
Returns the entity's target entity, or null if not found.
getTargetEntityId()  : int|null
Returns the entity ID of the entity's target, or null if it doesn't have a target.
getUniqueId()  : UuidInterface
Returns the player's UUID. This should be the preferred method to identify a player.
getUsedChunks()  : array<string|int, UsedChunkStatus>
getUsedChunkStatus()  : UsedChunkStatus|null
Returns a usage status of the given chunk, or null if the player is not using the given chunk.
getViewDistance()  : int
getViewers()  : array<string|int, Player>
getWorld()  : World
getXpDropAmount()  : int
Returns the amount of XP this mob will drop on death.
getXpManager()  : ExperienceManager
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()  : 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.
hasAutoJump()  : bool
hasFiniteResources()  : bool
TODO: make this a dynamic ability instead of being hardcoded
hasGravity()  : bool
hasItemCooldown()  : bool
Returns whether the player has a cooldown period left before it can use the given item again.
hasLineOfSight()  : bool
hasMovementUpdate()  : bool
Returns whether the entity needs a movement update on the next tick.
hasPermission()  : bool
hasPlayedBefore()  : bool
hasReceivedChunk()  : bool
Returns whether the target chunk has been sent to this player.
hasValidCustomSpawn()  : bool
heal()  : void
hidePlayer()  : void
interactBlock()  : bool
Touches the block at the given position with the currently-held item.
interactEntity()  : bool
Interacts with the given entity using the currently-held item.
isAdventure()  : 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.
isAlive()  : bool
isAuthenticated()  : bool
isBreathing()  : bool
Returns whether the entity is currently breathing or not. If this is false, the entity's air supply will be used.
isClosed()  : bool
Returns whether the entity has been "closed".
isConnected()  : bool
isCreative()  : 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.
isFireProof()  : bool
isFlaggedForDespawn()  : bool
isFlying()  : bool
isImmobile()  : bool
isInsideOfSolid()  : bool
isInvisible()  : bool
isNameTagAlwaysVisible()  : bool
isNameTagVisible()  : bool
isOnFire()  : bool
isOnGround()  : bool
isOnline()  : bool
isPermissionSet()  : bool
isSilent()  : bool
isSleeping()  : bool
isSneaking()  : bool
isSpectator()  : bool
isSprinting()  : bool
isSurvival()  : 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.
isUnderwater()  : bool
isUsingChunk()  : bool
Returns whether the player is using the chunk with the given coordinates, irrespective of whether the chunk has been sent yet.
isUsingItem()  : bool
Returns whether the player is currently using an item (right-click and hold).
isValidUserName()  : bool
Validates the given username.
jump()  : void
Called when the entity jumps from the ground. This method adds upwards velocity to the entity.
kick()  : bool
Kicks a player from the server
kill()  : void
knockBack()  : void
lookAt()  : void
Changes the entity's yaw and pitch to make it look at the specified Vector3 position. For mobs, this will cause their heads to turn.
nextRuntimeId()  : int
Returns a new runtime entity ID for a new entity.
onAirExpired()  : void
Called when the entity's air supply ticks reaches -20 or lower. The entity will usually take damage at this point and then the supply is reset to 0, so this method will be called roughly every second.
onBlockChanged()  : void
onChunkChanged()  : void
This method will be called when a Chunk is replaced by a new one
onChunkLoaded()  : void
onChunkPopulated()  : void
onChunkUnloaded()  : void
This method will be called when a registered chunk is unloaded
onCollideWithPlayer()  : void
onFormSubmit()  : bool
onInteract()  : bool
Called when interacted or tapped by a Player. Returns whether something happened as a result of the interaction.
onNearbyBlockChange()  : void
onRandomUpdate()  : void
Called when a random update is performed on the chunk the entity is in. This happens when the chunk is within the ticking chunk range of a player (or chunk loader).
onUpdate()  : bool
parseSkinNBT()  : Skin
pickBlock()  : bool
recalculatePermissions()  : array<string|int, mixed>
releaseHeldItem()  : bool
Releases the held item, for example to fire a bow. This should be preceded by a call to useHeldItem().
removeAttachment()  : void
removeCurrentWindow()  : void
removeTitles()  : void
Removes the title from the client's screen.
resetFallDistance()  : void
resetItemCooldown()  : void
Resets the player's cooldown time for the given item back to the maximum.
resetTitles()  : void
Resets the title duration settings to defaults and removes any existing titles.
respawn()  : void
respawnToAll()  : void
save()  : void
Handles player data saving
saveNBT()  : CompoundTag
scheduleUpdate()  : void
selectHotbarSlot()  : bool
sendActionBarMessage()  : void
Adds small text to the user's screen.
sendData()  : void
sendForm()  : void
Sends a Form to the player, or queue to send it if a form is already open.
sendJukeboxPopup()  : void
sendMessage()  : void
Sends a direct chat message to a player
sendPopup()  : void
Sends a popup message to the player
sendSkin()  : void
Sends the human's skin to the specified list of players. If null is given for targets, the skin will be sent to all viewers.
sendSubTitle()  : void
Sets the subtitle message, without sending a title.
sendTip()  : void
sendTitle()  : void
Adds a title text to the user's screen, with an optional subtitle.
sendTranslation()  : void
setAbsorption()  : void
setAirSupplyTicks()  : void
Sets the number of air ticks left in the entity's air supply.
setAllowFlight()  : void
setAutoJump()  : void
setBasePermission()  : void
setBreathing()  : void
Sets whether the entity is currently breathing. If false, it will cause the entity's air supply to be used.
setCanClimb()  : void
Sets whether the entity is able to climb climbable blocks.
setCanClimbWalls()  : void
Sets whether the entity is climbing a block. If true, the entity can climb anything.
setCanSaveWithChunk()  : void
setCurrentWindow()  : bool
Opens an inventory window to the player. Returns if it was successful.
setDisplayName()  : void
setFallDistance()  : void
setFireTicks()  : void
setFlying()  : void
setForceMovementUpdate()  : void
Flags the entity as needing a movement update on the next tick. Setting this forces a movement update even if the entity's motion is zero. Used to trigger movement updates when blocks change near entities.
setGamemode()  : bool
Sets the gamemode, and if needed, kicks the Player.
setHasGravity()  : void
setHealth()  : void
Sets the health of the Entity. This won't send any update to the players
setImmobile()  : void
setInvisible()  : void
setLastDamageCause()  : void
setMaxAirSupplyTicks()  : void
Sets the maximum amount of air ticks the air supply can hold.
setMaxHealth()  : void
setMotion()  : bool
setMovementSpeed()  : void
setNameTag()  : void
setNameTagAlwaysVisible()  : void
setNameTagVisible()  : void
setOnFire()  : void
setOwningEntity()  : void
Sets the owner of the entity. Passing null will remove the current owner.
setRotation()  : void
setScale()  : void
setScoreTag()  : void
setScreenLineHeight()  : void
Sets the line height used for command output pagination for this command sender. `null` will reset it to default.
setSilent()  : void
setSkin()  : void
Sets the human's skin. This will not send any update to viewers, you need to do that manually using {@link sendSkin}.
setSneaking()  : void
setSpawn()  : void
Sets the spawnpoint of the player (and the compass direction) to a Vector3, or set it on another world with a Position object
setSprinting()  : void
setTargetEntity()  : void
Sets the entity's target entity. Passing null will remove the current target.
setTitleDuration()  : void
Sets the title duration.
setUsingItem()  : void
setViewDistance()  : void
showPlayer()  : void
sleepOn()  : bool
spawnTo()  : void
spawnToAll()  : void
stopBreakBlock()  : void
stopSleep()  : void
teleport()  : bool
{@inheritdoc}
toggleFlight()  : bool
toggleSneak()  : bool
toggleSprint()  : bool
transfer()  : bool
Transfers a player to another server.
unsetBasePermission()  : void
useHeldItem()  : bool
Activates the item in hand, for example throwing a projectile.
actuallyRespawn()  : void
addAttributes()  : void
addDefaultWindows()  : void
addPermanentInventories()  : void
applyConsumptionResults()  : void
Applies effects from consuming the object. This shouldn't do any can-consume checks (those are expected to be handled by the caller).
applyDragBeforeGravity()  : bool
applyPostDamageEffects()  : void
Called after EntityDamageEvent execution to apply post-hurt effects, such as reducing absorption or modifying armour durability.
broadcastMotion()  : void
broadcastMovement()  : void
calculateFallDamage()  : float
checkBlockIntersections()  : void
checkGroundState()  : void
checkItemCooldowns()  : void
checkNearEntities()  : void
checkObstruction()  : bool
dealFireDamage()  : void
Called to deal damage to entities when they are on fire.
destroyCycles()  : void
Called when the entity is disposed, after all events have been fired. This should be used to perform destructive circular object references and things which could impact memory usage.
doAirSupplyTick()  : bool
Ticks the entity's air supply, consuming it when underwater and regenerating it when out of water.
doHitAnimation()  : void
doOnFireTick()  : bool
endDeathAnimation()  : void
entityBaseTick()  : bool
getAllNetworkData()  : array<string|int, MetadataProperty>
getBlocksAroundWithEntityInsideActions()  : array<string|int, Block>
getDirtyNetworkData()  : array<string|int, MetadataProperty>
getInitialSizeInfo()  : EntitySizeInfo
initEntity()  : void
initHumanData()  : void
For Human entities which are not players, sets their properties such as nametag, skin and UUID from NBT.
internalSetGameMode()  : void
move()  : void
onDeath()  : void
onDeathUpdate()  : bool
onDispose()  : void
Called when the entity is disposed to clean up things like viewers. This SHOULD NOT destroy internal state, because it may be needed by descendent classes.
onHitGround()  : float|null
Called when a falling entity hits the ground.
orderChunks()  : void
Calculates which new chunks this player needs to use, and which currently-used chunks it needs to stop using.
processMostRecentMovements()  : void
Fires movement events and synchronizes player movement, every tick.
recalculateBoundingBox()  : void
removePermanentInventories()  : void
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.
resetLastMovements()  : void
revertMovement()  : void
sendPosition()  : void
TODO: remove this
sendSpawnPacket()  : void
Called by spawnTo() to send whatever packets needed to spawn the entity to the client.
setPosition()  : bool
setPositionAndRotation()  : bool
spawnEntitiesOnAllChunks()  : void
spawnEntitiesOnChunk()  : void
startDeathAnimation()  : void
syncNetworkData()  : void
tryChangeMovement()  : void
unloadChunk()  : void
updateFallState()  : float|null
updateMovement()  : void
damageItem()  : void
recheckBroadcastPermissions()  : void

Constants

MOTION_THRESHOLD

public mixed MOTION_THRESHOLD = 1.0E-5

DEFAULT_BREATH_TICKS

protected mixed DEFAULT_BREATH_TICKS = 300

STEP_CLIP_MULTIPLIER

protected mixed STEP_CLIP_MULTIPLIER = 0.4

MOVE_BACKLOG_SIZE

private mixed MOVE_BACKLOG_SIZE = 100 * self::MOVES_PER_TICK

MOVES_PER_TICK

private mixed MOVES_PER_TICK = 2

Properties

$canCollide

public bool $canCollide = true

$deadTicks

public int $deadTicks = 0

$fallDistance

public float $fallDistance = 0.0

$isCollided

public bool $isCollided = false

$isCollidedHorizontally

public bool $isCollidedHorizontally = false

$isCollidedVertically

public bool $isCollidedVertically = false

$keepMovement

public bool $keepMovement = false

$lastUpdate

public int $lastUpdate

$noDamageTicks

public int $noDamageTicks = 0

$onGround

public bool $onGround = false

$spawned

public bool $spawned = false

$ticksLived

public int $ticksLived = 0

$allowFlight

protected bool $allowFlight = false

$alwaysShowNameTag

protected bool $alwaysShowNameTag = false

$attackTime

protected int $attackTime = 0

$authenticated

protected bool $authenticated

$autoJump

protected bool $autoJump = true

$blocksAround

protected array<string|int, Block>|null $blocksAround

$breathing

protected bool $breathing = true

$breathTicks

protected int $breathTicks = self::DEFAULT_BREATH_TICKS

$canClimb

protected bool $canClimb = false

$canClimbWalls

protected bool $canClimbWalls = false

$chunksPerTick

protected int $chunksPerTick

$closed

protected bool $closed = false

$displayName

protected string $displayName

$fireTicks

protected int $fireTicks = 0

$firstPlayed

protected int $firstPlayed

$flying

protected bool $flying = false

$forceMovementUpdate

protected bool $forceMovementUpdate = false

$formIdCounter

protected int $formIdCounter = 0

$forms

protected array<string|int, mixed> $forms = []

$gravity

protected float $gravity

$gravityEnabled

protected bool $gravityEnabled = true

$hasSpawned

protected array<string|int, Player> $hasSpawned = []

$hiddenPlayers

protected array<string|int, mixed> $hiddenPlayers = []

map: raw UUID (string) => bool

$immobile

protected bool $immobile = false

$inAirTicks

protected int $inAirTicks = 0

$invisible

protected bool $invisible = false

$isStatic

protected bool $isStatic = false

$jumpVelocity

protected float $jumpVelocity = 0.42

$justCreated

protected bool $justCreated = true

$lastMovementProcess

protected float|null $lastMovementProcess = null

$lastPlayed

protected int $lastPlayed

$lineHeight

protected int|null $lineHeight = null

$loadQueue

protected array<string|int, mixed> $loadQueue = []

chunkHash => dummy

Tags
phpstan-var

array<int, true>

$locale

protected string $locale = "en_US"

$maxBreathTicks

protected int $maxBreathTicks = self::DEFAULT_BREATH_TICKS

$maxDeadTicks

protected int $maxDeadTicks = 25

$messageCounter

protected int $messageCounter = 2

$moveRateLimit

protected float $moveRateLimit = 10 * self::MOVES_PER_TICK

$nameTag

protected string $nameTag = ""

$nameTagVisible

protected bool $nameTagVisible = true

$networkPropertiesDirty

protected bool $networkPropertiesDirty = false

$nextChunkOrderRun

protected int $nextChunkOrderRun = 5

$ownerId

protected int|null $ownerId = null

$permanentWindows

protected array<string|int, mixed> $permanentWindows = []

$scale

protected float $scale = 1.0

$scoreTag

protected string $scoreTag = ""

$silent

protected bool $silent = false

$sneaking

protected bool $sneaking = false

$spawnChunkLoadCount

protected int $spawnChunkLoadCount = 0

$spawnThreshold

protected int $spawnThreshold

$sprinting

protected bool $sprinting = false

$startAction

protected int $startAction = -1

$stepHeight

protected float $stepHeight = 0.6

$targetId

protected int|null $targetId = null

$usedChunks

protected array<string|int, mixed> $usedChunks = []

chunkHash => status

Tags
phpstan-var

array<int, UsedChunkStatus>

$usedItemsCooldown

protected array<string|int, mixed> $usedItemsCooldown = []

ID => ticks map

$username

protected string $username

$viewDistance

protected int $viewDistance = -1

$xpSeed

protected int $xpSeed

$xuid

protected string $xuid = ""

$ySize

protected float $ySize = 0.0

$activeChunkGenerationRequests

private array<string|int, mixed> $activeChunkGenerationRequests = []
Tags
phpstan-var

array<int, true>

$closeInFlight

private bool $closeInFlight = false

$entityCount

private static int $entityCount = 1

$health

private float $health = 20.0

$lastEmoteTick

private int $lastEmoteTick = 0

$maxHealth

private int $maxHealth = 20

$needsDespawn

private bool $needsDespawn = false

$respawnLocked

private bool $respawnLocked = false

$savedWithChunk

private bool $savedWithChunk = true

Methods

__debugInfo()

public __debugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed> —

__destruct()

public __destruct() : mixed
Return values
mixed —

__toString()

public __toString() : mixed
Return values
mixed —

addMotion()

Adds the given values to the entity's motion vector.

public addMotion(float $x, float $y, float $z) : void
Parameters
$x : float
$y : float
$z : float
Return values
void —

applyDamageModifiers()

Called prior to EntityDamageEvent execution to apply modifications to the event's damage, such as reduction due to effects or armour.

public applyDamageModifiers(EntityDamageEvent $source) : void
Parameters
$source : EntityDamageEvent
Return values
void —

attackBlock()

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

public attackBlock(Vector3 $pos, int $face) : bool
Parameters
$pos : Vector3
$face : int
Return values
bool —

if an action took place successfully

attackEntity()

Attacks the given entity with the currently-held item.

public attackEntity(Entity $entity) : bool

TODO: move this up the class hierarchy

Parameters
$entity : Entity
Return values
bool —

if the entity was dealt damage

breakBlock()

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

public breakBlock(Vector3 $pos) : bool
Parameters
$pos : Vector3
Return values
bool —

if the block was successfully broken, false if a rollback needs to take place.

broadcastAnimation()

public broadcastAnimation(Animation $animation[, array<string|int, mixed>|null $targets = null ]) : void
Parameters
$animation : Animation
$targets : array<string|int, mixed>|null = null
Return values
void —

broadcastSound()

public broadcastSound(Sound $sound[, array<string|int, mixed>|null $targets = null ]) : void
Parameters
$sound : Sound
$targets : array<string|int, mixed>|null = null
Return values
void —

canBeCollidedWith()

public canBeCollidedWith() : bool
Return values
bool —

canBeMovedByCurrents()

public canBeMovedByCurrents() : bool
Return values
bool —

canBreathe()

public canBreathe() : bool
Return values
bool —

canClimb()

Returns whether the entity is able to climb blocks such as ladders or vines.

public canClimb() : bool
Return values
bool —

canClimbWalls()

Returns whether this entity is climbing a block. By default this is only true if the entity is climbing a ladder or vine or similar block.

public canClimbWalls() : bool
Return values
bool —

canCollideWith()

public canCollideWith(Entity $entity) : bool
Parameters
$entity : Entity
Return values
bool —

canInteract()

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

public canInteract(Vector3 $pos, float $maxDistance[, float $maxDiff = M_SQRT3 / 2 ]) : bool
Parameters
$pos : Vector3
$maxDistance : float
$maxDiff : float = M_SQRT3 / 2

defaults to half of the 3D diagonal width of a block

Return values
bool —

canSaveWithChunk()

public canSaveWithChunk() : bool
Return values
bool —

canSee()

public canSee(Player $player) : bool
Parameters
$player : Player
Return values
bool —

changeSkin()

Called when a player changes their skin.

public changeSkin(Skin $skin, string $newSkinName, string $oldSkinName) : bool

Plugin developers should not use this, use setSkin() and sendSkin() instead.

Parameters
$skin : Skin
$newSkinName : string
$oldSkinName : string
Return values
bool —

chat()

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

public chat(string $message) : bool
Parameters
$message : string
Return values
bool —

close()

Closes the entity and frees attached references.

public final close() : void

WARNING: Entities are unusable after this has been executed!

Return values
void —

consumeHeldItem()

Consumes the currently-held item.

public consumeHeldItem() : bool
Return values
bool —

if the consumption succeeded.

consumeObject()

Causes the mob to consume the given Consumable object, applying applicable effects, health bonuses, food bonuses, etc.

public consumeObject(Consumable $consumable) : bool
Parameters
$consumable : Consumable
Return values
bool —

continueBreakBlock()

public continueBreakBlock(Vector3 $pos, int $face) : void
Parameters
$pos : Vector3
$face : int
Return values
void —

damageArmor()

Damages the worn armour according to the amount of damage given. Each 4 points (rounded down) deals 1 damage point to each armour piece, but never less than 1 total.

public damageArmor(float $damage) : void
Parameters
$damage : float
Return values
void —

despawnFrom()

public despawnFrom(Player $player[, bool $send = true ]) : void
Parameters
$player : Player
$send : bool = true
Tags
deprecated

WARNING: This function DOES NOT permanently hide the entity from the player. As soon as the entity or player moves, the player will once again be able to see the entity.

Return values
void —

despawnFromAll()

public despawnFromAll() : void
Tags
deprecated

WARNING: This function DOES NOT permanently hide the entity from viewers. As soon as the entity or player moves, viewers will once again be able to see the entity.

Return values
void —

disconnect()

Removes the player from the server. This cannot be cancelled.

public disconnect(string $reason[, Translatable|string|null $quitMessage = null ]) : void

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.

Parameters
$reason : string

Shown to the player, usually this will appear on their disconnect screen.

$quitMessage : Translatable|string|null = null

Message to broadcast to online players (null will use default)

Return values
void —

doChunkRequests()

Ticks the chunk-requesting mechanism.

public doChunkRequests() : void
Return values
void —

doFirstSpawn()

Called by the network system when the pre-spawn sequence is completed (e.g. after sending spawn chunks).

public doFirstSpawn() : void

This fires join events and broadcasts join messages to other online players.

Return values
void —

dropItem()

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

public dropItem(Item $item) : void
Parameters
$item : Item
Return values
void —

emote()

public emote(string $emoteId) : void
Parameters
$emoteId : string
Return values
void —

extinguish()

public extinguish() : void
Return values
void —

flagForDespawn()

Flags the entity to be removed from the world on the next tick.

public flagForDespawn() : void
Return values
void —

getAbsorption()

public getAbsorption() : float
Return values
float —

getAirSupplyTicks()

Returns the number of ticks remaining in the entity's air supply. Note that the entity may survive longer than this amount of time without damage due to enchantments such as Respiration.

public getAirSupplyTicks() : int
Return values
int —

getAllowFlight()

public getAllowFlight() : bool
Return values
bool —

getArmorPoints()

Returns how many armour points this mob has. Armour points provide a percentage reduction to damage.

public getArmorPoints() : int

For mobs which can wear armour, this should return the sum total of the armour points provided by their equipment.

Return values
int —

getCurrentWindow()

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

public getCurrentWindow() : Inventory|null
Return values
Inventory|null —

getDisplayName()

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

public getDisplayName() : string
Return values
string —

getDrops()

public getDrops() : array<string|int, Item>
Return values
array<string|int, Item> —

getEyeHeight()

public getEyeHeight() : float
Return values
float —

getFallDistance()

public getFallDistance() : float
Return values
float —

getFireTicks()

public getFireTicks() : int
Return values
int —

getFirstPlayed()

TODO: not sure this should be nullable

public getFirstPlayed() : int|null
Return values
int|null —

getHealth()

public getHealth() : float
Return values
float —

getHighestArmorEnchantmentLevel()

Returns the highest level of the specified enchantment on any armour piece that the entity is currently wearing.

public getHighestArmorEnchantmentLevel(Enchantment $enchantment) : int
Parameters
$enchantment : Enchantment
Return values
int —

getHorizontalFacing()

public getHorizontalFacing() : int
Return values
int —

getId()

public getId() : int
Return values
int —

getInAirTicks()

public getInAirTicks() : int
Return values
int —

getItemCooldownExpiry()

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

public getItemCooldownExpiry(Item $item) : int
Parameters
$item : Item
Return values
int —

getItemUseDuration()

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

public getItemUseDuration() : int
Return values
int —

getJumpVelocity()

Returns the initial upwards velocity of a jumping entity in blocks/tick, including additional velocity due to effects.

public getJumpVelocity() : float
Return values
float —

getLastPlayed()

TODO: not sure this should be nullable

public getLastPlayed() : int|null
Return values
int|null —

getLineOfSight()

public getLineOfSight(int $maxDistance[, int $maxLength = 0 ][, array<string|int, true> $transparent = [] ]) : array<string|int, Block>
Parameters
$maxDistance : int
$maxLength : int = 0
$transparent : array<string|int, true> = []
Tags
phpstan-param

array<int, true> $transparent

Return values
array<string|int, Block> —

getLocale()

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

public getLocale() : string
Return values
string —

getMaxAirSupplyTicks()

Returns the maximum amount of air ticks the entity's air supply can contain.

public getMaxAirSupplyTicks() : int
Return values
int —

getMaxHealth()

public getMaxHealth() : int
Return values
int —

getMovementSpeed()

public getMovementSpeed() : float
Return values
float —

getName()

Gets the username

public getName() : string
Return values
string —

getNameTag()

public getNameTag() : string
Return values
string —

getNetworkTypeId()

public abstract static getNetworkTypeId() : string
Return values
string —

getOwningEntity()

Returns the owning entity, or null if the entity was not found.

public getOwningEntity() : Entity|null
Return values
Entity|null —

getOwningEntityId()

Returns the entity ID of the owning entity, or null if the entity doesn't have an owner.

public getOwningEntityId() : int|null
Return values
int|null —

getPermissionRecalculationCallbacks()

public getPermissionRecalculationCallbacks() : ObjectSet|array<string|int, Closure>
Tags
phpstan-return

ObjectSet<\Closure(array<string, bool> $changedPermissionsOldValues) : void>

Return values
ObjectSet|array<string|int, Closure> —

getPlayerInfo()

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

public getPlayerInfo() : PlayerInfo
Return values
PlayerInfo —

getScale()

public getScale() : float
Return values
float —

getScoreTag()

public getScoreTag() : string|null
Return values
string|null —

getScreenLineHeight()

Returns the line height of the command-sender's screen. Used for determining sizes for command output pagination such as in the /help command.

public getScreenLineHeight() : int
Return values
int —

getSkin()

Returns a Skin object containing information about this human's skin.

public getSkin() : Skin
Return values
Skin —

getTargetBlock()

public getTargetBlock(int $maxDistance[, array<string|int, true> $transparent = [] ]) : Block|null
Parameters
$maxDistance : int
$transparent : array<string|int, true> = []
Tags
phpstan-param

array<int, true> $transparent

Return values
Block|null —

getTargetEntity()

Returns the entity's target entity, or null if not found.

public getTargetEntity() : Entity|null

This is used for things like hostile mobs attacking entities, and for fishing rods reeling hit entities in.

Return values
Entity|null —

getTargetEntityId()

Returns the entity ID of the entity's target, or null if it doesn't have a target.

public getTargetEntityId() : int|null
Return values
int|null —

getUniqueId()

Returns the player's UUID. This should be the preferred method to identify a player.

public getUniqueId() : UuidInterface

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.

Return values
UuidInterface —

getUsedChunks()

public getUsedChunks() : array<string|int, UsedChunkStatus>
Tags
phpstan-return

array<int, UsedChunkStatus>

Return values
array<string|int, UsedChunkStatus> —

chunkHash => status

getUsedChunkStatus()

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

public getUsedChunkStatus(int $chunkX, int $chunkZ) : UsedChunkStatus|null
Parameters
$chunkX : int
$chunkZ : int
Return values
UsedChunkStatus|null —

getViewDistance()

public getViewDistance() : int
Return values
int —

getViewers()

public getViewers() : array<string|int, Player>
Return values
array<string|int, Player> —

getXpDropAmount()

Returns the amount of XP this mob will drop on death.

public getXpDropAmount() : int
Return values
int —

getXuid()

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.

public getXuid() : string
Return values
string —

handleMovement()

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.

public handleMovement(Vector3 $newPos) : void

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

Parameters
$newPos : Vector3

Coordinates of the player's feet, centered horizontally at the base of their bounding box.

Return values
void —

hasAutoJump()

public hasAutoJump() : bool
Return values
bool —

hasFiniteResources()

TODO: make this a dynamic ability instead of being hardcoded

public hasFiniteResources() : bool
Return values
bool —

hasGravity()

public hasGravity() : bool
Return values
bool —

hasItemCooldown()

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

public hasItemCooldown(Item $item) : bool
Parameters
$item : Item
Return values
bool —

hasLineOfSight()

public hasLineOfSight(Entity $entity) : bool
Parameters
$entity : Entity
Return values
bool —

hasMovementUpdate()

Returns whether the entity needs a movement update on the next tick.

public hasMovementUpdate() : bool
Return values
bool —

hasPlayedBefore()

public hasPlayedBefore() : bool
Return values
bool —

hasReceivedChunk()

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

public hasReceivedChunk(int $chunkX, int $chunkZ) : bool
Parameters
$chunkX : int
$chunkZ : int
Return values
bool —

hasValidCustomSpawn()

public hasValidCustomSpawn() : bool
Return values
bool —

hidePlayer()

public hidePlayer(Player $player) : void
Parameters
$player : Player
Return values
void —

interactBlock()

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

public interactBlock(Vector3 $pos, int $face, Vector3 $clickOffset) : bool
Parameters
$pos : Vector3
$face : int
$clickOffset : Vector3
Return values
bool —

if it did something

interactEntity()

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

public interactEntity(Entity $entity, Vector3 $clickPos) : bool
Parameters
$entity : Entity
$clickPos : Vector3
Return values
bool —

isAdventure()

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.

public isAdventure([bool $literal = false ]) : bool
Parameters
$literal : bool = false

whether a literal check should be performed

Return values
bool —

isAlive()

public isAlive() : bool
Return values
bool —

isAuthenticated()

public isAuthenticated() : bool
Return values
bool —

isBreathing()

Returns whether the entity is currently breathing or not. If this is false, the entity's air supply will be used.

public isBreathing() : bool
Return values
bool —

isClosed()

Returns whether the entity has been "closed".

public isClosed() : bool
Return values
bool —

isConnected()

public isConnected() : bool
Return values
bool —

isCreative()

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.

public isCreative([bool $literal = false ]) : bool
Parameters
$literal : bool = false

whether a literal check should be performed

Return values
bool —

isFireProof()

public isFireProof() : bool
Return values
bool —

isFlaggedForDespawn()

public isFlaggedForDespawn() : bool
Return values
bool —

isFlying()

public isFlying() : bool
Return values
bool —

isImmobile()

public isImmobile() : bool
Return values
bool —

isInsideOfSolid()

public isInsideOfSolid() : bool
Return values
bool —

isInvisible()

public isInvisible() : bool
Return values
bool —

isNameTagAlwaysVisible()

public isNameTagAlwaysVisible() : bool
Return values
bool —

isNameTagVisible()

public isNameTagVisible() : bool
Return values
bool —

isOnFire()

public isOnFire() : bool
Return values
bool —

isOnGround()

public isOnGround() : bool
Return values
bool —

isOnline()

public isOnline() : bool
Return values
bool —

isSilent()

public isSilent() : bool
Return values
bool —

isSleeping()

public isSleeping() : bool
Return values
bool —

isSneaking()

public isSneaking() : bool
Return values
bool —

isSpectator()

public isSpectator() : bool
Return values
bool —

isSprinting()

public isSprinting() : bool
Return values
bool —

isSurvival()

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.

public isSurvival([bool $literal = false ]) : bool
Parameters
$literal : bool = false

whether a literal check should be performed

Return values
bool —

isUnderwater()

public isUnderwater() : bool
Return values
bool —

isUsingChunk()

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

public isUsingChunk(int $chunkX, int $chunkZ) : bool
Parameters
$chunkX : int
$chunkZ : int
Return values
bool —

isUsingItem()

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

public isUsingItem() : bool
Return values
bool —

isValidUserName()

Validates the given username.

public static isValidUserName(string|null $name) : bool
Parameters
$name : string|null
Return values
bool —

jump()

Called when the entity jumps from the ground. This method adds upwards velocity to the entity.

public jump() : void
Return values
void —

kick()

Kicks a player from the server

public kick([string $reason = "" ][, Translatable|string|null $quitMessage = null ]) : bool
Parameters
$reason : string = ""
$quitMessage : Translatable|string|null = null
Return values
bool —

kill()

public kill() : void
Return values
void —

knockBack()

public knockBack(float $x, float $z[, float $force = 0.4 ][, float|null $verticalLimit = 0.4 ]) : void
Parameters
$x : float
$z : float
$force : float = 0.4
$verticalLimit : float|null = 0.4
Return values
void —

lookAt()

Changes the entity's yaw and pitch to make it look at the specified Vector3 position. For mobs, this will cause their heads to turn.

public lookAt(Vector3 $target) : void
Parameters
$target : Vector3
Return values
void —

nextRuntimeId()

Returns a new runtime entity ID for a new entity.

public static nextRuntimeId() : int
Return values
int —

onAirExpired()

Called when the entity's air supply ticks reaches -20 or lower. The entity will usually take damage at this point and then the supply is reset to 0, so this method will be called roughly every second.

public onAirExpired() : void
Return values
void —

onChunkChanged()

This method will be called when a Chunk is replaced by a new one

public onChunkChanged(int $chunkX, int $chunkZ, Chunk $chunk) : void
Parameters
$chunkX : int
$chunkZ : int
$chunk : Chunk
Return values
void —

onChunkLoaded()

public onChunkLoaded(int $chunkX, int $chunkZ, Chunk $chunk) : void
Parameters
$chunkX : int
$chunkZ : int
$chunk : Chunk
Return values
void —

onChunkPopulated()

public onChunkPopulated(int $chunkX, int $chunkZ, Chunk $chunk) : void
Parameters
$chunkX : int
$chunkZ : int
$chunk : Chunk
Return values
void —

onChunkUnloaded()

This method will be called when a registered chunk is unloaded

public onChunkUnloaded(int $chunkX, int $chunkZ, Chunk $chunk) : void
Parameters
$chunkX : int
$chunkZ : int
$chunk : Chunk
Return values
void —

onCollideWithPlayer()

public onCollideWithPlayer(Player $player) : void
Parameters
$player : Player
Return values
void —

onFormSubmit()

public onFormSubmit(int $formId, mixed $responseData) : bool
Parameters
$formId : int
$responseData : mixed
Return values
bool —

onInteract()

Called when interacted or tapped by a Player. Returns whether something happened as a result of the interaction.

public onInteract(Player $player, Vector3 $clickPos) : bool
Parameters
$player : Player
$clickPos : Vector3
Return values
bool —

onNearbyBlockChange()

public onNearbyBlockChange() : void
Return values
void —

onRandomUpdate()

Called when a random update is performed on the chunk the entity is in. This happens when the chunk is within the ticking chunk range of a player (or chunk loader).

public onRandomUpdate() : void
Return values
void —

onUpdate()

public onUpdate(int $currentTick) : bool
Parameters
$currentTick : int
Return values
bool —

pickBlock()

public pickBlock(Vector3 $pos, bool $addTileNBT) : bool
Parameters
$pos : Vector3
$addTileNBT : bool
Return values
bool —

recalculatePermissions()

public recalculatePermissions() : array<string|int, mixed>
Return values
array<string|int, mixed> —

releaseHeldItem()

Releases the held item, for example to fire a bow. This should be preceded by a call to useHeldItem().

public releaseHeldItem() : bool
Return values
bool —

if it did something.

removeCurrentWindow()

public removeCurrentWindow() : void
Return values
void —

removeTitles()

Removes the title from the client's screen.

public removeTitles() : void
Return values
void —

resetFallDistance()

public resetFallDistance() : void
Return values
void —

resetItemCooldown()

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

public resetItemCooldown(Item $item[, int|null $ticks = null ]) : void
Parameters
$item : Item
$ticks : int|null = null
Return values
void —

resetTitles()

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

public resetTitles() : void
Return values
void —

respawn()

public respawn() : void
Return values
void —

respawnToAll()

public respawnToAll() : void
Return values
void —

save()

Handles player data saving

public save() : void
Return values
void —

scheduleUpdate()

public final scheduleUpdate() : void
Return values
void —

selectHotbarSlot()

public selectHotbarSlot(int $hotbarSlot) : bool
Parameters
$hotbarSlot : int
Return values
bool —

sendActionBarMessage()

Adds small text to the user's screen.

public sendActionBarMessage(string $message) : void
Parameters
$message : string
Return values
void —

sendData()

public sendData(array<string|int, mixed>|null $targets[, array<string|int, mixed>|null $data = null ]) : void
Parameters
$targets : array<string|int, mixed>|null
$data : array<string|int, mixed>|null = null
Return values
void —

sendForm()

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

public sendForm(Form $form) : void
Parameters
$form : Form
Tags
throws
InvalidArgumentException
Return values
void —

sendJukeboxPopup()

public sendJukeboxPopup(string $key, array<string|int, string> $args) : void
Parameters
$key : string
$args : array<string|int, string>
Return values
void —

sendMessage()

Sends a direct chat message to a player

public sendMessage(Translatable|string $message) : void
Parameters
$message : Translatable|string
Return values
void —

sendPopup()

Sends a popup message to the player

public sendPopup(string $message) : void

TODO: add translation type popups

Parameters
$message : string
Return values
void —

sendSkin()

Sends the human's skin to the specified list of players. If null is given for targets, the skin will be sent to all viewers.

public sendSkin([array<string|int, mixed>|null $targets = null ]) : void

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

Parameters
$targets : array<string|int, mixed>|null = null
Return values
void —

sendSubTitle()

Sets the subtitle message, without sending a title.

public sendSubTitle(string $subtitle) : void
Parameters
$subtitle : string
Return values
void —

sendTip()

public sendTip(string $message) : void
Parameters
$message : string
Return values
void —

sendTitle()

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

public sendTitle(string $title[, string $subtitle = "" ][, int $fadeIn = -1 ][, int $stay = -1 ][, int $fadeOut = -1 ]) : void
Parameters
$title : string
$subtitle : string = ""
$fadeIn : int = -1

Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used.

$stay : int = -1

Duration in ticks to stay on screen for

$fadeOut : int = -1

Duration in ticks for fade-out.

Return values
void —

sendTranslation()

public sendTranslation(string $message[, array<string|int, string>|array<string|int, Translatable> $parameters = [] ]) : void
Parameters
$message : string
$parameters : array<string|int, string>|array<string|int, Translatable> = []
Return values
void —

setAbsorption()

public setAbsorption(float $absorption) : void
Parameters
$absorption : float
Return values
void —

setAirSupplyTicks()

Sets the number of air ticks left in the entity's air supply.

public setAirSupplyTicks(int $ticks) : void
Parameters
$ticks : int
Return values
void —

setAllowFlight()

public setAllowFlight(bool $value) : void
Parameters
$value : bool
Return values
void —

setAutoJump()

public setAutoJump(bool $value) : void
Parameters
$value : bool
Return values
void —

setBreathing()

Sets whether the entity is currently breathing. If false, it will cause the entity's air supply to be used.

public setBreathing([bool $value = true ]) : void

For players, this also shows the oxygen bar.

Parameters
$value : bool = true
Return values
void —

setCanClimb()

Sets whether the entity is able to climb climbable blocks.

public setCanClimb([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setCanClimbWalls()

Sets whether the entity is climbing a block. If true, the entity can climb anything.

public setCanClimbWalls([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setCanSaveWithChunk()

public setCanSaveWithChunk(bool $value) : void
Parameters
$value : bool
Return values
void —

setCurrentWindow()

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

public setCurrentWindow(Inventory $inventory) : bool
Parameters
$inventory : Inventory
Return values
bool —

setDisplayName()

public setDisplayName(string $name) : void
Parameters
$name : string
Return values
void —

setFallDistance()

public setFallDistance(float $fallDistance) : void
Parameters
$fallDistance : float
Return values
void —

setFireTicks()

public setFireTicks(int $fireTicks) : void
Parameters
$fireTicks : int
Tags
throws
InvalidArgumentException
Return values
void —

setFlying()

public setFlying(bool $value) : void
Parameters
$value : bool
Return values
void —

setForceMovementUpdate()

Flags the entity as needing a movement update on the next tick. Setting this forces a movement update even if the entity's motion is zero. Used to trigger movement updates when blocks change near entities.

public final setForceMovementUpdate([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setGamemode()

Sets the gamemode, and if needed, kicks the Player.

public setGamemode(GameMode $gm) : bool
Parameters
$gm : GameMode
Return values
bool —

setHasGravity()

public setHasGravity([bool $v = true ]) : void
Parameters
$v : bool = true
Return values
void —

setHealth()

Sets the health of the Entity. This won't send any update to the players

public setHealth(float $amount) : void
Parameters
$amount : float
Return values
void —

setImmobile()

public setImmobile([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setInvisible()

public setInvisible([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setMaxAirSupplyTicks()

Sets the maximum amount of air ticks the air supply can hold.

public setMaxAirSupplyTicks(int $ticks) : void
Parameters
$ticks : int
Return values
void —

setMaxHealth()

public setMaxHealth(int $amount) : void
Parameters
$amount : int
Return values
void —

setMotion()

public setMotion(Vector3 $motion) : bool
Parameters
$motion : Vector3
Return values
bool —

setMovementSpeed()

public setMovementSpeed(float $v[, bool $fit = false ]) : void
Parameters
$v : float
$fit : bool = false
Return values
void —

setNameTag()

public setNameTag(string $name) : void
Parameters
$name : string
Return values
void —

setNameTagAlwaysVisible()

public setNameTagAlwaysVisible([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setNameTagVisible()

public setNameTagVisible([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setOnFire()

public setOnFire(int $seconds) : void
Parameters
$seconds : int
Return values
void —

setOwningEntity()

Sets the owner of the entity. Passing null will remove the current owner.

public setOwningEntity(Entity|null $owner) : void
Parameters
$owner : Entity|null
Tags
throws
InvalidArgumentException

if the supplied entity is not valid

Return values
void —

setRotation()

public setRotation(float $yaw, float $pitch) : void
Parameters
$yaw : float
$pitch : float
Return values
void —

setScale()

public setScale(float $value) : void
Parameters
$value : float
Return values
void —

setScoreTag()

public setScoreTag(string $score) : void
Parameters
$score : string
Return values
void —

setScreenLineHeight()

Sets the line height used for command output pagination for this command sender. `null` will reset it to default.

public setScreenLineHeight(int|null $height) : void
Parameters
$height : int|null
Return values
void —

setSilent()

public setSilent([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setSkin()

Sets the human's skin. This will not send any update to viewers, you need to do that manually using {@link sendSkin}.

public setSkin(Skin $skin) : void
Parameters
$skin : Skin
Return values
void —

setSneaking()

public setSneaking([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setSpawn()

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

public setSpawn(Vector3|Position|null $pos) : void
Parameters
$pos : Vector3|Position|null
Return values
void —

setSprinting()

public setSprinting([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void —

setTargetEntity()

Sets the entity's target entity. Passing null will remove the current target.

public setTargetEntity(Entity|null $target) : void
Parameters
$target : Entity|null
Tags
throws
InvalidArgumentException

if the target entity is not valid

Return values
void —

setTitleDuration()

Sets the title duration.

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

Title fade-in time in ticks.

$stay : int

Title stay time in ticks.

$fadeOut : int

Title fade-out time in ticks.

Return values
void —

setUsingItem()

public setUsingItem(bool $value) : void
Parameters
$value : bool
Return values
void —

setViewDistance()

public setViewDistance(int $distance) : void
Parameters
$distance : int
Return values
void —

showPlayer()

public showPlayer(Player $player) : void
Parameters
$player : Player
Return values
void —

spawnTo()

public spawnTo(Player $player) : void
Parameters
$player : Player
Return values
void —

spawnToAll()

public spawnToAll() : void
Return values
void —

stopBreakBlock()

public stopBreakBlock(Vector3 $pos) : void
Parameters
$pos : Vector3
Return values
void —

stopSleep()

public stopSleep() : void
Return values
void —

teleport()

{@inheritdoc}

public teleport(Vector3 $pos[, float|null $yaw = null ][, float|null $pitch = null ]) : bool
Parameters
$pos : Vector3
$yaw : float|null = null
$pitch : float|null = null
Return values
bool —

toggleFlight()

public toggleFlight(bool $fly) : bool
Parameters
$fly : bool
Return values
bool —

toggleSneak()

public toggleSneak(bool $sneak) : bool
Parameters
$sneak : bool
Return values
bool —

toggleSprint()

public toggleSprint(bool $sprint) : bool
Parameters
$sprint : bool
Return values
bool —

transfer()

Transfers a player to another server.

public transfer(string $address[, int $port = 19132 ][, string $message = "transfer" ]) : bool
Parameters
$address : string

The IP address or hostname of the destination server

$port : int = 19132

The destination port, defaults to 19132

$message : string = "transfer"

Message to show in the console when closing the player

Return values
bool —

if transfer was successful.

useHeldItem()

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

public useHeldItem() : bool
Return values
bool —

if it did something

actuallyRespawn()

protected actuallyRespawn() : void
Return values
void —

addAttributes()

protected addAttributes() : void
Return values
void —

addDefaultWindows()

protected addDefaultWindows() : void
Return values
void —

addPermanentInventories()

protected addPermanentInventories(Inventory ...$inventories) : void
Parameters
$inventories : Inventory
Return values
void —

applyConsumptionResults()

Applies effects from consuming the object. This shouldn't do any can-consume checks (those are expected to be handled by the caller).

protected applyConsumptionResults(Consumable $consumable) : void
Parameters
$consumable : Consumable
Return values
void —

applyDragBeforeGravity()

protected applyDragBeforeGravity() : bool
Return values
bool —

applyPostDamageEffects()

Called after EntityDamageEvent execution to apply post-hurt effects, such as reducing absorption or modifying armour durability.

protected applyPostDamageEffects(EntityDamageEvent $source) : void

This will not be called by damage sources causing death.

Parameters
$source : EntityDamageEvent
Return values
void —

broadcastMotion()

protected broadcastMotion() : void
Return values
void —

broadcastMovement()

protected broadcastMovement([bool $teleport = false ]) : void
Parameters
$teleport : bool = false
Return values
void —

calculateFallDamage()

protected calculateFallDamage(float $fallDistance) : float
Parameters
$fallDistance : float
Return values
float —

checkBlockIntersections()

protected checkBlockIntersections() : void
Return values
void —

checkGroundState()

protected checkGroundState(float $wantedX, float $wantedY, float $wantedZ, float $dx, float $dy, float $dz) : void
Parameters
$wantedX : float
$wantedY : float
$wantedZ : float
$dx : float
$dy : float
$dz : float
Return values
void —

checkItemCooldowns()

protected checkItemCooldowns() : void
Return values
void —

checkNearEntities()

protected checkNearEntities() : void
Return values
void —

checkObstruction()

protected checkObstruction(float $x, float $y, float $z) : bool
Parameters
$x : float
$y : float
$z : float
Return values
bool —

dealFireDamage()

Called to deal damage to entities when they are on fire.

protected dealFireDamage() : void
Return values
void —

destroyCycles()

Called when the entity is disposed, after all events have been fired. This should be used to perform destructive circular object references and things which could impact memory usage.

protected destroyCycles() : void

It is expected that the object is unusable after this is called.

Return values
void —

doAirSupplyTick()

Ticks the entity's air supply, consuming it when underwater and regenerating it when out of water.

protected doAirSupplyTick(int $tickDiff) : bool
Parameters
$tickDiff : int
Return values
bool —

doHitAnimation()

protected doHitAnimation() : void
Return values
void —

doOnFireTick()

protected doOnFireTick([int $tickDiff = 1 ]) : bool
Parameters
$tickDiff : int = 1
Return values
bool —

endDeathAnimation()

protected endDeathAnimation() : void
Return values
void —

entityBaseTick()

protected entityBaseTick([int $tickDiff = 1 ]) : bool
Parameters
$tickDiff : int = 1
Return values
bool —

getAllNetworkData()

protected final getAllNetworkData() : array<string|int, MetadataProperty>
Tags
phpstan-return

array<int, MetadataProperty>

Return values
array<string|int, MetadataProperty> —

getBlocksAroundWithEntityInsideActions()

protected getBlocksAroundWithEntityInsideActions() : array<string|int, Block>
Return values
array<string|int, Block> —

getDirtyNetworkData()

protected final getDirtyNetworkData() : array<string|int, MetadataProperty>
Tags
phpstan-return

array<int, MetadataProperty>

Return values
array<string|int, MetadataProperty> —

initHumanData()

For Human entities which are not players, sets their properties such as nametag, skin and UUID from NBT.

protected initHumanData(CompoundTag $nbt) : void
Parameters
$nbt : CompoundTag
Return values
void —

internalSetGameMode()

protected internalSetGameMode(GameMode $gameMode) : void
Parameters
$gameMode : GameMode
Return values
void —

move()

protected move(float $dx, float $dy, float $dz) : void
Parameters
$dx : float
$dy : float
$dz : float
Return values
void —

onDeath()

protected onDeath() : void
Return values
void —

onDeathUpdate()

protected onDeathUpdate(int $tickDiff) : bool
Parameters
$tickDiff : int
Return values
bool —

onDispose()

Called when the entity is disposed to clean up things like viewers. This SHOULD NOT destroy internal state, because it may be needed by descendent classes.

protected onDispose() : void
Return values
void —

onHitGround()

Called when a falling entity hits the ground.

protected onHitGround() : float|null
Return values
float|null —

orderChunks()

Calculates which new chunks this player needs to use, and which currently-used chunks it needs to stop using.

protected orderChunks() : void

This is based on factors including the player's current render radius and current position.

Return values
void —

processMostRecentMovements()

Fires movement events and synchronizes player movement, every tick.

protected processMostRecentMovements() : void
Return values
void —

recalculateBoundingBox()

protected recalculateBoundingBox() : void
Return values
void —

removePermanentInventories()

protected removePermanentInventories() : void
Return values
void —

requestChunks()

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.

protected requestChunks() : void
Return values
void —

resetLastMovements()

protected resetLastMovements() : void
Return values
void —

revertMovement()

protected revertMovement(Location $from) : void
Parameters
$from : Location
Return values
void —

sendPosition()

TODO: remove this

protected sendPosition(Vector3 $pos[, float|null $yaw = null ][, float|null $pitch = null ][, int $mode = MovePlayerPacket::MODE_NORMAL ]) : void
Parameters
$pos : Vector3
$yaw : float|null = null
$pitch : float|null = null
$mode : int = MovePlayerPacket::MODE_NORMAL
Return values
void —

sendSpawnPacket()

Called by spawnTo() to send whatever packets needed to spawn the entity to the client.

protected sendSpawnPacket(Player $player) : void
Parameters
$player : Player
Return values
void —

setPosition()

protected setPosition(Vector3 $pos) : bool
Parameters
$pos : Vector3
Return values
bool —

setPositionAndRotation()

protected setPositionAndRotation(Vector3 $pos, float $yaw, float $pitch) : bool
Parameters
$pos : Vector3
$yaw : float
$pitch : float
Return values
bool —

spawnEntitiesOnAllChunks()

protected spawnEntitiesOnAllChunks() : void
Return values
void —

spawnEntitiesOnChunk()

protected spawnEntitiesOnChunk(int $chunkX, int $chunkZ) : void
Parameters
$chunkX : int
$chunkZ : int
Return values
void —

startDeathAnimation()

protected startDeathAnimation() : void
Return values
void —

tryChangeMovement()

protected tryChangeMovement() : void
Return values
void —

unloadChunk()

protected unloadChunk(int $x, int $z[, World|null $world = null ]) : void
Parameters
$x : int
$z : int
$world : World|null = null
Return values
void —

updateFallState()

protected updateFallState(float $distanceThisTick, bool $onGround) : float|null
Parameters
$distanceThisTick : float
$onGround : bool
Return values
float|null —

updateMovement()

protected updateMovement([bool $teleport = false ]) : void
Parameters
$teleport : bool = false
Return values
void —

damageItem()

private damageItem(Durable $item, int $durabilityRemoved) : void
Parameters
$item : Durable
$durabilityRemoved : int
Return values
void —

recheckBroadcastPermissions()

private recheckBroadcastPermissions() : void
Return values
void —

Search results