ReadonlydimensionReadonlyidBetaisWhether the entity is sneaking - that is, moving more slowly and more quietly.
This property can't be edited in read-only mode.
Readonly BetalifetimeReadonlylocationOptional Readonly BetascoreboardReadonly BetatargetReadonlytypeBetaType of effect to add to the entity.
Amount of time, in ticks, for the effect to apply. There are 20 ticks per second. Use TicksPerSecond constant to convert between ticks and seconds. The value must be within the range [0, 20000000].
Optionaloptions: EntityEffectOptionsAdditional options for the effect.
Returns nothing if the effect was added or updated successfully. This can throw an error if the duration or amplifier are outside of the valid ranges, or if the effect does not exist.
Adds or updates an effect, like poison, to the entity.
This function can't be called in read-only mode.
const villagerId = 'minecraft:villager_v2<minecraft:ageable_grow_up>';
const villagerLoc: mc.Vector3 = { x: 1, y: 2, z: 1 };
const villager = test.spawn(villagerId, villagerLoc);
const duration = 20;
villager.addEffect(EffectTypes.get('poison'), duration, { amplifier: 1 });
const fox = overworld.spawnEntity('minecraft:fox', {
x: targetLocation.x + 1,
y: targetLocation.y + 2,
z: targetLocation.z + 3,
});
fox.addEffect(mc.MinecraftEffectTypes.Speed, 10, { amplifier: 20 });
log('Created a fox.');
const wolf = overworld.spawnEntity('minecraft:wolf', {
x: targetLocation.x + 4,
y: targetLocation.y + 2,
z: targetLocation.z + 3,
});
wolf.addEffect(mc.MinecraftEffectTypes.Slowness, 10, { amplifier: 20 });
wolf.isSneaking = true;
log('Created a sneaking wolf.', 1);
Content of the tag to add.
Returns true if the tag was added successfully. This can fail if the tag already exists on the entity.
Amount of damage to apply.
Optionaloptions: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptionsAdditional options about the source of damage, which may add additional effects or spur additional behaviors on this entity.
Whether the entity takes any damage. This can return false if the entity is invulnerable or if the damage applied is less than or equal to 0.
Impulse vector.
Applies impulse vector to the current velocity of the entity.
This function can't be called in read-only mode.
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.
Sets the current velocity of the Entity to zero. Note that this method may not have an impact on Players.
This function can't be called in read-only mode.
BetaOptionaluseEffects: booleanWhether to show any visual effects connected to the extinguishing.
Returns whether the entity was on fire.
Extinguishes the fire if the entity is on fire. Note that you can call getComponent('minecraft:onfire') and, if present, the entity is on fire.
This function can't be called in read-only mode.
BetaOptionaloptions: BlockRaycastOptionsAdditional configuration options for the ray cast.
Returns the first intersecting block from the direction that this entity is looking at.
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.
Returns the component if it exists on the entity, otherwise undefined.
Returns all components that are both present on this entity and supported by the API.
BetaThe effect identifier.
Effect object for the specified effect, undefined if the effect is not present, or throws an error if the effect does not exist.
BetaOptionaloptions: EntityRaycastOptionsAdditional configuration options for the ray cast.
Returns a set of entities from the direction that this entity is looking at.
Returns the current location of the head component of this entity.
Returns the current velocity vector of the entity.
Returns the current view direction of the entity.
The identifier of the component (e.g., 'minecraft:rideable') to retrieve. If no namespace prefix is specified, 'minecraft:' is assumed.
Returns true if the specified component is present on this entity.
Returns true if entity can be killed (even if it is already dead), otherwise it returns false.
Kills this entity. The entity will drop loot as normal.
This function can't be called in read-only mode.
BetaThe animation identifier. e.g. animation.creeper.swelling
Optionaloptions: PlayAnimationOptionsAdditional options to control the playback and transitions of the animation.
Cause the entity to play the given animation.
This function can't be called in read-only mode.
BetaThe effect identifier.
Returns true if the effect has been removed, false if the effect is not present, or will throw an error if the effect does not exist.
Removes the specified EffectType on the entity, or returns false if the effect is not present.
This function can't be called in read-only mode.
Content of the tag to remove.
Returns whether the tag existed on the entity.
The command string. Note: This should not include a leading forward slash.
A command result containing whether the command was successful.
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.
BetaLength of time to set the entity on fire.
OptionaluseEffects: booleanWhether side-effects should be applied (e.g. thawing freeze) and other conditions such as rain or fire protection should be taken into consideration.
Whether the entity was set on fire. This can fail if seconds is less than or equal to zero, the entity is wet or the entity is immune to fire.
Sets an entity on fire (if it is not in water or rain). Note that you can call getComponent('minecraft:onfire') and, if present, the entity is on fire.
This function can't be called in read-only mode.
BetaThe x and y rotation of the entity. For most mobs, the x rotation controls the head tilt and the y rotation controls the body rotation.
BetaNew location for the entity.
OptionalteleportOptions: TeleportOptionsOptions regarding the teleport operation.
Teleports the selected entity to a new location
This function can't be called in read-only mode.
BetaName of the entity type event to trigger. If a namespace is not specified, minecraft: is assumed.
Triggers an entity type event. For every entity, a number of events are defined in an entities' definition for key entity behaviors; for example, creepers have a minecraft:start_exploding type event.
This function can't be called in read-only mode.
BetaLocation to teleport the entity to.
OptionalteleportOptions: TeleportOptionsOptions regarding the teleport operation.
Returns whether the teleport succeeded. This can fail if the destination chunk is unloaded or if the teleport would result in intersecting with blocks.
Attempts to try a teleport, but may not complete the teleport operation (for example, if there are blocks at the destination.)
This function can't be called in read-only mode.
Represents the state of an entity (a mob, the player, or other moving objects like minecarts) in the world.