在 Minecraft 中播放你自己的音乐,并确保所有玩家都保持在歌曲的同一秒。使用声音事件、资源包中的 ogg 文件、指向 ogg/mp3/wav 文件的直接链接或任意链接:YouTube、SoundCloud、视频等。
命令:
/soundtrack <play/stop/list>
/soundtrack play <id> resource <sound> [volume] [fadeinTicks] [fadeoutTicks] [loop] [fadeloop] [pitch] [category]
/soundtrack play <id> url <link> [volume] ...
/soundtrack stop <id/all> [fadeoutTicks]
选择 resource,标签补全会显示你的 soundtracks 文件夹中的文件以及模组和原版的声音。选择 url 并粘贴链接。不需要引号。
Soundtracks 文件夹
将你的 .ogg 文件放入资源包内的 assets/<namespace>/soundtracks/ 中,无需 sounds.json。按 F3+T,它们会在标签补全中显示为 namespace:soundtracks/song.ogg。
链接
粘贴指向 ogg、mp3 或 wav 文件的直接链接即可播放。每个玩家只需下载一次,并将其缓存。
也可以链接到 YouTube 或 SoundCloud 等页面以及视频(mp4、webm...)。首次使用时,模组会从官方页面静默下载其所需的免费工具(yt-dlp、deno 和 ffmpeg),无需手动安装。
玩家可以在 config/soundtrackplayer.json 中关闭链接功能。
始终同步
如果某人迟到加入、离开后重新加入,或重载资源包,歌曲会从与其他人相同的秒数开始播放。循环也是如此。F3+T 和暂停菜单不再切断音乐。
淡入、循环和类别
- fadein / fadeout: 以刻(ticks)为单位(20 = 1 秒)
- 带淡出的停止: stop 中的 fadeout 会覆盖歌曲开始时使用的 fadeout。留空则使用原始设置
- fadeloop: true 会在每次循环时淡入淡出,false 仅在第一次启动和停止时淡入淡出
- pitch: 0.5 到 2.0,同时改变速度
- category: 默认为 SOUNDTRACKS,也可以是任何原版类别如 MUSIC、AMBIENT 或 RECORDS,以跟随相应的音量滑块
使用相同的 id 和声音再次运行命令会实时更改音量、音调或淡入淡出效果,歌曲会继续从当前位置播放。你自定义的 soundtracks 在离开和进入世界后也会继续播放。
Soundtracks 滑块
“音乐与声音”设置中新增了一个“Soundtracks”滑块,用于控制 SOUNDTRACKS 类别下所有音效的音量。已翻译成 20 种语言。
服务器
- Paper/Spigot: 使用 SoundtrackplayerPLUGIN 插件:
/soundtrackplugin play <@a/player> <id> <url/resource> <link/sound> ... 和 /soundtrackplugin stop <@a/player> <id/all> [fadeoutTicks]。它会保存所有状态,因此后来加入的玩家会在同一时间听到相同的内容。标签补全会显示当前正在播放的 id 以及你的玩家拥有的自定义声音。
- 单人游戏、Fabric、NeoForge 和 Forge 服务器: 使用你自己模组中的 API。
API
服务端(支持所有加载器,包括单人游戏):
Soundtrack boss = Soundtrack.builder("boss", "soundtrackplayer:soundtracks/boss.ogg")
.volume(0.8f).fadeIn(40).fadeOut(60).loop(true).build();
SoundtrackPlayerAPI.playForAll(server, boss);
SoundtrackPlayerAPI.play(player, boss);
SoundtrackPlayerAPI.stopForAll(server, "boss", 100);
客户端:使用 SoundtrackClientAPI 播放本地音轨、停止它们、读取或更改 Soundtracks 音量,并监听音轨的开始和停止。
插件:SoundtrackPlayerAPI.get() 提供与 Paper 插件相同的方法,以及当拥有该模组的玩家加入时触发的 SoundtrackClientReadyEvent。
源代码和文档:
适用于 Fabric 1.20.1 - 26.2、NeoForge 1.20.1 - 26.2 和 Forge 1.20.1 / 1.20.4。
Play your own music in Minecraft and keep everyone on the same second of the song. Use sound events, ogg files from a resource pack, a direct link to an ogg, mp3 or wav file, or any link: YouTube, SoundCloud, videos...
Commands:
/soundtrack <play/stop/list>
/soundtrack play <id> resource <sound> [volume] [fadeinTicks] [fadeoutTicks] [loop] [fadeloop] [pitch] [category]
/soundtrack play <id> url [volume] ...
/soundtrack stop <id/all> [fadeoutTicks]
Pick resource and the tab completion shows your soundtracks folder files, modded and vanilla sounds. Pick url and paste the link. No quotes needed.
Soundtracks folder
Put your .ogg files in assets/<namespace>/soundtracks/ inside a resource pack, no sounds.json needed. Press F3+T and they show up in the tab completion as namespace:soundtracks/song.ogg.
Links
Paste a direct link to an ogg, mp3 or wav file and it plays. Each player downloads it once and keeps it cached.
Links to pages like YouTube or SoundCloud and to videos (mp4, webm...) work too. The first time you use one, the mod quietly downloads the free tools it needs (yt-dlp, deno and ffmpeg) from their official pages, nothing to install by hand.
Players can turn links off in config/soundtrackplayer.json.
Always in sync
If someone joins late, leaves and comes back, or reloads their resource packs, the song picks up at the same second as everyone else. Loops too. F3+T and the pause menu don't cut the music anymore.
Fades, loops and categories
- fadein / fadeout: in ticks (20 = 1 second)
- stop with a fade: the fadeout in stop overrides the one the song was started with. Leave it empty and it uses the original one
- fadeloop: true fades every lap of a loop in and out, false only fades the first start and the stop
- pitch: 0.5 to 2.0, it changes the speed too
- category: SOUNDTRACKS by default, or any vanilla one like MUSIC, AMBIENT or RECORDS so it follows that slider
Running the same command again with the same id and sound changes the volume, pitch or fades live, the song keeps going from where it was. Your own soundtracks also keep playing after leaving and joining a world.
Soundtracks slider
There's a new "Soundtracks" slider in Music & Sounds to control the volume of every soundtrack in the SOUNDTRACKS category. It's translated to 20 languages.
Servers
- Paper/Spigot: use the SoundtrackplayerPLUGIN plugin:
/soundtrackplugin play <@a/player> <id> <url/resource> <link/sound> ... and /soundtrackplugin stop <@a/player> <id/all> [fadeoutTicks]. It saves everything, so players that join later hear the same thing at the same time. Tab completion shows the ids that are actually playing and the custom sounds your players have.
- Singleplayer, Fabric, NeoForge and Forge servers: use the API from your own mod.
API
Server side (every loader, singleplayer included):
Soundtrack boss = Soundtrack.builder("boss", "soundtrackplayer:soundtracks/boss.ogg")
.volume(0.8f).fadeIn(40).fadeOut(60).loop(true).build();
SoundtrackPlayerAPI.playForAll(server, boss);
SoundtrackPlayerAPI.play(player, boss);
SoundtrackPlayerAPI.stopForAll(server, "boss", 100);
Client side: SoundtrackClientAPI to play local tracks, stop them, read or change the Soundtracks volume and listen to tracks starting and stopping.
Plugin: SoundtrackPlayerAPI.get() with the same methods for Paper plugins, plus SoundtrackClientReadyEvent when a player with the mod joins.
Source code and docs:
Available for Fabric 1.20.1 - 26.2, NeoForge 1.20.1 - 26.2 and Forge 1.20.1 / 1.20.4.
评论 0
登录后参与评分
还没有评论,来抢沙发吧