Jump to content

Recommended Posts

Posted (edited)

It seems to be a cart before the horse issue: items are registered before sounds so the record has no sound attached to it. I can get around this by using a static initialiser, but I'm looking for other options. I also have a similar issue using custom spawn eggs: the entity type is a null. In this case I'm using spawn eggs directly so they can be placed in my mod's creative tab.

 

@ObjectHolder(References.MODID)
public class JungleSounds {

	public static SoundEvent RECORD_SURVIVORS;
	public static SoundEvent SAUROHN_DEATH;
	public static SoundEvent SAUROHN_HURT;
	public static SoundEvent SAUROHN_LAUGH;
	public static SoundEvent SAUROHN_MOCK;
	public static SoundEvent SAUROHN_TALK;
	
	
	public static void init() //Not currently called, doesn't work if used from pre-init
	{
		/*RECORD_SURVIVORS = registerSound("records.eyetyrant");
		
		SAUROHN_DEATH = registerSound("saurohn.saurohn_death");
		SAUROHN_HURT = registerSound("saurohn.saurohn_hurt");
		SAUROHN_LAUGH = registerSound("saurohn.saurohn_laugh");
		SAUROHN_MOCK = registerSound("saurohn.saurohn_mock");
		SAUROHN_TALK = registerSound("saurohn.saurohn_talk");*/
	}

	private static SoundEvent registerSound(String soundName) 
	{
	    //soundID;//SoundEvent soundID = IRegistry.field_212633_v.func_212608_b(new ResourceLocation(soundName));
		final ResourceLocation soundID = new ResourceLocation(References.MODID, soundName);
		return new SoundEvent(soundID).setRegistryName(soundID);
	}
	
	@EventBusSubscriber(modid = References.MODID, bus = EventBusSubscriber.Bus.MOD)
	public static class RegistrationHandlerSound 
	{
		@SubscribeEvent
		public static void registerSoundEvents(final RegistryEvent.Register<SoundEvent> event) 
		{
			init();
			event.getRegistry().registerAll
			(
					RECORD_SURVIVORS = registerSound("records.eyetyrant"),
					
					SAUROHN_DEATH = registerSound("saurohn.saurohn_death"),
					SAUROHN_HURT = registerSound("saurohn.saurohn_hurt"),
					SAUROHN_LAUGH = registerSound("saurohn.saurohn_laugh"),
					SAUROHN_MOCK = registerSound("saurohn.saurohn_mock"),
					SAUROHN_TALK = registerSound("saurohn.saurohn_talk")
					
			);
		}
	}

 

Edited by salvestrom
Posted

I ended up initialising my SoundEvents in a method called from RegistryEvent.Register<Item> and storing them in a temporary Map until they're registered in RegistryEvent.Register<SoundEvent>.

 

You can see this here

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.

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.