Changes

250 bytes added ,  01:17, 3 October 2021
Added a notice about a trap for newbies where sounds will always play on the client if they exist in the sound file regardless of registry.
Line 69: Line 69:  
For example, to reference <code>example_complex.ogg</code>, you would store the reference name (e.g. <code>example_sound_complex</code>) within a <code>new SoundEvent(new ResourceLocation("examplemod", "example_sound_complex"))</code>. This will locate <code>assets/examplemod/sounds.json</code> and try to find an <code>example_sound_complex</code> object nested within it.
 
For example, to reference <code>example_complex.ogg</code>, you would store the reference name (e.g. <code>example_sound_complex</code>) within a <code>new SoundEvent(new ResourceLocation("examplemod", "example_sound_complex"))</code>. This will locate <code>assets/examplemod/sounds.json</code> and try to find an <code>example_sound_complex</code> object nested within it.
   −
<code>SoundEvent</code>s must be [[Registration/1.16|registered]] to be referenced in code.  
+
 
 +
{{Tip/Warning|<code>SoundEvent</code>s must be [[Registration/1.16|registered]] on the <code>ModEventBus</code> to properly reference a sound on a server. However, <code>SoundEvent</code>s or referencing a sound by name will still work on the client when the sound is not registered as long as the sound exists in <code>sounds.json</code>!}}
    
== Playing Sounds ==
 
== Playing Sounds ==
2

edits