Readonly
Beta
dimensionDimension that the entity is currently within.
Readonly
idUnique identifier of the player. 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.
Beta
isTrue if the player is currently using a sneaking movement.
Readonly
levelReadonly
Beta
locationCurrent location of the player.
Readonly
nameName of the player.
Beta
nameOptional name tag of the player.
Readonly
Beta
onContains methods for manipulating the on-screen display of a Player.
Readonly
Beta
scoreboardReturns a scoreboard identity that represents this entity.
Beta
selectedManages the selected slot in the player's hotbar.
Optional
Readonly
spawnReadonly
Beta
targetRetrieves or sets an entity that is used as the target of AI-related behaviors, like attacking. For players, which don't use any AI semantics, this property does not do anything.
Readonly
totalReadonly
typeUnique identifier of the type of the entity - for example, 'minecraft:player'.
Readonly
xpBeta
Type of effect to add to the entity.
Amount of time, in ticks, for the effect to apply.
Optional
amplifier: numberOptional amplification of the effect to apply.
Optional
showParticles: booleanBeta
Amount of damage to apply.
Optional
source: EntityDamageSourceAdditional information around the source of damage that can apply to the player.
Beta
Optional
useEffects: booleanWhether to show any visual effects connected to the extinguishing.
Beta
The identifier of the component (e.g., 'minecraft:rideable') to retrieve. If no namespace prefix is specified, 'minecraft:' is assumed. If the component is not present on the entity, undefined is returned.
Beta
Beta
Effect object for the specified effect, or undefined if the effect is not present.
Beta
Optional
options: PlayAnimationOptionsBeta
Identifier of the sound to play.
Optional
soundOptions: SoundOptionsAdditional optional options for the sound.
Command to run. Note that command strings should not start with slash.
For commands that return data, returns a JSON structure with command response values.
Beta
The message to be displayed.
This method can throw if the provided RawMessage is
in an invalid format. For example, if an empty name
string
is provided to score
.
// Displays "Apple or Coal"
let rawMessage = {
translate: "accessibility.list.or.two",
with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
};
player.sendMessage(rawMessage);
Beta
Length of time to set the player on fire.
Optional
useEffects: booleanBeta
Name of the entity type event to trigger. If a namespace is not specified, minecraft: is assumed.
Represents a player within the world.