Jump to content

Recommended Posts

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.

Posted

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.

Posted

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

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