User Tools

Site Tools


tutorial:sounds

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:sounds [2021/02/06 10:33] – external edit 127.0.0.1tutorial:sounds [2024/06/23 16:23] (current) slainlight
Line 70: Line 70:
 public class ExampleMod { public class ExampleMod {
     [...]     [...]
-    public static final Identifier MY_SOUND_ID = new Identifier("tutorial:my_sound"); +    public static final Identifier MY_SOUND_ID = Identifier.of("tutorial:my_sound"); 
-    public static SoundEvent MY_SOUND_EVENT = new SoundEvent(MY_SOUND_ID);+    public static SoundEvent MY_SOUND_EVENT = SoundEvent.of(MY_SOUND_ID);
 } }
 </code> </code>
 +If you're using version 1.19.2 or below, please replace ''SoundEvent.of'' with ''new SoundEvent'', and 
 +if you're using versions below 1.21, replace ''Identifier.of'' with ''new Identifier''。 
 ==== Step 4: Register your sound event ==== ==== Step 4: Register your sound event ====
 Register your sound event under the ''SOUND_EVENT'' registry: Register your sound event under the ''SOUND_EVENT'' registry:
Line 80: Line 82:
 public void onInitialize(){ public void onInitialize(){
      [...]      [...]
-     Registry.register(Registry.SOUND_EVENT, ExampleMod.MY_SOUND_ID, MY_SOUND_EVENT);+     Registry.register(Registries.SOUND_EVENT, ExampleMod.MY_SOUND_ID, MY_SOUND_EVENT);
  
 </code> </code>
 +If you're using version 1.19.2 or below, please replace ''Registries'' with ''Registry''
 ==== Step 5: Use your sound event ==== ==== Step 5: Use your sound event ====
 Use the sound event just like we explained at the start (''onUse'' is just an example, use it anywhere you have access to ''World'' instance): Use the sound event just like we explained at the start (''onUse'' is just an example, use it anywhere you have access to ''World'' instance):
tutorial/sounds.1612607614.txt.gz · Last modified: 2021/02/06 10:33 by 127.0.0.1