Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.