Jump to content

[1.11.2]Sound loading


Smyler

Recommended Posts

I'm adding a disc to the game, and it works perfectly fine, with one problem. When playing the disc for the first time after the resources were loaded (with the game or F3+T), the game lags for a few seconds, just like if the audio file was just loaded only at that moment. Do you have any idea where the problem could be? Here are my items and sounds registering classes:

 

RandomItems.java

package smyler.random.item;

import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import smyler.random.sound.RandomSounds;

@Mod.EventBusSubscriber
public class RandomItems {

	// ==== The items ====
	public static final Item RECORD_ZELDA_STORM = new RandomRecordItem("zelda_storm", RandomSounds.SONG_OF_THE_STROM_ZELDA).setUnlocalizedName("record_storm_zelda").setRegistryName("record_storm_zelda");
	// ==== End of items ====
	
	
	@SubscribeEvent
	public static void registerItems(RegistryEvent.Register<Item> event){
		event.getRegistry().register(RECORD_ZELDA_STORM);
		
	}
	
	@SubscribeEvent
	public static void registerModels(ModelRegistryEvent event){
		registerItemModel(RECORD_ZELDA_STORM);
	}
	
	
	private static void registerItemModel(Item item){
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
	}
	
}

 

RandomSounds.java

package smyler.random.sound;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import smyler.random.RandomMod;

@Mod.EventBusSubscriber
public class RandomSounds {
	
	// ==== The sounds ====
	public static SoundEvent SONG_OF_THE_STROM_ZELDA = new SoundEvent(new ResourceLocation(RandomMod.MOD_ID, "songofstormzelda")).setRegistryName("songofstormzelda");
	// ==== End of sounds ====
	
	@SubscribeEvent
	public static void registerSounds(RegistryEvent.Register<SoundEvent> event){
		event.getRegistry().register(RandomSounds.SONG_OF_THE_STROM_ZELDA);
	}
	
	
}

 

Thanks in advance.

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.