Jump to content

Recommended Posts

Posted

What I want to do seems so simple to me but I cannot get it to work.  All I want to do is override some of the default zombie sounds with a few of my own.  As usual I find tons of examples on how to create custom sounds and play them with playSound() or attach to a new custom entity.  But I want to override a default sound.  Can't this easily be done?

 

Example, in the vanilla sounds.json, it has this:

 

"entity.zombie.hurt": {
    "sounds": [
      "mob/zombie/hurt1",
      "mob/zombie/hurt2"
    ],
    "subtitle": "subtitles.entity.zombie.hurt"
  },

 

I have my sounds.json file in my mod folder (or outside, I've tried many things).  And my .ogg files of those names in a "sounds" subdirectory.

 

{
  "entity.zombie.hurt": {
    "sounds": [
      "dumbhurt1",
      "dumbhurt2"
    ],
    "subtitle": "subtitles.entity.zombie.hurt"
  }
}

 

The closest I get to anything working are these messages in the console:

19:18:52] [main/WARN] [minecraft/SoundHandler]: File minecraft:sounds/dumbhurt1.ogg does not exist, cannot add it to event testmod1:entity.zombie.hurt
[19:18:52] [main/WARN] [minecraft/SoundHandler]: File minecraft:sounds/dumbhurt2.ogg does not exist, cannot add it to event testmod1:entity.zombie.hurt

 

So I don't get it.  Can someone help me do this?

 

Posted (edited)

Ok, I figured it out.  I behaves like a resource pack though in that the new sounds are added to the default ones.  Is there a way to only get the new ones?

 

Edited by MrChoke
Posted (edited)
  On 9/21/2018 at 2:09 AM, Animefan8888 said:

I'm not sure what this means.

Expand  

What I mean is the default "zombie hurt" sound effects.  So I added two of my own but the two that come with the game also play.  I assume it chooses one of the four randomly each time it plays.

 

I have been deep diving into the forge stuff so much to figure this out.  Number 1) We are not allowed to remove entries from a ForgeRegistry (I even tried hacking it by using reflection but it just blew up later complaining about missing keys).  So I cannot remove the initial two sounds.  My next attempt now is a long shot and that is to somehow override the contents of the default ones with my own.  But I am lost in trying to understand how the SoundEvent is processed right now.

 

My overall opinion of Forge so far is this:

It is great for adding new content.  It is not good at all for overriding default behaviors.

Edited by MrChoke
Posted
  On 9/21/2018 at 3:45 AM, MrChoke said:

It is great for adding new content.  It is not good at all for overriding default behaviors.

Expand  

You'd be wrong. However, most registries prevent modification, the only one I know of that allows removal is the IRecipe registry. Also there used to be a substitution alias system for Items and Blocks, however I knew there where some problems with it. Not sure if they worked the kinks out or just threw it in the trash to be started again.

 

The solution to your problem is simple. Use this

/***
 * Raised when the SoundManager tries to play a normal sound.
 *
 * If you return null from this function it will prevent the sound from being played,
 * you can return a different entry if you want to change the sound being played.
 */
public class PlaySoundEvent extends SoundEvent 

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 9/21/2018 at 3:51 AM, Animefan8888 said:

You'd be wrong. However, most registries prevent modification, the only one I know of that allows removal is the IRecipe registry. Also there used to be a substitution alias system for Items and Blocks, however I knew there where some problems with it. Not sure if they worked the kinks out or just threw it in the trash to be started again.

 

The solution to your problem is simple. Use this

/***
 * Raised when the SoundManager tries to play a normal sound.
 *
 * If you return null from this function it will prevent the sound from being played,
 * you can return a different entry if you want to change the sound being played.
 */
public class PlaySoundEvent extends SoundEvent 

 

Expand  

 

So I was going to look into that after I give up on this.  However, is my understanding correct in that this is a way to override the sound being played right before it is actually played?  Meaning the initial load of the default sounds is still there.  And this override logic executes for every sound.  Seems like that is not an ideal approach...  Hence my forming opinion for Forge...  But I will admit, I am very new to it still.

Posted
  On 9/21/2018 at 3:55 AM, MrChoke said:

Seems like that is not an ideal approach...  Hence my forming opinion for Forge...  But I will admit, I am very new to it still.

Expand  

An extra if statement or two means nothing in the grand scale of an application.

  On 9/21/2018 at 3:55 AM, MrChoke said:

However, is my understanding correct in that this is a way to override the sound being played right before it is actually played?

Expand  

Yes that is what happens.

  On 9/21/2018 at 3:55 AM, MrChoke said:

Meaning the initial load of the default sounds is still there.

Expand  

If your intent is to replace the default sounds on load, then use your mod as a resource pack. Because it is one.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 9/21/2018 at 4:00 AM, Animefan8888 said:

If your intent is to replace the default sounds on load, then use your mod as a resource pack. Because it is one.

Expand  

I tried this at first and I couldn't get it to work.  I was able to create an actual resource pack and put it in run/resourcepacks.  That ended up working the exact same as what I am seeing now.  The new sounds were added to the existing ones.

 

If you aware of a way I can override them with a resource pack that would  be great.

Posted (edited)

UPDATE:  I got it to work!  I used reflection and changed the domain of the default sounds to my mod:

 

Collection<SoundEvent> coll = reg.getValuesCollection();
Iterator<SoundEvent> iter = coll.iterator();
while(iter.hasNext()) {
    SoundEvent se = iter.next();
    if(se.getSoundName().toString().equals("minecraft:entity.zombie.hurt")) {
        Field fld = SoundEvent.class.getDeclaredField("soundName");
        fld.setAccessible(true);
        ResourceLocation resLoc = (ResourceLocation) fld.get(se);
        Field fld2 = ResourceLocation.class.getDeclaredField("resourceDomain");
        fld2.setAccessible(true);
        fld2.set(resLoc, TestMod1.MODID);
    }
}

 

Edited by MrChoke
Posted
  On 9/21/2018 at 4:08 AM, MrChoke said:

UPDATE:  I got it to work!  I used reflection and changed the domain of the default sounds to my mod:

Expand  

Don't do that.

 

You do it exactly the same as you would for a resource pack. Put your sounds in assets.minecraft.sounds.folder.yourfile.ogg

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

There are a few things being discussed here.

 

First of all, a resource pack should be able to replace vanilla assets not just add to them. It is possible that sounds are behaving different/wrongly but I don't think it is expected.

 

Secondly, the events are perfectly suited for this. As mentioned above, there is no noticeable performance impact for checking for a sound. Just check for the sound and if it is the one you want to replace, play yours instead.


Here is a video with more details about adding sounds in modpacks - the first part is about custom sounds (played using commands), but later it talks about replacing existing ones.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
  On 9/21/2018 at 5:21 AM, jabelar said:

There are a few things being discussed here.

 

First of all, a resource pack should be able to replace vanilla assets not just add to them. It is possible that sounds are behaving different/wrongly but I don't think it is expected.

 

Secondly, the events are perfectly suited for this. As mentioned above, there is no noticeable performance impact for checking for a sound. Just check for the sound and if it is the one you want to replace, play yours instead.


Here is a video with more details about adding sounds in modpacks - the first part is about custom sounds (played using commands), but later it talks about replacing existing ones.

Expand  

I would love to use simply a resource pack.  I could not get it to work.  As simply a pack file I put in run/resourcepacks for my mod, it does work in that it appends my sounds to the default ones.  It does not overwrite.  When trying to add my sounds and a sounds.json file directly into the mod, I couldn't get anything to work.

 

Ok, I agree, adding an event for playSound will probably work and long term I will probably do that, fine.  But please, if you think simply using .ogg files and sounds.json can work, please let me know....  I think you will find at best you append sounds, not replace.

Posted
  On 9/22/2018 at 12:11 AM, MrChoke said:

I would love to use simply a resource pack.  I could not get it to work.  As simply a pack file I put in run/resourcepacks for my mod, it does work in that it appends my sounds to the default ones.  It does not overwrite.  When trying to add my sounds and a sounds.json file directly into the mod, I couldn't get anything to work.

 

Ok, I agree, adding an event for playSound will probably work and long term I will probably do that, fine.  But please, if you think simply using .ogg files and sounds.json can work, please let me know....  I think you will find at best you append sounds, not replace.

Expand  

 

  On 9/21/2018 at 4:29 AM, Animefan8888 said:

assets.minecraft.sounds.folder.yourfile.ogg

Expand  

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 9/22/2018 at 12:13 AM, Animefan8888 said:

 

Expand  

OMG, it was that easy!  Why did I not think to rename the exact zombie filenames in vanilla????

assets\minecraft\sounds\mob\zombie\hurt1.ogg   and hurt2.ogg

 

It works as a a pack and directly in my mod.  Thanks for your help. 

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

    • Update ColdSweat to the latest build: https://www.curseforge.com/minecraft/mc-mods/cold-sweat/files/6450271
    • Veuillez lire la FAQ (le lien est en haut de la page) et les journaux de publication tels que décrits ici. Cela aidera à déterminer ce qui se passe. Ce sont des forums anglais, j'ai utilisé un traducteur pour essayer de vous aider, j'espère que ça se retrouve bien.
    • I tried adding the Create (6.0.4) mod to my modpack which causes it to crash before it finishes loading. I tried removing the mod Cold Sweat because the error said it failed to load due to something in Create but when I removed it, it kept crashing; and I also tried downgrading Create, but nothing helped. I assume there's an incompatible mod that's causing Create to not load correctly, but I can't find it. launcher_log.txt: https://mclo.gs/kn5Qkk2 debug.log: https://mclo.gs/zIKoAaB crash report: https://mclo.gs/j86C10Y The part of debug.log that I think is the crash (after Create mod already loaded incorrectly): [02May2025 14:52:36.813] [Worker-ResourceReload-2/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/]: Exception caught during firing event: com/simibubi/create/content/redstone/displayLink/DisplayBehaviour Index: 3 Listeners: 0: NORMAL 1: net.minecraftforge.eventbus.EventBus$$Lambda$1770/0x00000008009bc8a0@70223c71 2: ASM: class com.momosoftworks.coldsweat.core.event.PotionRecipes register(Lnet/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent;)V 3: ASM: class com.momosoftworks.coldsweat.compat.CompatManager$ModEvents setupModEvents(Lnet/minecraftforge/fml/event/lifecycle/FMLCommonSetupEvent;)V java.lang.NoClassDefFoundError: com/simibubi/create/content/redstone/displayLink/DisplayBehaviour at TRANSFORMER/cold_sweat@2.3.12/com.momosoftworks.coldsweat.compat.CompatManager$ModEvents.setupModEvents(CompatManager.java:501) at TRANSFORMER/cold_sweat@2.3.12/com.momosoftworks.coldsweat.compat.__ModEvents_setupModEvents_FMLCommonSetupEvent.invoke(.dynamic) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) at LAYER PLUGIN/javafmllanguage@1.20.1-47.4.0/net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:121) at LAYER PLUGIN/fmlcore@1.20.1-47.4.0/net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$5(ModContainer.java:127) at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) Caused by: java.lang.ClassNotFoundException: com.simibubi.create.content.redstone.displayLink.DisplayBehaviour at cpw.mods.securejarhandler/cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:141) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ... 14 more [02May2025 14:52:36.972] [Worker-ResourceReload-2/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/LOADING]: Caught exception during event FMLCommonSetupEvent dispatch for modid cold_sweat java.lang.NoClassDefFoundError: com/simibubi/create/content/redstone/displayLink/DisplayBehaviour at com.momosoftworks.coldsweat.compat.CompatManager$ModEvents.setupModEvents(CompatManager.java:501) ~[ColdSweat-2.3.12.jar%23537!/:2.3.12] at com.momosoftworks.coldsweat.compat.__ModEvents_setupModEvents_FMLCommonSetupEvent.invoke(.dynamic) ~[ColdSweat-2.3.12.jar%23537!/:2.3.12] at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2387!/:?] at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2387!/:?] at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2387!/:?] at net.minecraftforge.fml.javafmlmod.FMLModContainer.acceptEvent(FMLModContainer.java:121) ~[javafmllanguage-1.20.1-47.4.0.jar%23784!/:?] at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$5(ModContainer.java:127) ~[fmlcore-1.20.1-47.4.0.jar%23783!/:?] at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?] at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[?:?] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?] at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?] at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?] at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?] at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?] Caused by: java.lang.ClassNotFoundException: com.simibubi.create.content.redstone.displayLink.DisplayBehaviour at cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:141) ~[securejarhandler-2.1.10.jar:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[?:?] ... 14 more
    • You would probably be better served looking for support where NeoForge support is given, I believe their discord server.
    • If you copy and paste the java commandline into the terminal, what happens? as in trying to launch it without using the .bat file.
  • Topics

×
×
  • Create New...

Important Information

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