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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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