Jump to content

[1.8] Playing custom music problem (no gradlew, mcp)


TominoCZ

Recommended Posts

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.

Link to comment
Share on other sites

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).

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.