Class: SimulatedPlayer
A simulated player can be used within GameTests to represent how a player moves throughout the world and to support testing of how entities and the environment will react to a player. This type derives much of its structure and methods from the @minecraft/server.Player type. Note that many types of events that may be available for entities more broadly, such as item use events, may not fire in the same capacity for simulated players.
Extends
Player
Constructors
new SimulatedPlayer()
private
new SimulatedPlayer():SimulatedPlayer
Returns
Overrides
minecraftserver.Player.constructor
Properties
camera
readonly
camera:Camera
Remarks
The player's Camera.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.camera
dimension
readonly
dimension:Dimension
Remarks
Dimension that the entity is currently within.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.dimension
fallDistance
Beta
readonly
fallDistance:number
Remarks
The distance an entity has fallen. The value is reset when the entity is teleported. The value is always 1 when gliding with Elytra.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.fallDistance
headRotation
readonly
headRotation:Vector2
Remarks
Rotation of the head across pitch and yaw angles.
Throws
This property can throw when used.
id
readonly
id:string
Remarks
Unique identifier of the entity. This identifier is intended to be consistent across loads of a world instance. No meaning should be inferred from the value and structure of this unique identifier - do not parse or interpret it. This property is accessible even if Entity.isValid is false.
Inherited from
minecraftserver.Player.id
isClimbing
readonly
isClimbing:boolean
Remarks
Whether the entity is touching a climbable block. For example, a player next to a ladder or a spider next to a stone wall.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isClimbing
isEmoting
readonly
isEmoting:boolean
Remarks
If true, the player is currently emoting.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isEmoting
isFalling
readonly
isFalling:boolean
Remarks
Whether the entity has a fall distance greater than 0, or greater than 1 while gliding.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isFalling
isFlying
readonly
isFlying:boolean
Remarks
Whether the player is flying. For example, in Creative or Spectator mode.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isFlying
isGliding
readonly
isGliding:boolean
Remarks
Whether the player is gliding with Elytra.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isGliding
isInWater
readonly
isInWater:boolean
Remarks
Whether any part of the entity is inside a water block.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isInWater
isJumping
readonly
isJumping:boolean
Remarks
Whether the player is jumping. This will remain true while the player is holding the jump action.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isJumping
isOnGround
readonly
isOnGround:boolean
Remarks
Whether the entity is on top of a solid block. This property may behave in unexpected ways. This property will always be true when an Entity is first spawned, and if the Entity has no gravity this property may be incorrect.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isOnGround
isSleeping
readonly
isSleeping:boolean
Remarks
If true, the entity is currently sleeping.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isSleeping
isSneaking
isSneaking:
boolean
Remarks
Whether the entity is sneaking - that is, moving more slowly and more quietly.
This property can't be edited in read-only mode.
Inherited from
minecraftserver.Player.isSneaking
isSprinting
isSprinting:
boolean
Remarks
Returns whether the simulated player is sprinting.
This property can't be edited in read-only mode.
Overrides
minecraftserver.Player.isSprinting
isSwimming
readonly
isSwimming:boolean
Remarks
Whether the entity is in the swimming state. For example, a player using the swim action or a fish in water.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.isSwimming
level
readonly
level:number
Remarks
The current overall level for the player, based on their experience.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.level
lifetimeState
Beta
readonly
lifetimeState:EntityLifetimeState
Remarks
Whether the entity reference that you have is valid or not. For example, an entity may be unloaded if it moves into a chunk that is unloaded, but may be reactivated if the chunk it is within gets reloaded.
Inherited from
minecraftserver.Player.lifetimeState
location
readonly
location:Vector3
Remarks
Current location of the entity.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.location
name
readonly
name:string
Remarks
Name of the player.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.name
nameTag
nameTag:
string
Remarks
Given name of the entity.
This property can't be edited in read-only mode.
Inherited from
minecraftserver.Player.nameTag
onScreenDisplay
readonly
onScreenDisplay:ScreenDisplay
Remarks
Contains methods for manipulating the on-screen display of a Player.
Throws
This property can throw when used.
Inherited from
minecraftserver.Player.onScreenDisplay
scoreboardIdentity?
optional
readonly
scoreboardIdentity:ScoreboardIdentity
Remarks
Returns a scoreboard identity that represents this entity. Will remain valid when the entity is killed.
Inherited from
minecraftserver.Player.scoreboardIdentity
selectedSlot
Beta
selectedSlot:
number
Remarks
Manages the selected slot in the player's hotbar.
This property can't be edited in read-only mode.