Actions
Change something in the game.
send [Player] the message [text]
Sends the player a chat message. Only that player sees it.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The player to send the message to. |
| 2 | text | The text to send. |
Script: player.sendMessage(text)
teleport [Player] to [Location]
Teleports this entity to the given location. If this entity is riding a vehicle, it will be dismounted prior to teleportation.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The Player to act on. |
| 2 | Location | New location to teleport this entity to |
Script: player.teleport(location)
set health of [Player] to [number]
Sets the entity's health from 0 to getMaxHealth(), where 0 is dead.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The Player to act on. |
| 2 | number | New health represented from 0 to max |
Script: player.setHealth(number)
set food level of [Player] to [number]
Sets the players current food level
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The Player to act on. |
| 2 | number | New food level |
Script: player.setFoodLevel(number)
set [Player] on fire for [number] ticks
Sets the entity's current fire ticks (ticks before the entity stops being on fire).
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The Player to act on. |
| 2 | number | Current ticks remaining |
Script: player.setFireTicks(number)
give [Player] [number] experience
Gives the player the amount of experience specified.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The Player to act on. |
| 2 | number | Exp amount to give |
Script: player.giveExp(number)
kick [Player] with reason [text]
Disconnects the player from the server, showing them the given reason on their disconnect screen.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The player to disconnect. |
| 2 | text | The reason shown to them. |
Script: player.kickPlayer(text)
play sound [Sound] to [Player] at [Location] · volume [number] · pitch [number]
Play a sound for a player at the location. This function will fail silently if Location or Sound are null.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Sound | The sound to play |
| 2 | Player | The Player to act on. |
| 3 | Location | The location to play the sound |
| 4 | number | The volume of the sound |
| 5 | number | The pitch of the sound |
Script: player.playSound(location, sound, number, number)
set game mode of [Player] to [GameMode]
Sets this human's current GameMode
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The Player to act on. |
| 2 | GameMode | New game mode |
Script: player.setGameMode(gameMode)
play sound [Sound] to [Player] at [Location] in category [SoundCategory] · volume [number] · pitch [number]
Play a sound for a player at the location. This function will fail silently if Location or Sound are null.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Sound | The sound to play |
| 2 | Player | The Player to act on. |
| 3 | Location | The location to play the sound |
| 4 | SoundCategory | The category of the sound |
| 5 | number | The volume of the sound |
| 6 | number | The pitch of the sound |
Script: player.playSound(location, sound, soundCategory, number, number)
in [World] spawn [EntityType] at [Location]
Creates a entity at the given Location
| Slot | Takes | What it is for |
|---|---|---|
| 1 | World | The World to act on. |
| 2 | EntityType | The entity to spawn |
| 3 | Location | The location to spawn the entity |
Script: world.spawnEntity(location, entityType)
in [World] show [Particle] particles at [Location] · count [number]
Spawns the particle (the number of times specified by count) at the target location.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | World | The World to act on. |
| 2 | Particle | the particle to spawn |
| 3 | Location | the location to spawn at |
| 4 | number | the number of particles |
Script: world.spawnParticle(particle, location, number)
in [World] strike lightning at [Location]
Strikes lightning at the given Location
| Slot | Takes | What it is for |
|---|---|---|
| 1 | World | The World to act on. |
| 2 | Location | The location to strike lightning |
Script: world.strikeLightning(location)
set block [Block] to [Material]
Sets the type of this block
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Block | The Block to act on. |
| 2 | Material | Material to change this block to |
Script: block.setType(material)
give [Player] [number] of item [Material]
Puts items straight into the player's inventory. Anything that does not fit is discarded rather than dropped on the ground, so check for space first if that matters. An amount below 1 is treated as 1.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The player to give the items to. |
| 2 | number | How many. Amounts over a stack fill several slots. |
| 3 | Material | Which item to give. |
Script: player.giveItem(material, number)
give [Player] effect [PotionEffectType] for [number] ticks at level [number]
Applies a potion effect to the player for a while. Replaces any effect of the same kind already running.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The player to affect. |
| 2 | PotionEffectType | Which effect to apply. |
| 3 | number | How long it lasts, in ticks. 20 ticks is one second. |
| 4 | number | Strength, counting from 0 -- level 0 is what the game shows as I, level 1 as II. |
Script: player.giveEffect(potionEffectType, number, number)
set attribute [Attribute] of [Player] to [number]
Sets one of the player's underlying attributes, such as max health or movement speed. Does nothing at all if that attribute does not apply to players, so a change that appears to have no effect usually means the wrong attribute was chosen.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Attribute | Which attribute to set. |
| 2 | Player | The player to change. |
| 3 | number | The new base value, before any modifiers the game applies on top. |
Script: player.setAttributeBase(attribute, number)
enchant [Player]'s held item with [Enchantment] level [number]
Enchants whatever the player is holding in their main hand. Does nothing if the hand is empty. Vanilla level limits are not enforced, so levels beyond the normal maximum are allowed and the item keeps them.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The player whose held item to enchant. |
| 2 | Enchantment | Which enchantment to add. |
| 3 | number | The level, counting from 1. |
Script: player.enchantHeldItem(enchantment, number)
equip [Player]'s [EquipmentSlot] with [Material]
Puts an item in one of the player's equipment slots, replacing whatever was there. The replaced item is not returned to the player, so it is gone.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The player to equip. |
| 2 | EquipmentSlot | Which slot to fill -- head, chest, legs, feet, or a hand. |
| 3 | Material | The item to put in the slot. |
Script: player.setEquipment(equipmentSlot, material)
send [Player] a [NamedTextColor] message [text]
Sends the player a chat message in one colour. Only that player sees it.
| Slot | Takes | What it is for |
|---|---|---|
| 1 | Player | The player to send the message to. |
| 2 | NamedTextColor | The colour of the message. |
| 3 | text | The text to send. |
Script: player.sendColoredMessage(namedTextColor, text)