Posted April 10, 20169 yr To be more clear, I'm trying to make a playsound alternative that is also able to stop the sound from a coordinate (if it has been started by the same command) and loop it. I managed to make the start/stop thing for now, but it only on cient side. Any help on how to make it work for other players? Code of the play sound part: In the command: Main.proxy.playSoundFromCoords(sound, x, y, z, vol, pitch); In the client proxy: private final Map<ChunkCoordinates, ISound> mapSoundPositions = new HashMap<ChunkCoordinates, ISound>(); @Override public void playSoundFromCoords(String sound, int x, int y, int z, float vol, float pitch) { ChunkCoordinates chunkcoordinates = new ChunkCoordinates(x, y, z); ISound isound = mapSoundPositions.get(chunkcoordinates); if (isound != null) { System.out.println("Sound already playing at " + x + "/" + y + "/" + z + "; stopping sound"); Minecraft.getMinecraft().getSoundHandler().stopSound(isound); mapSoundPositions.remove(chunkcoordinates); } if (sound != null) { System.out.println("Playing sound at " + x + "/" + y + "/" + z + ": " + sound); ResourceLocation resource = new ResourceLocation(sound); PositionedSoundRecord psr = new PositionedSoundRecord(resource, vol, pitch, x, y, z); mapSoundPositions.put(chunkcoordinates, psr); Minecraft.getMinecraft().getSoundHandler().playSound(psr); } } Edit: forgot to say that the code mostly comes from this thread:http://www.minecraftforge.net/forum/index.php?topic=24230.0
April 10, 20169 yr Author Realized how to, I have to run that code after sending a packet to the client.
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.