Jump to content

[Solved] [1.15] Registering a sound event - Missing sound for event


imtheredspy

Recommended Posts

Hi,

 

I've been trying to look this up and have had no luck with this. As far as I'm aware, my code looks correct, but obviously something is missing.

 

The problem is that I have registered a couple sound events for a custom entity, but the entity is not playing the sound, and the debug log states this: 

[Render thread/WARN] [net.minecraft.client.audio.SoundEngine/]: Missing sound for event: thestuff:schnozz_ambient

 

 

Here's my ModSoundEvents class to store the sound events:

package com.redspy.thestuff.common;

import java.util.ArrayList;

import com.redspy.thestuff.TheStuff;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;

public class ModSoundEvents {
	static ArrayList<SoundEvent> allItems = new ArrayList<SoundEvent>();
	
	public static SoundEvent schnozz_ambient = register("schnozz_ambient");
	public static SoundEvent schnozz_hurt = register("schnozz_hurt");
	public static SoundEvent schnozz_dead = register("schnozz_dead");

	public static SoundEvent[] getAllSounds()
	{
		return allItems.toArray(new SoundEvent[allItems.size()]);
	}
	
	private static ResourceLocation location(String name)
	{
		return new ResourceLocation(TheStuff.modId, name);
	}
	
	private static SoundEvent register(String name)
	{
		ResourceLocation soundLocation = location(name);
		SoundEvent ret = new SoundEvent(soundLocation).setRegistryName(name);
		allItems.add(ret);
		return ret;
	}
}

 

And here's how they're registered:

        @SubscribeEvent
        public static void onSoundsRegistry(final RegistryEvent.Register<SoundEvent> event) {
			event.getRegistry().registerAll
			(
				ModSoundEvents.getAllSounds()
			);
			LOGGER.info("Sounds Registered");
        }

 

Here's my sounds.json (located at src\main\resources\assets\thestuff)

{
	"schnozz_ambient": {
		"category": "mob",
		"subtitle": "thestuff.subtitle.schnozz_ambient",
		"sounds": [
			"thestuff:schnozz_ambient1",
			"thestuff:schnozz_ambient2"
		]
	},
	"schnozz_hurt": {
		"category": "mob",
		"subtitle": "thestuff.subtitle.schnozz_hurt",
		"sounds": [
			"thestuff:schnozz_hurt1",
			"thestuff:schnozz_hurt2"
		]
	},
	"schnozz_dead": {
		"category": "mob",
		"subtitle": "thestuff.subtitle.schnozz_dead",
		"sounds": [
			"thestuff:schnozz_dead"
		]
	},
}

With the sounds located at src\main\resources\assets\thestuff\sounds, and all the sounds are not empty, and are .ogg files.

 

In case it helps, my custom entity is derived off of a chicken, and calls the sounds as such:

	   protected SoundEvent getAmbientSound() {
	      return ModSoundEvents.schnozz_ambient;
	   }

	   protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
	      return ModSoundEvents.schnozz_hurt;
	   }

	   protected SoundEvent getDeathSound() {
	      return ModSoundEvents.schnozz_dead;
	   }

 

 

I should also note that "/playsound thestuff:schnozz_ambient" or any of the other sound event registry names does not work in-game.

 

Not sure where I'm going wrong here, or how to fix it. 

 

Any ideas? Tips? 

Anything I'm obviously doing wrong?

Edited by imtheredspy
solved
Link to comment
Share on other sites

I feel rather silly after finally figuring out what went wrong. If you take a look at my sounds.json, the last sound object has a trailing comma after it. I usually program in C# using Newtonsoft when working with JSON so I'm used to the model accepting and ignoring the trailing comma at the end. After removing the extra comma, sounds loaded just fine.

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.