Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.7.10][Solved]Sound start from a coordinate and stopping it, server-wide

Featured Replies

Posted

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

  • 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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.