Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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/

  • Author

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.