Protected
constructorReadonly
Beta
dimensionDimension that the entity is currently within.
This property can throw when used.
Readonly
idUnique 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 can throw when used.
Readonly
Beta
locationCurrent location of the entity.
This property can throw when used.
Readonly
nameName of the player.
This property can throw when used.
Beta
nameGiven name of the entity.
This property can't be edited in read-only mode.
Readonly
typeUnique identifier of the type of the entity - for example, 'minecraft:skeleton'.
This property can throw when used.
Beta
Amount of damage to apply.
Optional
options: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptionsAdditional options about the source of damage, which may add additional effects or spur additional behaviors on this entity.
Applies a set of damage to an entity.
This function can't be called in read-only mode.
This function can throw errors.
Beta
Impulse vector.
Applies impulse vector to the current velocity of the entity.
This function can't be called in read-only mode.
This function can throw errors.
Beta
X direction in horizontal plane.
Z direction in horizontal plane.
Knockback strength for the horizontal vector.
Knockback strength for the vertical vector.
Applies impulse vector to the current velocity of the entity.
This function can't be called in read-only mode.
This function can throw errors.
Beta
Identifier of the sound to play.
Optional
soundOptions: PlayerSoundOptionsAdditional optional options for the sound.
Plays a sound that only this particular player can hear.
This function can't be called in read-only mode.
This function can throw errors.
Beta
This function can't be called in read-only mode.
This function can throw errors.
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.
Runs a particular command asynchronously from the context of this entity. Note that there is a maximum queue of 128 asynchronous commands that can be run in a given tick.
This function can throw errors.
Beta
The message to be displayed.
Sends a message to the player.
This method can throw if the provided RawMessage is
in an invalid format. For example, if an empty name
string
is provided to score
.
nestedTranslation.ts
// Displays "Apple or Coal"
let rawMessage = {
translate: "accessibility.list.or.two",
with: { rawtext: [{ translate: "item.apple.name" }, { translate: "item.coal.name" }] },
};
player.sendMessage(rawMessage);
scoreWildcard.ts
// Displays the player's score for objective "obj". Each player will see their own score.
const rawMessage = { score: { name: "*", objective: "obj" } };
world.sendMessage(rawMessage);
simpleString.ts
// Displays "Hello, world!"
world.sendMessage("Hello, world!");
translation.ts
// Displays "First or Second"
const rawMessage = { translate: "accessibility.list.or.two", with: ["First", "Second"] };
player.sendMessage(rawMessage);
Represents a player within the world.