Changes

72 bytes removed ,  21:33, 2 August 2021
Update to 1.17
Line 67: Line 67:  
Vanilla has lots of methods for playing sounds that can be used in different scenarios.
 
Vanilla has lots of methods for playing sounds that can be used in different scenarios.
   −
=== <code>World</code> ===
+
=== <code>Level</code> ===
   −
# <code><nowiki>playSound(PlayerEntity, BlockPos, SoundEvent, SoundCategory, volume, pitch)</nowiki></code>
+
# <code><nowiki>playSound(Player, BlockPos, SoundEvent, SoundCategory, volume, pitch)</nowiki></code>
 
#*Simply forwards to overload (2), adding 0.5 to each coordinate of the BlockPos given.
 
#*Simply forwards to overload (2), adding 0.5 to each coordinate of the BlockPos given.
# <code><nowiki>playSound(PlayerEntity, double x, double y, double z, SoundEvent, SoundCategory, volume, pitch)</nowiki></code>
+
# <code><nowiki>playSound(Player, double x, double y, double z, SoundEvent, SoundCategory, volume, pitch)</nowiki></code>
 
#* <code>Client Behavior</code>: If the passed in player is the client player, plays the sound event to the client player.
 
#* <code>Client Behavior</code>: If the passed in player is the client player, plays the sound event to the client player.
 
#* <code>Server Behavior</code>: Plays the sound event to everyone nearby except the passed in player. Player can be <code>null</code>.
 
#* <code>Server Behavior</code>: Plays the sound event to everyone nearby except the passed in player. Player can be <code>null</code>.
 
#* <code>Usage</code>: The correspondence between the behaviors implies that these two methods are to be called from some player-initiated code that will be run on both logical sides at the same time - the logical client handles playing it to the user and the logical server handles everyone else hearing it without re-playing it to the original user. They can also be used to play any sound in general at any position server-side by calling it on the logical server and passing in a <code>null</code> player, thus letting everyone hear it.
 
#* <code>Usage</code>: The correspondence between the behaviors implies that these two methods are to be called from some player-initiated code that will be run on both logical sides at the same time - the logical client handles playing it to the user and the logical server handles everyone else hearing it without re-playing it to the original user. They can also be used to play any sound in general at any position server-side by calling it on the logical server and passing in a <code>null</code> player, thus letting everyone hear it.
 
# <code><nowiki>playSound(double x, double y, double z, SoundEvent, SoundCategory, volume, pitch, distanceDelay)</nowiki></code>
 
# <code><nowiki>playSound(double x, double y, double z, SoundEvent, SoundCategory, volume, pitch, distanceDelay)</nowiki></code>
#* <code>Client Behavior</code>: Just plays the sound event in the client world. If distanceDelay is true, then delays the sound based on how far it is from the player.
+
#* <code>Client Behavior</code>: Just plays the sound event in the client level. If distanceDelay is true, then delays the sound based on how far it is from the player.
 
#* <code>Server Behavior</code>: Does nothing.
 
#* <code>Server Behavior</code>: Does nothing.
 
#* <code>Usage</code>: This method only works client-side, and thus is useful for sounds sent in custom packets, or other client-only effect-type sounds. Used for thunder.
 
#* <code>Usage</code>: This method only works client-side, and thus is useful for sounds sent in custom packets, or other client-only effect-type sounds. Used for thunder.
   −
=== <code> ClientWorld </code> ===
+
=== <code>ClientLevel</code> ===
    
# <code><nowiki>playSound(BlockPos, SoundEvent, SoundCategory, volume, pitch, distanceDelay)</nowiki></code>
 
# <code><nowiki>playSound(BlockPos, SoundEvent, SoundCategory, volume, pitch, distanceDelay)</nowiki></code>
#* Simply forwards to <code>World</code>‘s overload (3), adding 0.5 to each coordinate of the <code>BlockPos</code> given.
+
#* Simply forwards to <code>Level</code>‘s overload (3), adding 0.5 to each coordinate of the <code>BlockPos</code> given.
   −
=== <code> Entity </code> ===
+
=== <code>Entity</code> ===
    
# <code><nowiki>playSound(SoundEvent, volume, pitch)</nowiki></code>
 
# <code><nowiki>playSound(SoundEvent, volume, pitch)</nowiki></code>
#* Forwards to <code>World</code>‘s overload (2), passing in <code>null</code> as the player.
+
#* Forwards to <code>LEvel</code>‘s overload (2), passing in <code>null</code> as the player.
 
#* <code>Client Behavior</code>: Does nothing.
 
#* <code>Client Behavior</code>: Does nothing.
 
#* <code>Server Behavior</code>: Plays the sound event to everyone at this entity’s position.
 
#* <code>Server Behavior</code>: Plays the sound event to everyone at this entity’s position.
 
#* <code>Usage</code>: Emitting any sound from any non-player entity server-side.
 
#* <code>Usage</code>: Emitting any sound from any non-player entity server-side.
   −
=== <code> PlayerEntity</code> ===
+
=== <code>Player</code> ===
    
# <code><nowiki>playSound(SoundEvent, volume, pitch)</nowiki></code> (overriding the one in <code>[[Sounds#Entity|Entity]]</code>)
 
# <code><nowiki>playSound(SoundEvent, volume, pitch)</nowiki></code> (overriding the one in <code>[[Sounds#Entity|Entity]]</code>)
#* Forwards to <code>World</code>‘s overload (2), passing in <code>this</code> as the player.
+
#* Forwards to <code>Level</code>‘s overload (2), passing in <code>this</code> as the player.
#* <code>Client Behavior</code>: Does nothing, see override in <code>[[Sounds#clientplayerentity|ClientPlayerEntity]]</code>.
+
#* <code>Client Behavior</code>: Does nothing, see override in <code>[[Sounds#localplayer|LocalPlayer]]</code>.
 
#* <code>Server Behavior</code>: Plays the sound to everyone nearby <code>except</code> this player.
 
#* <code>Server Behavior</code>: Plays the sound to everyone nearby <code>except</code> this player.
#* <code>Usage</code>: See <code>[[Sounds#clientplayerentity|ClientPlayerEntity]]</code>.
+
#* <code>Usage</code>: See <code>[[Sounds#localplayer|LocalPlayer]]</code>.
   −
=== <code> ClientPlayerEntity</code> ===
+
=== <code>LocalPlayer</code> ===
   −
# <code><nowiki>playSound(SoundEvent, volume, pitch)</nowiki></code> (overriding the one in <code>[[Sounds#playerentity|PlayerEntity]]</code>)
+
# <code><nowiki>playSound(SoundEvent, volume, pitch)</nowiki></code> (overriding the one in <code>[[Sounds#player|Player]</code>)
#* Forwards to <code>World</code>‘s overload (2), passing in <code>this</code> as the player.
+
#* Forwards to <code>Level</code>‘s overload (2), passing in <code>this</code> as the player.
 
#* <code>Client Behavior</code>: Just plays the Sound Event.
 
#* <code>Client Behavior</code>: Just plays the Sound Event.
 
#* <code>Server Behavior</code>: Method is client-only.
 
#* <code>Server Behavior</code>: Method is client-only.
#* <code>Usage</code>: Just like the ones in <code>World</code>, these two overrides in the player classes seem to be for code that runs together on both sides. The client handles playing the sound to the user, while the server handles everyone else hearing it without re-playing to the original user.
+
#* <code>Usage</code>: Just like the ones in <code>Level</code>, these two overrides in the player classes seem to be for code that runs together on both sides. The client handles playing the sound to the user, while the server handles everyone else hearing it without re-playing to the original user.
       
[[Category:Game Effects]]
 
[[Category:Game Effects]]