IllegalArgumentException
elifoster opened this issue ยท 2 comments
When getting pinged:
Caused by: java.lang.IllegalArgumentException: value already present: santa.ping.PingSound@17e0fabe
at com.google.common.collect.HashBiMap.put(HashBiMap.java:238) ~[guava-17.0.jar:?]
at com.google.common.collect.HashBiMap.put(HashBiMap.java:215) ~[guava-17.0.jar:?]
at net.minecraft.client.audio.SoundManager.playSound(SoundManager.java:439) ~[SoundManager.class:?]
at net.minecraft.client.audio.SoundHandler.playSound(SoundHandler.java:233) ~[SoundHandler.class:?]
at santa.ping.PingEventHandler.playSoundSendMessage(PingEventHandler.java:38) ~[PingEventHandler.class:?]
at santa.ping.PingEventHandler.onChatMessage(PingEventHandler.java:24) ~[PingEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_PingEventHandler_onChatMessage_ClientChatReceivedEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:49) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) ~[EventBus.class:?]
at net.minecraftforge.event.ForgeEventFactory.onClientChat(ForgeEventFactory.java:267) ~[ForgeEventFactory.class:?]
at net.minecraft.client.network.NetHandlerPlayClient.handleChat(NetHandlerPlayClient.java:875) ~[NetHandlerPlayClient.class:?]
at net.minecraft.network.play.server.SPacketChat.processPacket(SPacketChat.java:54) ~[SPacketChat.class:?]
at net.minecraft.network.play.server.SPacketChat.processPacket(SPacketChat.java:11) ~[SPacketChat.class:?]
at net.minecraft.nPacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_60]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_60]
at net.minecraft.util.Util.runTask(Util.java:23) ~[Util.class:?]
I believe the answer is to first check if the sound is already playing (which may inadvertently fix #4 as well), then use a new PingSound
object.
if (!Minecraft.getMinecraft().getSoundHandler().isSoundPlaying(sound)) {
sound = new PingSound();
Minecraft.getMinecraft().getSoundHandler().playSound(sound);