Jump to content

[1.10.2] [SOLVED] Sound Resource Domain Is Lost (build 2076)


Recommended Posts

Posted

My sounds' resource locations are being set correctly and bound to their sounds, but by the time MC tries to validate them, all of the domains have been lost, resulting in "minecraft:" locations that can't be found. I've stepped through my static assignments in the debugger; they're creating the correct RLs, which are printed to the console.

 

This is not a new mod. This was all working as intended in mc 1.8. I can't for the life of me figure out where my resource locations are losing their domains.

 

First my sound source code:

  protected static final String modid = classInventionsMod.MODID;

  public static final String pwrUpPath = "fanPwrUp";
  public static final ResourceLocation PWRUP = new ResourceLocation (modid, pwrUpPath);
  protected static final SoundEvent fanPwrUpSnd = new SoundEvent (PWRUP);

  public static final String whirrPath = "fanWhirr";
  public static final ResourceLocation WHIRRLOC = new ResourceLocation (modid, whirrPath);
  protected static final SoundEvent whirrSnd = new SoundEvent (WHIRRLOC);

  public static final String chokePath = "fanChoke";
  public static final ResourceLocation CHOKE = new ResourceLocation (modid, chokePath);
  protected static final SoundEvent fanChokeSnd = new SoundEvent (CHOKE);

  public static final String pwrDnPath = "fanPwrDn";
  public static final ResourceLocation PWRDN = new ResourceLocation (modid, pwrDnPath);
  protected static final SoundEvent fanPwrDnSnd = new SoundEvent (PWRDN);

 

Then the console:

 

[16:42:49] [Client thread/INFO] [sTDOUT]: [jrfshare.classJRFmod:regBlock:172]: Registered blower block with ID = 0218 & iBlock with ID = 4096

[16:42:49] [Client thread/INFO] [sTDOUT]: [jrfinventions.classBlockBlower:<init>:75]: PWRUP=jrfinventions:fanPwrUp

[16:42:49] [Client thread/INFO] [sTDOUT]: [jrfinventions.classBlockBlower:<init>:76]: WHIRRLOC=jrfinventions:fanWhirr

[16:42:49] [Client thread/INFO] [sTDOUT]: [jrfinventions.classBlockBlower:<init>:77]: CHOKE=jrfinventions:fanChoke

[16:42:49] [Client thread/INFO] [sTDOUT]: [jrfinventions.classBlockBlower:<init>:78]: PWRDN=jrfinventions:fanPwrDn

[16:42:49] [Client thread/INFO] [sTDOUT]: [jrfinventions.classInventionsMod:preInit:89]: STATUS: Registered TE

[16:42:49] [Client thread/INFO] [sTDOUT]: [jrfshare.classProxyClient:preInit:88]: Preinit jrfinventions

[16:42:49] [Client thread/INFO] [FML]: Applying holder lookups

[16:42:49] [Client thread/INFO] [FML]: Holder lookups applied

[16:42:49] [Client thread/INFO] [FML]: Injecting itemstacks

[16:42:49] [Client thread/INFO] [FML]: Itemstack injection complete

[16:42:49] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Found status: OUTDATED Target: 12.18.2.2099

[16:42:56] [Client thread/WARN]: File minecraft:sounds/fanPwrUp.ogg does not exist, cannot add it to event jrfinventions:fanPwrUp

[16:42:56] [Client thread/WARN]: File minecraft:sounds/fanWhirr.ogg does not exist, cannot add it to event jrfinventions:fanWhirr

[16:42:56] [Client thread/WARN]: File minecraft:sounds/fanChoke.ogg does not exist, cannot add it to event jrfinventions:fanChoke

[16:42:56] [Client thread/WARN]: File minecraft:sounds/fanPwrDn.ogg does not exist, cannot add it to event jrfinventions:fanPwrDn

[16:42:56] [sound Library Loader/INFO]: Starting up SoundSystem...

 

 

How do I upgrade my code? Or, do I need to move to a later Forge build of mc 1.10.2?

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

As of 1.9+ you need to register your SoundEvents in the Forge game registry

// common code
public static SoundEvent SOUND_EVENT_BASIC_SOUND;

public static void register()
{
    ResourceLocation soundID = new ResourceLocation(SoundsByExample.MODID, "sbe01_sound_event_basic_sound_name");
    SOUND_EVENT_BASIC_SOUND = GameRegistry.register(new SoundEvent(soundID).setRegistryName(soundID));
}

 

As of 1.10.1+ I you no longer need the specify a sound category in the sounds.json file

{	
"sbe01_sound_event_basic_sound_name": 
{
	"subtitle": "subtitle.item.soundsbyexample:sbe01_sound_event_basic_sound",
	"sounds": 
	[
		{
			"name": "soundsbyexample:sbe01_sound_event_basic_sound",
			"stream": false
		}
	]
}
}

 

References:

http://mcforge.readthedocs.io/en/latest/effects/sounds/

https://github.com/Aeronica/SoundsByExample/tree/master/src/main/java/soundsbyexample/sbe01_basic_sound

Posted

Please show your

sounds.json

.

 

This is unchanged from what worked in 1.8. Have the rules changed?

sounds.json:

{
"fanPwrUp": {"category": "master","sounds": [{"name": "fanPwrUp", "stream": false}]},
"fanWhirr": {"category": "master","sounds": [{"name": "fanWhirr", "stream": false}]},
"fanChoke": {"category": "master","sounds": [{"name": "fanChoke", "stream": false}]},
"fanPwrDn": {"category": "master","sounds": [{"name": "fanPwrDn", "stream": false}]}
}

 

As of 1.9+ you need to register your SoundEvents in the Forge game registry

 

Aha... I'm not doing that (yet). I'll get on it tomorrow. Too bad the RL I passed into the constructor wasn't used to set the registry name (and register the sound for me).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Got past the earlier error and ran into something really surprising. The "sound" supplied by Forge's PlaySoundEvent has a null in it!

 

It turns out that the "sound" in the event is a sound record wrapper around the actual sound that I used to get directly in mc 1.8 and earlier. Inside of this wrapper, the actual sound is null because the hook fires before it is set by side-effect of a call to createAccessor.

 

In order to make getSound() callable, my PlaySoundEvent event-handler needs to call p_sound.createAccessor(this.sndHandler) before it can call getSound(). Without the side-effects of that call, getSound() blows up with a null pointer exception.

 

I'm aghast at how badly MC mangled the sound interface since 1.8 (leaving initialization until after the constructor is egregious, and requiring external calls to functions with side-effects is unforgivable). Who's writing this now, Microsoft?

 

At least I'm no longer crashing. However, my block is silent. Perhaps I am calling the wrong server-side substitute for playSoundEffect(...). I will poke around some more in the debugger and post again if I get stuck.

 

My revised registration code:

 

  public static final ResourceLocation PWRUP = new ResourceLocation (modid, "fanPwrUp");
  protected static final SoundEvent fanPwrUpSnd = GameRegistry.register (new SoundEvent (PWRUP).setRegistryName (PWRUP));

  public static final ResourceLocation WHIRRLOC = new ResourceLocation (modid, "fanWhirr");
  protected static final SoundEvent whirrSnd = GameRegistry.register (new SoundEvent (WHIRRLOC).setRegistryName (WHIRRLOC));

  public static final ResourceLocation CHOKE = new ResourceLocation (modid, "fanChoke");
  protected static final SoundEvent fanChokeSnd = GameRegistry.register (new SoundEvent (CHOKE).setRegistryName (CHOKE));

  public static final ResourceLocation PWRDN = new ResourceLocation (modid, "fanPwrDn");
  protected static final SoundEvent fanPwrDnSnd = GameRegistry.register (new SoundEvent (PWRDN).setRegistryName (PWRDN));

 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Forge's documentation has an explanation of the various sound-playing methods here.

 

The

SoundEvent

is the object you use to play the sound, the

ResourceLocation

stored by it doesn't need to be saved anywhere.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Fan power up?  Hmm so you are doing some sort of machine sounds. Is this a sort of ASR: attack-sustain-release sound mechanic?

 

Sort of. The whirr is a continuous sound. The others are short sound-effects. The power-up and down also play when the fan changes speed (covering the skip when the whirr changes pitch).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Solved: In the sounds.json file in 1.8, each sound name was automatically prefixed with my domain. In 1.10.2, I need to explicitly include the domain in each name. Adding domains gave me my sounds.

 

New sounds.json file:

{
"fanPwrUp": {"category": "master","sounds": [{"name": "jrfinventions:fanPwrUp", "stream": false}]},
"fanWhirr": {"category": "master","sounds": [{"name": "jrfinventions:fanWhirr", "stream": false}]},
"fanChoke": {"category": "master","sounds": [{"name": "jrfinventions:fanChoke", "stream": false}]},
"fanPwrDn": {"category": "master","sounds": [{"name": "jrfinventions:fanPwrDn", "stream": false}]}
}

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.