American2050 Posted April 4, 2016 Share Posted April 4, 2016 I'm having problems figuring out how to make a custom sound play in my mod. ResourceLocation location = new ResourceLocation("playmeon:customsound"); SoundEvent sound = new SoundEvent(location); Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(sound, 1.0F)); the customsound.ogg is placed on resources/assets/playmeon/sounds/ I also have a sounds.json on resources/assets/playmeon/ { "customsound": {"category": "master","sounds": [{"name": "customsound","stream": false}]}, } But the sound is not playing, I'm getting: [server thread/WARN]: Unable to play unknown soundEvent: playmeon:customsound I wonder what I'm missing/forgetting here... Quote Link to comment Share on other sites More sharing options...
Draco18s Posted April 4, 2016 Share Posted April 4, 2016 world.playSoundEffect(...) ? Also, have you even looked at how the Jukebox works? Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
American2050 Posted April 4, 2016 Author Share Posted April 4, 2016 world.playSoundEffect(...) ? Also, have you even looked at how the Jukebox works? Well, I must still be missing something here. EntityPlayer player = (EntityPlayer) event.getEntityLiving(); ResourceLocation location = new ResourceLocation("playmeon:customsound"); SoundEvent sound = new SoundEvent(location); SoundCategory category = SoundCategory.MASTER; World world = event.getEntityLiving().worldObj; // world.playSound(player, player.getPosition(), sound, category, 1.0F, 1.0F); world.playRecord(player.getPosition(), sound); Quote Link to comment Share on other sites More sharing options...
Choonster Posted April 4, 2016 Share Posted April 4, 2016 SoundEvent s are singletons and need to be registered in preInit using GameRegister.register , just like Block s, Item s and any other implementation of IForgeRegistryEntry . Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
American2050 Posted April 4, 2016 Author Share Posted April 4, 2016 SoundEvent s are singletons and need to be registered in preInit using GameRegister.register , just like Block s, Item s and any other implementation of IForgeRegistryEntry . That's something I wasn't doing, and never did on my 1.7.10 Mods. Thanks I'm gonna give that a try and see how it does now. Quote Link to comment Share on other sites More sharing options...
Choonster Posted April 4, 2016 Share Posted April 4, 2016 SoundEvent s are singletons and need to be registered in preInit using GameRegister.register , just like Block s, Item s and any other implementation of IForgeRegistryEntry . That's something I wasn't doing, and never did on my 1.7.10 Mods. Thanks I'm gonna give that a try and see how it does now. SoundEvent s and Forge's new registry system were only added in 1.9. Earlier versions simply used strings for sound IDs. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
American2050 Posted April 6, 2016 Author Share Posted April 6, 2016 SoundEvent s are singletons and need to be registered in preInit using GameRegister.register , just like Block s, Item s and any other implementation of IForgeRegistryEntry . That's something I wasn't doing, and never did on my 1.7.10 Mods. Thanks I'm gonna give that a try and see how it does now. SoundEvent s and Forge's new registry system were only added in 1.9. Earlier versions simply used strings for sound IDs. I must be blind but I can't find any register for sounds on GameRegistry (Did I misunderstood something?) Quote Link to comment Share on other sites More sharing options...
Choonster Posted April 6, 2016 Share Posted April 6, 2016 I must be blind but I can't find any register for sounds on GameRegistry (Did I misunderstood something?) Instead of a separate method to register each type of object, there's now a pair of GameRegistry.register methods that register any IForgeRegistryEntry . This includes Block s, Item s and SoundEvent s. The single-argument overload expects the object to already have its registry name set with IForgeRegistryEntry#setRegistryName . The two-argument overload takes a registry name as an argument. Make sure you're using Forge 1.9-12.16.0.1819-1.9 or newer, this is the version that added the new registry system. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
American2050 Posted April 6, 2016 Author Share Posted April 6, 2016 Thanks, yes I'm updating my dev environment and today I did update them to 1845 and saw already that some things have changed, so I was kinda lost. Gonna update again to the newest Forge from today and start from there fixing what is broken now, hopefully I get it right. Thanks for your patience. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.