Jump to content

Unable to play unknown soundEvent [1.12.2]


Recommended Posts

Hi there,

I've added a custom entity (called a Nils) to my 1.12.2 mod and I'm trying to override the getAmbientSound(), getHurtSound() and getDeathSound() methods in the entity's class.


I have multiple of each sound saved in this folder:



This is my sounds.json (located in 





    "entity.nils.ambient" : {
        "category" : "entity",
        "subtitle" : "entity.nils.ambient",
        "sounds" : [
            {"name" : "MODNAME:entity/nils/ambient_0", "stream" : true},
            {"name" : "MODNAME:entity/nils/ambient_1", "stream" : true},
            {"name" : "MODNAME:entity/nils/ambient_2", "stream" : true},
            {"name" : "MODNAME:entity/nils/ambient_3", "stream" : true}
    "entity.nils.hurt" : {
        "category" : "entity",
        "subtitle" : "entity.nils.hurt",
        "sounds" : [
            {"name" : "MODNAME:entity/nils/hurt_0", "stream" : true},
            {"name" : "MODNAME:entity/nils/hurt_1", "stream" : true}
    "entity.nils.death" : {
        "category" : "entity",
        "subtitle" : "entity.nils.death",
        "sounds" : [
            {"name" : "MODNAME:entity/nils/death_0", "stream" : true},
            {"name" : "MODNAME:entity/nils/death_1", "stream" : true},
            {"name" : "MODNAME:entity/nils/death_2", "stream" : true},
            {"name" : "MODNAME:entity/nils/death_3", "stream" : true}


I have also tried replacing each dictionary element in "sounds" to just the name. ie. 

        "sounds" : [


The method overrides are just simple two-liners, all like this:

int index = (new Random()).nextInt(SoundsHandler.ENTITY_NILS_AMBIENT.size());
return SoundsHandler.ENTITY_NILS_AMBIENT.get(index);

(but obviously replacing ..._AMBIENT with ..._HURT and ..._DEATH for the other events).


The class SoundsHandler looks like this:

package mod.loizouca.MODNAME.util.handlers;

import java.util.ArrayList;
import java.util.List;

import mod.loizouca.MODNAME.util.Reference;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;

public class SoundsHandler {
	public static final int NUM_AMBIENT = 4, NUM_HURT = 2, NUM_DEATH = 4;
	public static List<SoundEvent> ENTITY_NILS_AMBIENT = new ArrayList<SoundEvent>();
	public static List<SoundEvent> ENTITY_NILS_HURT = new ArrayList<SoundEvent>();
	public static List<SoundEvent> ENTITY_NILS_DEATH = new ArrayList<SoundEvent>();
	public static void registerSounds() {
		for (int i=0; i<NUM_AMBIENT; i++) ENTITY_NILS_AMBIENT.add(registerSound("entity/nils/ambient_"+Integer.toString(i)));
		for (int i=0; i<NUM_HURT; i++) ENTITY_NILS_HURT.add(registerSound("entity/nils/hurt_"+Integer.toString(i)));
		for (int i=0; i<NUM_DEATH; i++) ENTITY_NILS_DEATH.add(registerSound("entity/nils/death_"+Integer.toString(i)));
	private static SoundEvent registerSound(String name) {
		ResourceLocation location = new ResourceLocation(Reference.MOD_ID, name);
		SoundEvent event = new SoundEvent(location);
		return event;


My problem is that after the game has loaded and I'm in the world (no problems thus far), the sounds don't work.I just get these errors in the Eclipse console:

[main/WARN] [minecraft/SoundManager]: Unable to play unknown soundEvent: MODNAME:entity/nils/ambient_0

This happens for every event (ambient, hurt and death) and for all the different files.

I'm aware that it is probably to do with where the files are, but I have changed their locations, I have changed the path I parse into registerSound(), and nothing has worked. If I leave it to super off the Entity I have inherited from, the sounds work (I get the cow moo, hurt and death sounds).


Please let me know if you need any more information / code / etc. and thanks in advance for any help :). This has been bugging me for days now.


(PS. I have replaced my mod's name with MODNAME in all the paths, so my code actually has a name there, not just a placeholder).

Link to comment
Share on other sites

This topic is now closed to further replies.


  • Create New...

Important Information

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