Jukebox#stopPlaying() does not always stop the disc from playing.
Expected behavior
Upon calling this method, the jukebox that is currently playing a song should stop.
Observed/Actual behavior
The music continues to play sometimes, for some players.
Steps/models to reproduce
- On PlayerInteractEvent.
- if the block is a jukebox, and you are putting in a disc.
- Create a 1-2 tick BukkitRunnable
- inside the runnable, get the Jukebox state and call jukebox#stopPlaying.
Plugin and Datapack List
None, besides the plugin used to test it
Paper version
[17:03:22 INFO]: Checking version, please wait... [17:03:23 INFO]: This server is running Paper version git-Paper-515 (MC: 1.19.4) (Implementing API version 1.19.4-R0.1-SNAPSHOT) (Git: beed22d) You are running the latest version Previous version: git-Paper-386 (MC: 1.19.3)
Other
No response
I'm just guessing here, but I bet I know what causes this. If a player is in range of the jukebox when it starts playing (within 64 blocks), it gets told to start playing the sound. But if they move out of that range when the stop is called, the client isn't told to stop, so if they go back near to the jukebox, it is still playing.
I'm guessing this also affects vanilla since you can also do these things without needing the API, just by starting and stopping the jukebox.
It boils down to the jukebox not tracking what players are hearing the current song. It just updates nearby players, and nearby players can change.
I'm gonna wait a week on this issue if the reporter or anyone else chimes in with something, but this really isn't fixable without trying to track on the server what clients are listening to what music which is very hard since you can change it with a simple packet.
Just found this actually, which while not exactly this issue, does speak, I think, to mojang's lack of interest in addressing the desync of jukeboxes and players. https://bugs.mojang.com/browse/MC-10436
Closing this, it has been 2 weeks, there is not much too do given how poorly jukeboxes are synced with the client.