TominoCZ Posted April 17, 2015 Posted April 17, 2015 First you have to know: I just begun coding, so I almost don't know anything about it. Just some very small basics... I have this code for playing sounds: soundHandlerIn.playSound(PositionedSoundRecord.createPositionedSoundRecord(new ResourceLocation("music.menu"), 1.0F)); But how do I make it play my own music? let's say the sound file is called payday.ogg. Where do I put the file? What would the code look like? Plz help. Quote
jabelar Posted April 17, 2015 Posted April 17, 2015 ResourceLocation call also be constructed to point to a mod's location, like this: ResouceLocation("yourmodid", "thepathtoyourasset") So you should put your modid and path in. The path should be the part after the /assets/yourmodid/ so if you created a music folder for assets then the path would be "music/yourfilename". However, if you're creating a sound from the entity, including the player, then there is a different play sound method available. theEntity.playSound("yourmodid:thepathtoyourasset", 1.0F, 1.0F) You'd change theEntity to whatever entity instance you have. The first 1.0F is the sound volume (you can lower it if you want), and second is the sound pitch (like you can make the sound deeper or higher). Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
TominoCZ Posted April 17, 2015 Author Posted April 17, 2015 So I just made a new package. I called it assets.PAYDAY2.sounds.music and I also put the sound file called menu.ogg there. So here's my the code: soundHandlerIn.playSound(PositionedSoundRecord.createPositionedSoundRecord(new ResourceLocation("PAYDAY2", "sounds/music/menu.ogg"))); (tell me if it's allright) EDIT: It's not. [19:20:53] [Client thread/WARN]: Unable to play unknown soundEvent: payday2:sounds/music/menu.ogg PS: this music is supposed to play after pressing a button - only the playsound remains to complete, other is done. Quote
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.