Sound file is registered, but when I use the /playsound command, no sound is playing.
ModSounds.java:
@Mod.EventBusSubscriber(modid =ExampleMod.MODID, bus =Mod.EventBusSubscriber.Bus.MOD)@ObjectHolder(ExampleMod.MODID)publicclassModSounds{publicstaticSoundEvent epic_music;/**
* The actual event handler that registers the custom items.
*
* @param event The event this event handler handles
*/@SubscribeEventpublicstaticvoid registerSounds(RegistryEvent.Register<SoundEvent> event){ResourceLocation yeet =newResourceLocation(ExampleMod.MODID,"epic_music");
epic_music =newSoundEvent(yeet).setRegistryName(yeet);
final SoundEvent[] soundEvents ={
epic_music
};
event.getRegistry().registerAll(soundEvents);}}
the sounds.json file is in src/main/resources/assets/examplemod/sounds.json
The sound file is called epic_music.ogg and is in src/main/resources/assets/examplemod/sounds/epic_music.ogg
The epic_music.ogg file is a 9.5 minute speech file.
ExampleMod.java
@Mod("examplemod")publicclassExampleMod{// Directly reference a log4j logger.privatestatic final Logger LOGGER =LogManager.getLogger();publicstatic final String MODID ="examplemod";publicExampleMod(){// Register ourselves for server and other game events we are interested inMinecraftForge.EVENT_BUS.register(this);}// You can use SubscribeEvent and let the Event Bus discover methods to call@SubscribeEventpublicvoid onServerStarting(FMLServerStartingEvent event){// do something when the server starts
LOGGER.info("HELLO from server starting");}}
The game recognizes the examplemod:epic_music sound when I go to enter the /playsound command, but no sound is playing
Registering custom sound
in Modder Support
Posted
Sound file is registered, but when I use the /playsound command, no sound is playing.
ModSounds.java:
the sounds.json file is in src/main/resources/assets/examplemod/sounds.json
The sound file is called epic_music.ogg and is in src/main/resources/assets/examplemod/sounds/epic_music.ogg
The epic_music.ogg file is a 9.5 minute speech file.
ExampleMod.java
The game recognizes the examplemod:epic_music sound when I go to enter the /playsound command, but no sound is playing