prismarine-web-client icon indicating copy to clipboard operation
prismarine-web-client copied to clipboard

Sounds

Open AwesomestCode opened this issue 3 years ago • 5 comments

Add sounds (shouldn't be that difficult considering mineflayer has an event for hard coded sounds too)

AwesomestCode avatar Mar 02 '21 14:03 AwesomestCode

how to do it:

  1. check license

turns out a lot of MC sound effects are under CC0 Public Domain Dedication: https://www.minecraft.net/en-us/attribution/sound/ For C418’s music, he wants attribution and a link to his download page make sure that we filter only the sounds that we verified the licence

  1. retrieve from mojang the list of files at build time :
  • versions https://launchermeta.mojang.com/mc/game/version_manifest.json
  • file list https://launchermeta.mojang.com/v1/packages/436877ffaef948954053e1a78a366b8b7c204a91/1.16.5.json
  • asset index https://launchermeta.mojang.com/v1/packages/3a5d110a6ab102c7083bae4296d2de4b8fcf92eb/1.16.json

retrieve actual song directly in browser:

const aa = document.createElement('audio')
const ss = document.createElement('source')
ss.setAttribute('src', "http://resources.download.minecraft.net/e3/e367d1dfa1ce07374e0aeaecbfb1526142a0dcc1")
ss.setAttribute('type', 'audio/ogg')
aa.appendChild(ss)
aa.setAttribute('autoplay', "true")

bypass CORS

(reference https://github.com/PrismarineJS/node-minecraft-wrap/blob/master/lib/launcher_download.js )

rom1504 avatar Mar 24 '21 23:03 rom1504

we'd need in addition a "event => sound that should be played mapping" actually as said by AwesomestCode , we can use the mineflayer event for that

rom1504 avatar Mar 24 '21 23:03 rom1504

lot of id of sounds, would need the id => file name mapping

rom1504 avatar Mar 25 '21 00:03 rom1504

Most sounds would require audio spatialization (it's a nice link to have here btw), but it'd be impossible to avoid CORS policies if we use that

Moondarker avatar Mar 25 '21 05:03 Moondarker

Sound isn't playing inside the game because of this:

The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu

kf106 avatar Aug 12 '22 08:08 kf106