Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Minecraft:Commands/playsound: Difference between revisions

From SAS Gaming Wiki
SyncBot (talk | contribs)
Fix template calls: add MC/ prefix
SyncBot (talk | contribs)
Sync: updated from Minecraft
 
Line 4: Line 4:
* 2 {{only|java|short=1}}
* 2 {{only|java|short=1}}
* 1 {{only|bedrock|short=1}}
* 1 {{only|bedrock|short=1}}
|others=Cheat only{{only|bedrock|short=1}}
|others=[[Minecraft:Cheat]] only{{only|bedrock|short=1}}
}}
}}
Plays a specified sound to a player, in a location, and in a specific volume and pitch.
Plays a specified [[Minecraft:sound]] to a player, in a location, and in a specific volume and pitch.


== Syntax ==
== Syntax ==
Line 16: Line 16:


== Arguments ==
== Arguments ==
{{MC/Argument|sound|resource_location|sound: string|basic_string}}
{{argument|sound|resource_location|sound: string|basic_string}}
: Specifies the sound to play.
: Specifies the sound to play.
: {{MC/In|bedrock}}, {{lcfirst:{{MC/Arg desc|be=string}}}} Should be a sound definition defined in <samp>[[Minecraft:Sounds.json#Bedrock Edition values|sound_definitions.json]]</samp> (for example, <code>mob.pig.say</code>).
: {{IN|bedrock}}, {{lcfirst:{{arg desc|be=string}}}} Should be a sound definition defined in <samp>[[Minecraft:Sounds.json#Bedrock Edition values|sound_definitions.json]]</samp> (for example, <code>mob.pig.say</code>).
: {{MC/In|java}}, {{lcfirst:{{MC/Arg desc|je=resource_location}}}} Should be a '''Sound Event''' defined in <samp>[[Minecraft:Sounds.json#Sound events|sounds.json]]</samp> (for example, <code>entity.pig.ambient</code>).
: {{IN|java}}, {{lcfirst:{{arg desc|je=resource_location}}}} Should be a '''Sound Event''' defined in <samp>[[Minecraft:Sounds.json#Sound events|sounds.json]]</samp> (for example, <code>entity.pig.ambient</code>).
: 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 <code>entity.pig.ambient</code> sound event plays one of several pig sounds at random, because the event has multiple sounds associated with it.
: 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 <code>entity.pig.ambient</code> 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).
:[[Minecraft:Resource pack]]s 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).


{{MC/El|je|short=1}}: {{MC/Code|<''source''>}}
{{el|je|short=1}}: {{code|<''source''>}}
: Specifies the music category and options the sound falls under. Must be <code>master</code>, <code>music</code>, <code>record</code>, <code>weather</code>, <code>block</code>, <code>hostile</code>, <code>neutral</code>, <code>player</code>, <code>ambient</code>, <code>voice</code>, or <code>ui</code>. If omitted, <code>master</code> is used.
: Specifies the music category and options the sound falls under. Must be <code>master</code>, <code>music</code>, <code>record</code>, <code>weather</code>, <code>block</code>, <code>hostile</code>, <code>neutral</code>, <code>player</code>, <code>ambient</code>, <code>voice</code>, or <code>ui</code>. If omitted, <code>master</code> is used.


{{MC/Argument|targets|entity|player: target|CommandSelector<Player>}}
{{argument|targets|entity|player: target|CommandSelector<Player>}}
: Specifies the player(s) for whom the sound is going to be played. If not specified, defaults to the player who executes the command.
: Specifies the player(s) for whom the sound is going to be played. If not specified, defaults to the player who executes the command.
: {{MC/Arg desc|je=entity|amount=multiple|type=players|be=player}}
: {{arg desc|je=entity|amount=multiple|type=players|be=player}}


{{MC/Argument|pos|vec3|position: x y z|CommandPositionFloat}}
{{argument|pos|vec3|position: x y z|CommandPositionFloat}}
: Specifies the [[Minecraft:Coordinates|position]] to play the sounds from.
: Specifies the [[Minecraft:Coordinates|position]] to play the sounds from.
: {{MC/Arg desc|je=vec3|be=CommandPositionFloat}}
: {{arg desc|je=vec3|be=CommandPositionFloat}}


{{MC/Argument|volume|float|volume: float|float}}
{{argument|volume|float|volume: float|float}}
: Specifies the distance that the sound can be heard. If not specified, defaults to 1. For values less than 1, the volume diminishes. 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 player can hear the sound.
: Specifies the distance that the sound can be heard. If not specified, defaults to 1. For values less than 1, the volume diminishes. 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 player can hear the sound.
: {{MC/Arg desc|je=float|min=0.0|be=Float}}
: {{arg desc|je=float|min=0.0|be=Float}}


{{MC/Argument|pitch|float|pitch: float|float}}
{{argument|pitch|float|pitch: float|float}}
: Specifies the pitch and speed of the sound. If not specified, defaults to 1.
: Specifies the pitch and speed of the sound. If not specified, defaults to 1.
: {{MC/Arg desc|je=float|min=0.0|max=2.0|be=Float}}
: {{arg desc|je=float|min=0.0|max=2.0|be=Float}}
: {{MC/In|java}}, 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 {{slink|Note block|Usage}} for converting other intervals to pitch values, but be aware that 1 isn't F♯ for all sound effects.)
: {{IN|java}}, 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 {{slink|Note block|Usage}} for converting other intervals to pitch values, but be aware that 1 isn't F♯ for all sound effects.)
: {{MC/In|bedrock}}, only values between 0 and 256 work. Values above 256 are equivalent to the default value; values less than 0 default to 1, while values equal to 0 makes the sound inaudible. The value of the pitch is also the value for the speed multiplier, ex. if you set the pitch to 2 then the sound will play at double the pitch and double the speed.  
: {{IN|bedrock}}, only values between 0 and 256 work. Values above 256 are equivalent to the default value; values less than 0 default to 1, while values equal to 0 makes the sound inaudible. The value of the pitch is also the value for the speed multiplier, ex. if you set the pitch to 2 then the sound will play at double the pitch and double the speed.  
: Notice that in [[Minecraft:Bedrock Edition]], if you try to set a pitch value to a sound, then the speed of playing sound will be changed in turn. And the speed multiplier is just the value of this argument.  
: Notice that in [[Minecraft:Bedrock Edition]], if you try to set a pitch value to a sound, then the speed of playing sound will be changed in turn. And the speed multiplier is just the value of this argument.  


{{MC/Argument|minVolume|float|minimumVolume: float|float}}
{{argument|minVolume|float|minimumVolume: float|float}}
: 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 (two blocks away) from the target, and this argument determines its volume. If not greater than 0, targets outside the normal audible sphere cannot hear the sound.
: 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 (two blocks away) from the target, and this argument determines its volume. If not greater than 0, targets outside the normal audible sphere cannot hear the sound.
: If not specified, defaults to 0.0.  
: If not specified, defaults to 0.0.  
: {{MC/Arg desc|je=float|min=0.0|max=1.0|be=Float}}
: {{arg desc|je=float|min=0.0|max=1.0|be=Float}}


== Result ==
== Result ==
Line 57: Line 57:
{{Result table|<code><targets></code> or <code>player: target</code> fails to resolve to one or more online players.|fail}}
{{Result table|<code><targets></code> or <code>player: target</code> fails to resolve to one or more online players.|fail}}
{{Result table|Nobody can hear the sound (<code>minVolume</code> or <code>minimumVolume: float</code> is not greater than 0.0, while all the targets are outside the normal audible sphere).}}
{{Result table|Nobody can hear the sound (<code>minVolume</code> or <code>minimumVolume: float</code> is not greater than 0.0, while all the targets are outside the normal audible sphere).}}
{{Result table|One of the specified players cannot hear the sound{{MC/Needs testing}}.|N/A}}
{{Result table|One of the specified players cannot hear the sound{{needs testing}}.|N/A}}
{{Result table|succeed}}
{{Result table|succeed}}
{{Result table}}
{{Result table}}
Line 63: Line 63:
== Output ==
== Output ==


{{MC/Output table}}
{{Output table}}
{{MC/Output table|edition=je|On fail|0|0|0}}
{{Output table|edition=je|On fail|0|0|0}}
{{MC/Output table|On success|1|1|the number of players who can hear the sound}}
{{Output table|On success|1|1|the number of players who can hear the sound}}
{{MC/Output table|edition=be|On fail|0}}
{{Output table|edition=be|On fail|0}}
{{MC/Output table|On success|the number of targeted players}}
{{Output table|On success|the number of targeted players}}
{{MC/Output table}}
{{Output table}}


== Examples ==
== Examples ==
* To play the creeper hissing sound 3 blocks behind the nearest player:
* To play the [[Minecraft:creeper]] hissing sound 3 blocks behind the nearest player:
** <code>/[[Minecraft:execute]] as @p at @s run playsound entity.creeper.primed hostile @s ^ ^ ^-3 1 0.5</code>{{only|java}}
** <code>/[[Minecraft:execute]] as @p at @s run playsound entity.creeper.primed hostile @s ^ ^ ^-3 1 0.5</code>{{only|java}}
** <code>/[[Minecraft:execute]] as @p at @s run playsound note.creeper @s ^ ^ ^-3 1 0.5</code>{{only|bedrock}}
** <code>/[[Minecraft:execute]] as @p at @s run playsound note.creeper @s ^ ^ ^-3 1 0.5</code>{{only|bedrock}}
Line 78: Line 78:
=== ''Java Edition'' ===
=== ''Java Edition'' ===
{{HistoryTable
{{HistoryTable
|{{MC/HistoryLine|java}}
|{{HistoryLine|java}}
|{{HistoryLine||1.6.1|dev=pre|Added {{MC/Cmd|playsound|link=none}}.}}
|{{HistoryLine||1.6.1|dev=pre|Added {{cmd|playsound|link=none}}.}}
|{{HistoryLine||1.9|dev=15w49a|{{MC/Cmd|playsound|link=none}} now accepts tab-completion.}}
|{{HistoryLine||1.9|dev=15w49a|{{cmd|playsound|link=none}} now accepts tab-completion.}}
|{{HistoryLine|||dev=16w02a|{{MC/Cmd|playsound|link=none}} now requires a ''source'' parameter, specifying what is the sound's category for volume purposes.}}
|{{HistoryLine|||dev=16w02a|{{cmd|playsound|link=none}} now requires a ''source'' parameter, specifying what is the sound's category for volume purposes.}}
|{{HistoryLine||1.20.5|dev=24w09a|Can now be used without specifying the player (assuming {{MC/Cd|@s}}) and without specifying the mixer (assuming {{MC/Cd|master}}).}}
|{{HistoryLine||1.20.5|dev=24w09a|Can now be used without specifying the player (assuming {{cd|@s}}) and without specifying the mixer (assuming {{cd|master}}).}}
|{{HistoryLine||1.21.6|dev=Pre-Release 3|Added new category {{MC/Cd|ui}}.}}
|{{HistoryLine||1.21.6|dev=Pre-Release 3|Added new category {{cd|ui}}.}}
}}
}}


=== ''Bedrock Edition'' ===
=== ''Bedrock Edition'' ===
{{HistoryTable
{{HistoryTable
|{{MC/HistoryLine|pocket}}
|{{HistoryLine|pocket}}
|{{HistoryLine||1.0.5|dev=alpha 1.0.5.0|Added {{MC/Cmd|playsound|link=none}}.}}
|{{HistoryLine||1.0.5|dev=alpha 1.0.5.0|Added {{cmd|playsound|link=none}}.}}
}}
}}


== See also ==
== See also ==
* {{MC/Cmd|stopsound}} — Stops a sound.
* {{cmd|stopsound}} — Stops a sound.


== External links ==
== External links ==
Line 100: Line 100:


== Navigation ==
== Navigation ==
{{MC/Navbox commands}}
{{Navbox commands}}


de:Befehl/playsound
[[Minecraft:de:Befehl/playsound]]
es:Comandos/playsound
[[Minecraft:es:Comandos/playsound]]
ja:コマンド/playsound
[[Minecraft:fr:Commandes/playsound]]
pt:Comandos/playsound
[[Minecraft:ja:コマンド/playsound]]
ru:Команды консоли/playsound
[[Minecraft:pt:Comandos/playsound]]
uk:Команди консолі/playsound
[[Minecraft:ru:Команды консоли/playsound]]
zh:命令/playsound
[[Minecraft:uk:Команди консолі/playsound]]
[[Minecraft:zh:命令/playsound]]

Latest revision as of 11:03, 19 May 2026

Template:Infobox command Plays a specified Minecraft:sound to a player, in a location, and in a specific volume and pitch.

Syntax

  • 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

Template:Argument

Specifies the sound to play.
Template:IN, Template:Arg desc Should be a sound definition defined in sound_definitions.json (for example, mob.pig.say).
Template:IN, Template:Arg desc Should 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.
Minecraft: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).

Template:El: Template:Code

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

Template:Argument

Specifies the player(s) for whom the sound is going to be played. If not specified, defaults to the player who executes the command.
Template:Arg desc

Template:Argument

Specifies the position to play the sounds from.
Template:Arg desc

Template:Argument

Specifies the distance that the sound can be heard. If not specified, defaults to 1. For values less than 1, the volume diminishes. 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 player can hear the sound.
Template:Arg desc

Template:Argument

Specifies the pitch and speed of the sound. If not specified, defaults to 1.
Template:Arg desc
Template:IN, 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 Template:Slink for converting other intervals to pitch values, but be aware that 1 isn't F♯ for all sound effects.)
Template:IN, only values between 0 and 256 work. Values above 256 are equivalent to the default value; values less than 0 default to 1, while values equal to 0 makes the sound inaudible. The value of the pitch is also the value for the speed multiplier, ex. if you set the pitch to 2 then the sound will play at double the pitch and double the speed.
Notice that in Minecraft:Bedrock Edition, if you try to set a pitch value to a sound, then the speed of playing sound will be changed in turn. And the speed multiplier is just the value of this argument.

Template:Argument

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 (two blocks away) from the target, and this argument determines its volume. If not greater than 0, targets outside the normal audible sphere cannot hear the sound.
If not specified, defaults to 0.0.
Template:Arg desc

Result

Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table Template:Result table

Output

Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table Template:Output table

Examples

History

Java Edition

Template:HistoryTable

Bedrock Edition

Template:HistoryTable

See also

External links

Navigation

Template:Navbox commands

Minecraft:de:Befehl/playsound Minecraft:es:Comandos/playsound Minecraft:fr:Commandes/playsound Minecraft:ja:コマンド/playsound Minecraft:pt:Comandos/playsound Minecraft:ru:Команды консоли/playsound Minecraft:uk:Команди консолі/playsound Minecraft:zh:命令/playsound