Jump to content

Recommended Posts

Posted (edited)

I've looked up multiple tutorials and at this point I'm just at a loss. In 1.8.9 this worked just fine but of course everything had to go and get flipped on its head soundwise in 1.11.2. ^^; I really don't understand much about how this whole sound system is functioning as a whole as it is, and for some reason none of my workspaces seem to generate with source code. I would love it if someone could help me out. Thanks!

 

Main Mod Class-

package slvr.LupineMod;

import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import slvr.LupineMod.proxy.*;
import net.minecraftforge.common.BiomeManager.BiomeType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.SpawnListEntry;
import net.minecraftforge.fml.common.Mod;
import slvr.LupineMod.entities.*;
import slvr.LupineMod.init.LupineSoundEvents;
import slvr.LupineMod.init.ModItems;
import slvr.LupineMod.init.SoundRegisterListener;
import slvr.LupineMod.proxy.CommonProxy;
import net.minecraftforge.common.BiomeDictionary;
import static net.minecraftforge.common.BiomeDictionary.Type;

@Mod(modid =Reference.MOD_ID, name =Reference.NAME, version =Reference.VERSION, acceptedMinecraftVersions =Reference.ACCEPTED_VERSIONS)
public class LupineMod {

	@Instance
	public static LupineMod instance;
	
	@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
	public static CommonProxy proxy;
	
	@EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		System.out.println("Pre Init");
		proxy.preInit();
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "africanWildDog"), EntityAfricanWildDog.class, "africanWildDog", 9, this, 50, 2, true, 0xdfc030, 0xb44b21);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "redWolf"), EntityRedWolf.class, "redWolf", 9, this, 50, 2, true, 0xf01f4b, 0x5d1b07);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "coyote"), EntityCoyote.class, "coyote", 9, this, 50, 2, true, 0xc37025, 0x484848);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "netherhound"), EntityNetherhound.class, "netherhound", 9, this, 50, 2, true, 0xcc6519, 0x2e2525);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "germanShepherd"), EntityGermanShepherd.class, "germanShepherd", 9, this, 50, 2, true, 0xd39147, 0x361d06);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "goldenRetriever"), EntityGoldenRetriever.class, "goldenRetriever", 9, this, 50, 2, true, 0xffdd53, 0xea9600);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "pitBull"), EntityPitBull.class, "pitBull", 9, this, 50, 2, true, 0x8eb2c9, 0xd2d2d2);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "dingo"), EntityDingo.class, "dingo", 9, this, 50, 2, true, 0xaa895a, 0xb6640c);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "arcticWolf"), EntityArcticWolf.class, "arcticWolf", 9, this, 50, 2, true, 0xe9fff8, 0x7f80bc);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "endWolf"), EntityEndWolf.class, "endWolf", 9, this, 50, 2, true, 0x360657, 0xe620e4);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "islandWolf"), EntityIslandWolf.class, "islandWolf", 9, this, 50, 2, true, 0x3188ff, 0x004141);
		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID, "newGuineaSingingDog"), EntityNewGuineaSingingDog.class, "newGuineaSingingDog", 9, this, 50, 2, true, 0xFF5721, 0xf7fffd);
		ModItems.init();
		ModItems.register();
		
	}	
	
	@EventHandler
	public void init(FMLInitializationEvent event)
	{
		System.out.println("Init");
		proxy.init();
		GameRegistry.addRecipe(new ItemStack(slvr.LupineMod.init.ModItems.golden_steak), new Object[] {"###", "#X#", "###", '#', Items.GOLD_INGOT, 'X', Items.COOKED_BEEF});
	}
	
	@EventHandler
	public void postInit(FMLPostInitializationEvent event)
	{
		System.out.println("Post Init");
		proxy.postInit();
		MinecraftForge.EVENT_BUS.register(new LupineEventHandler());
		MinecraftForge.EVENT_BUS.register(new LupineSoundEvents());
		SpawnListEntry african = new SpawnListEntry(EntityAfricanWildDog.class, 4, 2, 4);
		SpawnListEntry red = new SpawnListEntry(EntityRedWolf.class, 4, 2, 6);
		SpawnListEntry coyote = new SpawnListEntry(EntityCoyote.class, 1, 4, 4);
		SpawnListEntry netherhound = new SpawnListEntry(EntityNetherhound.class, 25, 1, 2);
		SpawnListEntry gs = new SpawnListEntry(EntityGermanShepherd.class, 1, 1, 1);
		SpawnListEntry golden = new SpawnListEntry(EntityGoldenRetriever.class, 1, 1, 1);
		SpawnListEntry pit = new SpawnListEntry(EntityPitBull.class, 1, 1, 1);
		SpawnListEntry dingo = new SpawnListEntry(EntityDingo.class, 2, 1, 1);
		SpawnListEntry arctic = new SpawnListEntry(EntityArcticWolf.class, 4, 4, 4);
		SpawnListEntry end = new SpawnListEntry(EntityEndWolf.class, 5, 4, 4);
		SpawnListEntry island = new SpawnListEntry(EntityIslandWolf.class, 8, 4, 4);
		SpawnListEntry singing = new SpawnListEntry(EntityNewGuineaSingingDog.class, 6, 4, 4);
		
		Object biomes[] = BiomeDictionary.getBiomes(Type.SANDY).toArray();
		for (int i = 0; i < biomes.length; i++){
			if(BiomeDictionary.hasType((Biome)biomes[i], Type.HOT)){
				((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(dingo);
				((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(african);
				((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(red);
			}
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(gs);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(pit);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(golden);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(coyote);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.SNOWY).toArray();
		for (int i = 0; i < biomes.length; i++){
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(arctic);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.PLAINS).toArray();
		for (int i = 0; i < biomes.length; i++){
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(african);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(gs);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(pit);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(golden);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(coyote);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.FOREST).toArray();
		for (int i = 0; i < biomes.length; i++){
			if(!BiomeDictionary.hasType((Biome)biomes[i], Type.SNOWY)){
				((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(red);
			}
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(gs);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(pit);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(golden);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(coyote);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.NETHER).toArray();
		for (int i = 0; i < biomes.length; i++){
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.MONSTER).add(netherhound);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.END).toArray();
		for (int i = 0; i < biomes.length; i++){
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.MONSTER).add(end);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.WASTELAND).toArray();
		for (int i = 0; i < biomes.length; i++){
			if(!BiomeDictionary.hasType((Biome)biomes[i], Type.SNOWY)){
			}
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(red);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(singing);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.MOUNTAIN).toArray();
		for (int i = 0; i < biomes.length; i++){
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(gs);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(pit);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(golden);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(coyote);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.MUSHROOM).toArray();
		for (int i = 0; i < biomes.length; i++){
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(gs);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(pit);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(golden);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(coyote);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(island);
			
		}
		
		biomes = BiomeDictionary.getBiomes(Type.JUNGLE).toArray();
		for (int i = 0; i < biomes.length; i++){
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(gs);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(pit);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(golden);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(coyote);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(singing);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.SWAMP).toArray();
		for (int i = 0; i < biomes.length; i++){
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(gs);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(pit);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(golden);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(coyote);
		}
		
		biomes = BiomeDictionary.getBiomes(Type.WATER).toArray();
		for (int i = 0; i < biomes.length; i++){
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(gs);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(pit);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(golden);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(island);
			((Biome)biomes[i]).getSpawnableList(EnumCreatureType.CREATURE).add(singing);
		}
	}

}

 

LupineSoundEvents under the package 'slvr.LupineMod.init' (and yes I stole some code from another modder's example for some help, heh, forgot to take the comment out):

package slvr.LupineMod.init;

	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 net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
	import slvr.LupineMod.Reference;

	public class LupineSoundEvents {

		public static final SoundEvent SINGER_HOWL = createSoundEvent("singer_howl");
		/**
		 * Create a {@link SoundEvent}.
		 *
		 * @param soundName The SoundEvent's name without the testmod3 prefix
		 * @return The SoundEvent
		 */
		private static SoundEvent createSoundEvent(String soundName) {
			final ResourceLocation soundID = new ResourceLocation(Reference.MOD_ID, soundName);
			return new SoundEvent(soundID).setRegistryName(soundID);
		}

		@Mod.EventBusSubscriber
		public static class RegistrationHandler {
			@SubscribeEvent
			public static void registerSoundEvents(RegistryEvent.Register<SoundEvent> event) {
				event.getRegistry().registerAll(
						SINGER_HOWL
				);
			}
		}
	}

sounds.json-

{
  "singer_howl": {
    "category" : "hostile",
    "sounds": [{
        "name": "slupinemod:mob/newguineasingingdog/singer_howl",
        "stream": true
      }
    ]
  }

EntityNewGuineaSingingDog-

package slvr.LupineMod.entities;

import net.minecraft.init.SoundEvents;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.world.World;
import slvr.LupineMod.Reference;
import slvr.LupineMod.init.LupineSoundEvents;

public class EntityNewGuineaSingingDog extends EntityVariedWolf{
	
	public EntityNewGuineaSingingDog(World dWorld){
		super(dWorld);
	}
	
	protected void entityInit(){
		super.entityInit();
		this.setWolfType(14);
	}
	
	protected SoundEvent getAmbientSound()
    {
		if (this.rand.nextInt(3) == 0)
				return LupineSoundEvents.SINGER_HOWL;
		else
			return this.isAngry() ? SoundEvents.ENTITY_WOLF_GROWL : (this.rand.nextInt(3) == 0 ? (this.isTamed() && ((Float)this.dataManager.get(DATA_HEALTH_ID)).floatValue() < 10.0F ? SoundEvents.ENTITY_WOLF_WHINE : SoundEvents.ENTITY_WOLF_PANT) : SoundEvents.ENTITY_WOLF_AMBIENT);
    }
}

 

The sound is stored in the filepath "src\main\resources\assets\slupinemod\sounds\mob\newguineasingingdog" as "singer_howl.ogg".

Edited by Starjay811
Posted

You have either posted incomplete sounds.json or it is invalid as it is missing } at the end.

Also I am pretty sure that last time I checked mc printed sound-related warnings and errors into console if something was wrong with the soundevent(sound can't be found/registered, invalid json, invalid ogg file, etc) so you should scan your log for any sound-related errors.

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.