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

so anyways, I've been trying to mod minecraft so that every time you break a block, or hit an entity, it makes a sound when using this item i've been trying to code in. i tried onLeftClick, and no sound,  i even tried using a vanilla sound to see if the code was working properly, and it didn't even work.  I cant seem to get this sound to play. and also i tried adding the files to the .json configuration file and it seems to be of no help to me. also the sound files are in the \src\main\java\assets\modname\sounds folder. i could really use some help, as youtube and the rest of the internet tutorials have failed me. i am modding 1.6.4 on the gradle setup in forge 9.11.1.964 (as for most of the good mods are back in that update, and i want to be able to use it along with a few other 1.6.4 never updated mods. 1.6.4 was a good era for mods, what can i say?) anyone here got something useful that i could possibly use or some good advice, please comment.

I know this is said way too many times on this forum, but try to update to 1.7 or 1.8 if you can. 1.6.4 is really old.

 

As for getting this to work, try sending a log message to see if the method is being called.

In 1.6.4, sounds are not added via JSON, they are registered during an event:

@ForgeSubscribe
public void onLoadSound(SoundLoadEvent event) {
event.manager.addSound(ModInfo.ID + ":sound_file.ogg");
}

If you have a sound with variants (e.g. 'sound1', 'sound2', etc.), you need to register each variant separately (loops work great) BUT when you play the sound, you play it without a number (e.g. 'sound') and it chooses a random one from the variants.

 

Other than that, sounds are handled exactly the same: world.playSoundAt(Entity...) plays a sound on the server which everyone will hear, player.playSound can be used on the client side to play a sound just for that player, and packets are your go between when needed.

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.