Posted August 12, 20232 yr For some reason, this code doesn't work: public void GameStart() { System.out.println("Checking for server"); //(1) if (Value.server != null && Value.server.isRunning()) { System.out.println("Playing Sound"); //(2) Value.server.getPlayerList().getPlayers().forEach(p ->{ double x = p.getX(); double y = p.getY(); double z = p.getZ(); p.getLevel().playSound(p.getInventory().player, x, y, z, LoadSounds.GAME_START.get(), SoundSource.PLAYERS, 100f, 100f); }); } } Both System.out.print are executed, but no sound is played. I can play the sound using /playsound, so I don't think it is caused by a typo in the all the JSON file or in the name of those files. Here are aditional file that may be needed: LoadSound.class: public class LoadSounds { public static final DeferredRegister<SoundEvent> SOUND_EVENT = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, FlagsHunters.MODID); //Load Sound public static final RegistryObject<SoundEvent> GAME_START = soundEventRegistryObject("game_start"); //Random Stuff private static RegistryObject<SoundEvent> soundEventRegistryObject(String name) { ResourceLocation id = new ResourceLocation(FlagsHunters.MODID, name); return SOUND_EVENT.register(name, () -> new SoundEvent(id)); } //Load function public static void Load(IEventBus eventBus) { SOUND_EVENT.register(eventBus); } } sounds.json: { "game_start": { "subtitle": "flagshunters.subtitle.game_start", "sounds": [ "flagshunters:game_start" ] } } all the file and folder: The minecraft version: 1.19.2 The forge version: 43.2.21 Edited August 12, 20232 yr by ____tbvns____ Forgot to add version
August 12, 20232 yr Please use the search function in future. These playsound FAQs have been asked and answered sooo many times before. https://forge.gemwire.uk/wiki/Sounds#Level You are doing 2.2 which assumes the sound has already been played by the client for any player passed in the first parameter. i.e. the player for ServerLevel.playsound is an "exclude this player". Quote Server Behavior: Plays the sound event to everyone nearby except the passed in player. Player can be null. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
August 12, 20232 yr Author 10 minutes ago, warjort said: Please use the search function in future. These playsound FAQs have been asked and answered sooo many times before. https://forge.gemwire.uk/wiki/Sounds#Level You are doing 2.2 which assumes the sound has already been played by the client for any player passed in the first parameter. i.e. the player for ServerLevel.playsound is an "exclude this player". Nice! thx you so much !
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.