Commands/playsound

From Minecraft Wiki
Jump to: navigation, search
playsound
Restrictions

Operator

First introduced

Java Edition 1.6.1 (1.6.1-pre)
PE 1.0.5 (Pocket Edition alpha 1.0.5.0)

Plays a specified sound at a player, in a location, and in a specific volume and pitch.

Syntax[edit]

  • Java Edition
playsound <sound> <source> <targets> [<pos>] [<volume>] [<pitch>] [<minVolume>]
  • Bedrock Edition
playsound <sound: string> [player: target] [position: x y z] [volume: float] [pitch: float] [minimumVolume: float]

Arguments[edit]

JE<sound>: resource_location
BE: sound: string: basic_string

Specifies the sound to play.
In Bedrock Edition, it must be either a single word (no spaces) or a quoted string. Can be a sound event defined in sound_definitions.json (for example, mob.pig.say).
In Java Edition, must be a namespaced ID. Can be a sound event defined in sounds.json (for example, entity.pig.ambient).
A sound event may be affiliated with multiple sounds, and the sound that is actually produced is chosen at random from them, modified by their "weight", just as the game normally would. For example, the entity.pig.ambient sound event plays one of several pig sounds at random, because the event has multiple sounds associated with it.
Resource packs may add their own events to sounds.json; the command successfully plays these. File names are not used by this command; it strictly uses the events defined in sounds.json (which may not even be similar to the original file names and paths), and thus a resource pack adding new sound files must define events for them (this is not necessary when replacing old sounds already defined in events).

JE: <source>

Specifies the music category and options the sound falls under. Must be master, music, record, weather, block, hostile, neutral, player, ambient, or voice.

JE<targets>: entity
BE: player: target: CommandSelector<Player>

Must be a player name, a target selector or a UUID. And the target selector must be of player type.
Specifies the sound's target.

JE<pos>: vec3
BE: position: x y z: CommandPositionFloat

Must be a three-dimensional coordinates with floating-point number elements. Accepts tilde and caret notations.
Specifies the position to play the sounds from.

JE<volume>: float
BE: volume: float: float

Must be a Single-precision floating-point format number. In Java Edition, it must be greater than or equal to 0.0.
Specifies the distance that the sound can be heard. If not specified, defaults to 1. For values less than 1, the volume diminishes and the sound has a smaller sphere in which it may be heard. For values greater than 1, the sound does not actually grow louder, but its audible range (a 16-block radius at 1) is multiplied by volume. There is always a gradual falloff to silence based on distance from the center of the sphere. For values equal to or less than 0, no one can hear the sound.

JE<pitch>: float
BE: pitch: float: float

Must be a Single-precision floating-point format number. In Java Edition, it must be between 0.0 and 2.0 (inclusive).
Specifies the pitch of the sound. If not specified, defaults to 1.
In Java Edition, values less than 0.5 are equivalent to 0.5. Values lower than 1 lower the pitch and increase the duration; values greater than 1 raise the pitch and reduce the duration. The pitch value is a multiplier applied to the frequency, so if a value from 0.5 to 1 is doubled, the pitch goes an octave higher. (See Note block § Usage for converting other intervals to pitch values, but be aware that 1 isn't F♯ for all sound effects.)
In Bedrock Edition, only values between 0 and 256 work. Values above 256 are equivalent to the default value; values less than or equal to 0 makes the sound inaudible.[more information needed]

JE<minVolume>: float
BE: minimumVolume: float: float

Must be a Single-precision floating-point format number. In Java Edition, it must be between 0.0 and 1.0 (inclusive).
Specifies the volume for targets outside the sound's normal audible sphere. If a target is outside the normal sphere, the sound is instead centered some short distance from the target (less than four blocks away), and this argument determines its volume.

Result[edit]

CommandTriggerJava EditionBedrock Edition
anythe arguments are not specified correctly Unparseable Failed
if <targets> or player: target fails to resolve to one or more online players Failed
if nobody can hear the sound
if one of players cannot hear the sound N/A
On successPlays a sound for the targeted player(s).

Output[edit]

CommandEditionSituationSuccess Count/execute store succeess .../execute store result ...
anyJava EditionOn fail000
On success11the number of players who can hear the sound
Bedrock EditionOn fail0N/AN/A
On successthe number of targeted playersN/AN/A

History[edit]

Java Edition
1.6.1preAdded /playsound.
1.915w49a/playsound now accepts tab-completion.
16w02a/playsound now requires a source parameter, specifying what is the sound's category for volume purposes.
Pocket Edition
1.0.5alpha 1.0.5.0Added /playsound.

See also[edit]