Posted August 30, 201213 yr Hello! How do I make music play in my dimension like how the aether does it? I want my custom music to play. http://i.imgur.com/Hppni.png[/img]
August 30, 201213 yr Author Subscribe to the PlayBackgroundMusicEvent and then check if the player is in your dimension. If so, return a different SoundPoolEntry. That's how I'd do it. To have the music in your Mod-Zip file, you can use a custom URLStreamHandler which makes the SoundPoolEntry accept the InputStreams from your zip. Ask if you wan't help with that. Yes I would want some more help with that stuff. Someone should make a page on the tutorials page on how to add background music to dimensions and just music in general and also in the same tutorial how to add sounds(I used the system with ISoundHandler before but now that its gone I need to do the events things) so yeah, a tutorial called: How to add new Audio(Sounds and Music) should be in the tutorials section! http://i.imgur.com/Hppni.png[/img]
August 30, 201213 yr Author The method instance() is undefined for the type ThorMod_InputStreamURLHandler i think you forgot it http://i.imgur.com/Hppni.png[/img]
August 30, 201213 yr Author Can you explain what is the path to the actual file and how to add more? http://i.imgur.com/Hppni.png[/img]
August 31, 201213 yr You are aware of the fact that Class.getResource() (Not as stream) returns an URL you could pass to new SoundPoolEntry? Like: public class SoundHandler { @ForgeSubscribe public void onSound(SoundLoadEvent event) { try { event.manager.soundPoolSounds.addSound("your/sound.ogg", CameraCraft.class.getResource("/path/to/your/sound.ogg")); } catch (Exception e) { System.err.println("Failed to register one or more sounds."); } } } This avoids writing a hacked urlstreamhandler and will work no matter where in your classpath the sound file is.
August 31, 201213 yr Author I have a problem. I want my mob to do this sound but im not getting anything, heres my code package net.minecraft.src; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; import net.minecraftforge.client.event.sound.SoundLoadEvent; import net.minecraftforge.event.ForgeSubscribe; public class ThorMod_SoundHandler { @ForgeSubscribe @SideOnly(Side.CLIENT) public void onSound(SoundLoadEvent event) { try { event.manager.soundPoolSounds.addSound("monkey1", mod_TheThorMod.class.getResource("/Sounds/monkey1")); event.manager.soundPoolSounds.addSound("monkey2", mod_TheThorMod.class.getResource("/Sounds/monkey2")); event.manager.soundPoolSounds.addSound("monkey3", mod_TheThorMod.class.getResource("/Sounds/monkey3")); } catch (Exception e) { System.err.println("Failed to register one or more sounds."); } } } And in my entity class I have this protected String getLivingSound() { return "monkey"; } http://i.imgur.com/Hppni.png[/img]
August 31, 201213 yr Okay, I tried that now for myself and my sound won't register anywhere. In fact, the onSound method doesn't get even called (I've put a println in the method to test if it gets called). Did I do something wrong? My SoundHandler: public class PD_SoundHandler { @ForgeSubscribe public void onSound(SoundLoadEvent event) { System.out.println("sound!"); try { event.manager.soundPoolSounds.addSound("particledeco/static.ogg", PD_ModRegistry.class.getResource("/sound/static.wav")); } catch (Exception e) { System.err.println("Failed to register one or more sounds."); } } The event bus will be registered in my ClientProxy like this: MinecraftForge.EVENT_BUS.register(new PD_SoundHandler()); how I want to call my sound (in my entity): PD_ModRegistry.proxy.getClientWorld().playSoundAtEntity(this, "particledeco.static", 1f, 1f); PS: It seems that Thor597 above me has the same problem Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
August 31, 201213 yr Okay, tyvm, but I have still the problem that the sound isn't played. The sound is registered and the file will be found, but the entity won't play it EDIT: Nvm, I'm using the worldObj field from my entity instead the ClientWorld from my proxy and it works now ^.^ EDIT2: It seems you have to use the server world for the entity, because it doesn't work with the client one... Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
August 31, 201213 yr Author So if i want music in my dimension i put this in my soundhandler @ForgeSubscribe @SideOnly(Side.CLIENT) public void onSound(SoundLoadEvent event) { try { if(this.world.provider.worldType == 23) { event.manager.soundPoolMusic.addSound("thormod/netromWood2.wav", mod_TheThorMod.class.getResource("/Sounds/netromWood2.wav")); } } http://i.imgur.com/Hppni.png[/img]
August 31, 201213 yr Author i defined it above, anyway how do i use the nPlayBackgroundMusicEvent? thanks http://i.imgur.com/Hppni.png[/img]
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.