leduyquang753 Posted April 22, 2018 Posted April 22, 2018 (edited) So I am making a Forge 1.12 mod that can play note block song (.nbs) files. But when I tried to play note block sounds to the client: String name = Instrument.getInstrument(note.getInstrument()); // One of "block.note.harp", "block.note.bass", "block.note.basedrum",... float pitch = (float)Math.pow(2.0D, (double)(note.getKey - 45) / 12.0D); // Ranges from 1 to 2. Minecraft.getMinecraft().player.playSound(new SoundEvent(new ResourceLocation("minecraft", name)), 1F, pitch); it throws ConcurrentModificationException: [8 | 22/4/2018 14h07:55] [main/FATAL]: Unreported exception thrown! java.util.ConcurrentModificationException: null at com.google.common.collect.HashBiMap$Itr.hasNext(HashBiMap.java:401) ~[guava-21.0.jar:?] at net.minecraft.client.audio.SoundManager.updateAllSounds(SoundManager.java:272) ~[SoundManager.class:?] at net.minecraft.client.audio.SoundHandler.update(SoundHandler.java:297) ~[SoundHandler.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1983) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1186) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:441) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:25) [start/:?] Another thing to note is the mod plays multiple sounds at once. Is this the right way to play multiple sounds in Forge? Or is there another way to handle this? Edited April 24, 2018 by leduyquang753 Solved thanks to @diesieben07. Quote
leduyquang753 Posted April 22, 2018 Author Posted April 22, 2018 So I need to do the stuff in SidedProxy to prevent this? Quote
jabelar Posted April 22, 2018 Posted April 22, 2018 On 4/22/2018 at 3:26 PM, leduyquang753 said: So I need to do the stuff in SidedProxy to prevent this? Expand Yes Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
leduyquang753 Posted April 23, 2018 Author Posted April 23, 2018 So when I called EntityPlayerSP#playSound, it was run on both logical sides? Quote
Cadiboo Posted April 23, 2018 Posted April 23, 2018 On 4/23/2018 at 5:10 AM, leduyquang753 said: So when I called EntityPlayerSP#playSound, it was run on both logical sides? Expand pretty much, you should be able to just surround your code with an world.isRemote check Quote About Me Reveal hidden contents My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
leduyquang753 Posted April 23, 2018 Author Posted April 23, 2018 I tried surrounding my code with World#isRemote on both Minecraft.player.world and Minecraft.world but it still crashes... Super confused. Quote
Draco18s Posted April 23, 2018 Posted April 23, 2018 On 4/23/2018 at 5:35 AM, leduyquang753 said: I tried surrounding my code with World#isRemote on both Minecraft.player.world and Minecraft.world but it still crashes... Super confused. Expand Both of those are client side only. As soon as the server tries to load the Minecraft class, it fails to find it. You're already being passed a world object, somewhere. Post more of your code. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
leduyquang753 Posted April 23, 2018 Author Posted April 23, 2018 Here is the whole source with a slightly modified version of xxmicloxx's Note Block API. NBS-Player.zipFetching info... The classes worth seeing are cf.leduyquang753.nbsplayer.Main, com.xxmicloxx.NoteBlockAPI.SongPlayer / NoteBlockSongPlayer / SongPlayer, the class NoteBlockSongPlayer is the class that is making errors... Quote
Draco18s Posted April 23, 2018 Posted April 23, 2018 I am not downloading a zip file. Post your code on GitHub. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
leduyquang753 Posted April 23, 2018 Author Posted April 23, 2018 Were you serious? You won't read my code just because it's in a ZIP? Quote
leduyquang753 Posted April 23, 2018 Author Posted April 23, 2018 (edited) Uhhh here is its repo: https://github.com/leduyquang753/NBS-Player Somehow my router reset thrice while I was doing this... :((( Edited April 23, 2018 by leduyquang753 Quote
Draco18s Posted April 23, 2018 Posted April 23, 2018 https://github.com/leduyquang753/NBS-Player/blob/master/src/main/java/com/xxmicloxx/NoteBlockAPI/SongPlayer.java#L85 You're creating your own threads? Yeah, that won't create problems, ever. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Recommended Posts
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.