关于
本项目是一个功能完备、开箱即用的资源包模板,旨在让为 Minecraft 添加自定义背景音乐和字幕变得极其简单。无论您是想完全替换原版配乐,还是仅用自己的喜爱曲目扩充音乐库,此模板都为您提供了所需的精确文件夹结构和代码基础。
它已针对各种游戏内场景进行了预配置,包括主菜单、常规玩法、特定生物群系(如森林和平原)、不同维度(下界),甚至包括Boss战(末影龙)。
文件夹结构与路径
为了让您的自定义音乐正常工作,所有文件必须放置在资源包中指定的确切位置:
- 音频文件: 所有自定义的
.ogg 音乐文件需放入 assets/minecraft/sounds/music/ 目录。
sounds.json: 这个核心配置文件直接位于 assets/minecraft/ 目录中。
- 字幕:
lang 文件夹(包含用于文本的 en_us.json 文件)也位于 assets/minecraft/ 目录内。
工作原理
添加自定义音乐需要特定的 JSON 文件来告知 Minecraft 何时播放音轨以及在屏幕上显示什么内容。以下是此模板中包含的各个组件的详细分解。
sounds.json 文件
该文件充当音频包的“大脑”。它将游戏内事件与您的音频文件链接起来,并告诉引擎如何处理它们。
- 事件触发器(例如
music.menu): 这定义了游戏应该播放音乐的确切情境。例如,music.menu 在标题界面触发,而 music.dragon 在末影龙 Boss 战期间触发。
replace: 这是一个关键设置,决定了您的音乐如何与原游戏文件交互。
- 设置为
false:您的自定义音轨将被添加到现有的原版 Minecraft 音乐池中。游戏将在原声带和您的音乐之间随机选择。
- 设置为
true:游戏将完全忽略此特定事件的默认 Minecraft 音乐,仅播放您的自定义音轨。
name: 指向自定义音轨的确切文件路径,从 sounds/ 文件夹内部开始。此处无需包含文件扩展名。
stream: 对于背景长音频文件,此项应始终设置为 true。它告诉游戏直接从硬盘流式传输音频,而不是将整个歌曲加载到 RAM 中,从而防止严重的性能下降和内存泄漏。
weight: 这决定了某音轨相对于同一类别中其他音轨的播放概率。如果音轨 A 的权重为 2,音轨 B 的权重为 1,则游戏选择音轨 A 的可能性是音轨 B 的两倍。
en_us.json 文件(语言与字幕)
位于 lang 文件夹中,此文件将您的音频轨道连接到游戏内的字幕系统。
当玩家在辅助功能设置中启用字幕时,游戏会查看此文件以知道应在屏幕右下角显示什么文本。您只需将音频事件的名称映射到您希望显示的文本上,例如艺术家姓名和歌曲名称。
重要提示
在修改此模板并添加自己的音乐时,您必须严格遵守 Minecraft 引擎的规则。未能遵循这些限制将导致资源包无法加载或音乐完全不播放。
- 仅限文件格式: Minecraft 仅读取
.ogg 音频文件。不能使用 .mp3、.wav 或 .m4a 文件。在将其放入文件夹之前,必须将音乐转换为 .ogg 格式。
- 严格的命名约定: 每个文件名和文件夹名必须严格小写。带有大写字母的文件将无法被游戏识别。
- 无空格: 切勿在文件名或文件夹中使用空格。请使用下划线 (
_) 来分隔单词(例如:my_custom_song.ogg)。
- 有效字符: 仅使用小写字母 (
a-z)、数字 (0-9)、下划线 (_) 和连字符 (-)。避免使用任何特殊字符。
- JSON 语法: JSON 文件非常敏感。缺少一个逗号、列表末尾多余的逗号或缺少引号都会破坏整个文件。编辑后请务必仔细检查语法。
About
This project is a comprehensive, ready-to-use Resource Pack Template designed to make adding custom background music and subtitles to Minecraft incredibly straightforward. Whether you want to completely replace the vanilla soundtrack or simply expand it with your own favorite tracks, this template provides the exact folder structure and code foundations you need.
It comes pre-configured for various in-game situations, including the main menu, normal gameplay, specific biomes (like forests and plains), different dimensions (the Nether), and even for the boss fight (Ender Dragon).
Folder Structure & Paths
For your custom music to work, all files must be placed in their exact designated locations within the resource pack:
- Audio Files: All your custom
.ogg music files need to go into the assets/minecraft/sounds/music/ directory.
sounds.json: This core configuration file is located directly in the assets/minecraft/ directory.
- Subtitles: The
lang folder (which contains the en_us.json file for your text) is also found inside the assets/minecraft/ directory.
How it works
Adding custom music requires specific JSON files to tell Minecraft when to play a track and what to display on the screen. Here is a detailed breakdown of the components included in this template.
The sounds.json File
This file acts as the brain of your audio pack. It links in-game events to your audio files and tells the engine how to handle them.
- The Event Trigger (e.g.,
music.menu): This defines the exact situation when the game should play the music. For example, music.menu triggers on the title screen, while music.dragon triggers during the Ender Dragon boss fight.
replace: This is a crucial setting that determines how your music interacts with the original game files.
- Set to
false: Your custom tracks will be added to the pool of existing vanilla Minecraft music. The game will randomly choose between the original soundtrack and yours.
- Set to
true: The game will completely ignore the default Minecraft music for this specific event and only play your custom tracks.
name: The exact file path to your custom track, starting inside the sounds/ folder. You do not include the file extension here.
stream: This should always be set to true for long audio files like background music. It tells the game to stream the audio directly from your hard drive rather than loading the entire song into the RAM, preventing massive performance drops and memory leaks.
weight: This determines the probability of a track playing compared to others in the same category. If Track A has a weight of 2 and Track B has a weight of 1, Track A is twice as likely to be chosen by the game.
The en_us.json File (Language & Subtitles)
Located in the lang folder, this file connects your audio tracks to the in-game subtitle system.
When a player has subtitles enabled in their accessibility settings, the game looks at this file to know what text to display in the bottom right corner of the screen. You simply map the exact name of your audio event to the text you want to display, such as the artist and the name of the song.
Important
When modifying this template and adding your own music, you must adhere strictly to Minecraft's engine rules. Failing to follow these constraints will result in the resource pack failing to load or the music not playing at all.
- File Format Only: Minecraft exclusively reads
.ogg audio files. You cannot use .mp3, .wav, or .m4a files. You must convert your music to .ogg before placing it in the folder.
- Strict Naming Convention: Every single file name and folder name must be strictly lowercase. The game will not recognize files with capital letters.
- No Spaces: Never use spaces in your file names or folders. Use underscores (
_) instead to separate words (for example: my_custom_song.ogg).
- Valid Characters: Only use lowercase letters (
a-z), numbers (0-9), underscores (_), and hyphens (-). Avoid any special characters.
- JSON Syntax: JSON files are extremely sensitive. A single missing comma, an extra comma at the end of a list, or a missing quotation mark will break the entire file. Always double-check your syntax after editing.
评论 0
登录后参与评分
还没有评论,来抢沙发吧