Крашит при playSound в цикле

Версия Minecraft
1.12.2
API
Forge
57
3
7
Это норма?
 
Краш-лог
java.util.ConcurrentModificationException

at com.google.common.collect.HashBiMap$Itr.hasNext(HashBiMap.java:401)

at net.minecraft.client.audio.SoundManager.func_148605_d(SoundManager.java:252)

at net.minecraft.client.audio.SoundHandler.func_73660_a(SoundHandler.java:293)

at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1858)

at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1098)

at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398)

at net.minecraft.client.main.Main.main(SourceFile:123)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)



A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------


-- Head --

Thread: Client thread

Stacktrace:

at com.google.common.collect.HashBiMap$Itr.hasNext(HashBiMap.java:401)

at net.minecraft.client.audio.SoundManager.func_148605_d(SoundManager.java:252)

at net.minecraft.client.audio.SoundHandler.func_73660_a(SoundHandler.java:293)


-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityPlayerSP['Xewerdell'/0, l='MpServer', x=10.18, y=4.00, z=23.46]]

Chunk stats: MultiplayerChunkCache: 441, 441

Level seed: 0

Level generator: ID 01 - flat, ver 0. Features enabled: false

Level generator options:

Level spawn location: World: (8,4,8), Chunk: (at 8,0,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Level time: 107799 game time, 107799 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 1 total; [EntityPlayerSP['Xewerdell'/0, l='MpServer', x=10.18, y=4.00, z=23.46]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.func_72914_a(WorldClient.java:532)

at net.minecraft.client.Minecraft.func_71396_d(Minecraft.java:2741)

at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:427)

at net.minecraft.client.main.Main.main(SourceFile:123)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Краш-лог:
java.util.ConcurrentModificationException

    at com.google.common.collect.HashBiMap$Itr.hasNext(HashBiMap.java:401)

    at net.minecraft.client.audio.SoundManager.func_148605_d(SoundManager.java:252)

    at net.minecraft.client.audio.SoundHandler.func_73660_a(SoundHandler.java:293)

    at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1858)

    at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1098)

    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398)

    at net.minecraft.client.main.Main.main(SourceFile:123)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:497)

    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)



A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------


-- Head --

Thread: Client thread

Stacktrace:

    at com.google.common.collect.HashBiMap$Itr.hasNext(HashBiMap.java:401)

    at net.minecraft.client.audio.SoundManager.func_148605_d(SoundManager.java:252)

    at net.minecraft.client.audio.SoundHandler.func_73660_a(SoundHandler.java:293)


-- Affected level --

Details:

    Level name: MpServer

    All players: 1 total; [EntityPlayerSP['Xewerdell'/0, l='MpServer', x=10.18, y=4.00, z=23.46]]

    Chunk stats: MultiplayerChunkCache: 441, 441

    Level seed: 0

    Level generator: ID 01 - flat, ver 0. Features enabled: false

    Level generator options:

    Level spawn location: World: (8,4,8), Chunk: (at 8,0,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

    Level time: 107799 game time, 107799 day time

    Level dimension: 0

    Level storage version: 0x00000 - Unknown?

    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

    Forced entities: 1 total; [EntityPlayerSP['Xewerdell'/0, l='MpServer', x=10.18, y=4.00, z=23.46]]

    Retry entities: 0 total; []

    Server brand: fml,forge

    Server type: Integrated singleplayer server

Stacktrace:

    at net.minecraft.client.multiplayer.WorldClient.func_72914_a(WorldClient.java:532)

    at net.minecraft.client.Minecraft.func_71396_d(Minecraft.java:2741)

    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:427)

    at net.minecraft.client.main.Main.main(SourceFile:123)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:497)

    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
445
42
117
ConcurrentModificationException это когда ты пытаешься во время итерации по коллекции вставлять или убирать из нее значения.
(Что говорит о твоем уровне владения java)
Чтобы этого не было, делай итерацию по копии например (решений много, но это самое простое)
 
57
3
7
Чтобы этого не было, делай итерацию по копии
Можно было бы понять по моему уровню владения java, что я не знаю как делать итерации по копии. Всё-таки, как это сделать? можно конкретнее?
 
445
42
117
что я не знаю как делать итерации по копии
А собственно, что тебе мешает это узнать?
можно конкретнее?
ни стыда ни совести загуглить решение этой проблемы самостоятельно, хотя бы на StackOverflow:
        List<String> list = Arrays.asList("a", "b", "c");
        for(String item:list){
            list.add("e"); //ошибка
        }
        for(int i=0;i<list.size();i++){
            String item = list.get(i);
            list.remove(item); //правильно
        }
        for(String itemOfCopy:new ArrayList<>(list)){
            list.remove(itemOfCopy); //тоже пойдет
        }
 
Сверху