Minecraft: Java Edition 26.3 rewritten from scratch in Rust, checked against vanilla with 281 differential harnesses. Get it with the Horizon launcher.
Rust differential-testinggame-enginegamedevlinuxminecraftminecraft-javareimplementationrustvoxelvulkanwgpu
Declare native-mod microphone usage in the macOS game bundle
wxund00ee9283065b
diff --git a/launcher/lang/de.json b/launcher/lang/de.jsonindex f96037807..6bc5383bf 100644--- a/launcher/lang/de.json+++ b/launcher/lang/de.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "Exportiere den Server außerhalb der vom Launcher verwalteten Ordner.","{path} is not a folder to build into.": "{path} ist kein Ordner, in den gebaut wird.","Could not copy the build: {error}": "Build konnte nicht kopiert werden: {error}",- "Could not move the build to {path}: {error}": "Build konnte nicht nach {path} verschoben werden: {error}"+ "Could not move the build to {path}: {error}": "Build konnte nicht nach {path} verschoben werden: {error}",+ "Native mods can use your microphone for voice chat when you enable it.": "Native Mods können dein Mikrofon für Sprachchat verwenden, wenn du es aktivierst."}diff --git a/launcher/lang/es.json b/launcher/lang/es.jsonindex acfb2b337..cc639b7a6 100644--- a/launcher/lang/es.json+++ b/launcher/lang/es.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "Exporte el servidor fuera de las carpetas administradas por el launcher.","{path} is not a folder to build into.": "{path} no es una carpeta para compilar.","Could not copy the build: {error}": "No se pudo copiar la compilación: {error}",- "Could not move the build to {path}: {error}": "No se pudo mover la compilación a {path}: {error}"+ "Could not move the build to {path}: {error}": "No se pudo mover la compilación a {path}: {error}",+ "Native mods can use your microphone for voice chat when you enable it.": "Los mods nativos pueden usar tu micrófono para el chat de voz cuando lo actives."}diff --git a/launcher/lang/fr.json b/launcher/lang/fr.jsonindex 4e68dfe53..7f4ffc221 100644--- a/launcher/lang/fr.json+++ b/launcher/lang/fr.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "Exportez le serveur en dehors des dossiers gérés par le launcher.","{path} is not a folder to build into.": "{path} n'est pas un dossier dans lequel compiler.","Could not copy the build: {error}": "Impossible de copier la compilation : {error}",- "Could not move the build to {path}: {error}": "Impossible de déplacer la compilation vers {path} : {error}"+ "Could not move the build to {path}: {error}": "Impossible de déplacer la compilation vers {path} : {error}",+ "Native mods can use your microphone for voice chat when you enable it.": "Les mods natifs peuvent utiliser votre micro pour le chat vocal lorsque vous l'activez."}diff --git a/launcher/lang/ja.json b/launcher/lang/ja.jsonindex 5009a6859..70e20869f 100644--- a/launcher/lang/ja.json+++ b/launcher/lang/ja.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "ランチャーが管理するフォルダーの外にサーバーをエクスポートしてください。","{path} is not a folder to build into.": "{path} はビルド先のフォルダーではありません。","Could not copy the build: {error}": "ビルドをコピーできませんでした: {error}",- "Could not move the build to {path}: {error}": "ビルドを {path} に移動できませんでした: {error}"+ "Could not move the build to {path}: {error}": "ビルドを {path} に移動できませんでした: {error}",+ "Native mods can use your microphone for voice chat when you enable it.": "ネイティブモッドは、有効にした場合、音声チャットにマイクを使用できます。"}diff --git a/launcher/lang/pl.json b/launcher/lang/pl.jsonindex b1f4ff6dd..abec72a57 100644--- a/launcher/lang/pl.json+++ b/launcher/lang/pl.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "Eksportuj serwer poza foldery zarządzane przez launcher.","{path} is not a folder to build into.": "{path} nie jest folderem do kompilacji.","Could not copy the build: {error}": "Nie można skopiować kompilacji: {error}",- "Could not move the build to {path}: {error}": "Nie można przenieść kompilacji do {path}: {error}"+ "Could not move the build to {path}: {error}": "Nie można przenieść kompilacji do {path}: {error}",+ "Native mods can use your microphone for voice chat when you enable it.": "Native mody mogą użyć Twojego mikrofonu do czatu głosowego, gdy to włączysz."}diff --git a/launcher/lang/pt-br.json b/launcher/lang/pt-br.jsonindex 26ad0b9bc..c4ff31e90 100644--- a/launcher/lang/pt-br.json+++ b/launcher/lang/pt-br.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "Exporte o servidor fora das pastas gerenciadas pelo launcher.","{path} is not a folder to build into.": "{path} não é uma pasta para criação de build.","Could not copy the build: {error}": "Não foi possível copiar o build: {error}",- "Could not move the build to {path}: {error}": "Não foi possível mover o build para {path}: {error}"+ "Could not move the build to {path}: {error}": "Não foi possível mover o build para {path}: {error}",+ "Native mods can use your microphone for voice chat when you enable it.": "Mods nativos podem usar seu microfone para bate-papo por voz quando você ativar isso."}diff --git a/launcher/lang/ru.json b/launcher/lang/ru.jsonindex 9aecb49d3..01a8e005e 100644--- a/launcher/lang/ru.json+++ b/launcher/lang/ru.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "Экспортируйте сервер вне управляемых лаунчером папок.","{path} is not a folder to build into.": "{path} не является папкой для сборки.","Could not copy the build: {error}": "Не удалось скопировать сборку: {error}",- "Could not move the build to {path}: {error}": "Не удалось переместить сборку в {path}: {error}"+ "Could not move the build to {path}: {error}": "Не удалось переместить сборку в {path}: {error}",+ "Native mods can use your microphone for voice chat when you enable it.": "Нативные моды могут использовать ваш микрофон для голосового чата, когда вы это включите."}diff --git a/launcher/lang/tr.json b/launcher/lang/tr.jsonindex f3a532ed6..18f261a30 100644--- a/launcher/lang/tr.json+++ b/launcher/lang/tr.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "Sunucuyu launcher tarafından yönetilen klasörlerin dışına aktarın.","{path} is not a folder to build into.": "{path} derleme yapılacak klasör değil.","Could not copy the build: {error}": "Build kopyalanamadı: {error}",- "Could not move the build to {path}: {error}": "Build {path} konumuna taşınamadı: {error}"+ "Could not move the build to {path}: {error}": "Build {path} konumuna taşınamadı: {error}",+ "Native mods can use your microphone for voice chat when you enable it.": "Yerel modlar, bunu etkinleştirdiğinizde sesli sohbet için mikrofonunuzu kullanabilir."}diff --git a/launcher/lang/uk.json b/launcher/lang/uk.jsonindex 13c5c7228..fe7875a07 100644--- a/launcher/lang/uk.json+++ b/launcher/lang/uk.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "Експортуйте сервер позаду папок, которыmi керує лаунчер.","{path} is not a folder to build into.": "{path} не є папкою для збірки.","Could not copy the build: {error}": "Не вдалося скопіювати збірку: {error}",- "Could not move the build to {path}: {error}": "Не вдалося перемістити збірку у {path}: {error}"+ "Could not move the build to {path}: {error}": "Не вдалося перемістити збірку у {path}: {error}",+ "Native mods can use your microphone for voice chat when you enable it.": "Нативні моди можуть використовувати ваш мікрофон для голосового чату, коли ви це увімкнете."}diff --git a/launcher/lang/zh.json b/launcher/lang/zh.jsonindex 7e3741df0..9498dd03b 100644--- a/launcher/lang/zh.json+++ b/launcher/lang/zh.json@@ -743,5 +743,6 @@"Export the server outside the launcher's managed folders.": "将服务器导出到启动器管理的文件夹之外。","{path} is not a folder to build into.": "{path} 不是可供构建的文件夹。","Could not copy the build: {error}": "无法复制构建:{error}",- "Could not move the build to {path}: {error}": "无法将构建移动到 {path}:{error}"+ "Could not move the build to {path}: {error}": "无法将构建移动到 {path}:{error}",+ "Native mods can use your microphone for voice chat when you enable it.": "原生模组在您启用时可使用您的麦克风进行语音聊天。"}diff --git a/launcher/src/game_app.rs b/launcher/src/game_app.rsindex d4fc9972d..82b46e8f4 100644--- a/launcher/src/game_app.rs+++ b/launcher/src/game_app.rs@@ -40,10 +40,16 @@ const INFO_PLIST: &str = r#"<?xml version="1.0" encoding="UTF-8"?><string>public.app-category.games</string><key>NSHighResolutionCapable</key><true/>+ <key>NSMicrophoneUsageDescription</key>+ <string>__MIC_DESCRIPTION__</string></dict></plist>"#;+/// Where `ensure` fills in the localized `NSMicrophoneUsageDescription` (native mods can open the+/// microphone for voice chat; without the key macOS would kill the game instead of asking).+const MIC_DESCRIPTION: &str = "__MIC_DESCRIPTION__";+/// Brings `version`'s Horizon.app up to date and returns the game's program inside it. A program/// replaced in the version folder (a reinstall, a build copied over) is linked again.pub fn ensure(version: &Path) -> io::Result<PathBuf> {@@ -51,7 +57,16 @@ pub fn ensure(version: &Path) -> io::Result<PathBuf> {let programs = contents.join("MacOS");fs::create_dir_all(&programs)?;fs::create_dir_all(contents.join("Resources"))?;- write_if_changed(&contents.join("Info.plist"), INFO_PLIST.as_bytes())?;+ // Filled here so the prompt follows the launcher's language: the game reads the bundle as+ // it starts, and the plist is not a place the game can localize.+ let plist = INFO_PLIST.replacen(+ MIC_DESCRIPTION,+ &crate::shortcut::xml(crate::i18n::tr(+ "Native mods can use your microphone for voice chat when you enable it.",+ )),+ 1,+ );+ write_if_changed(&contents.join("Info.plist"), plist.as_bytes())?;write_if_changed(&contents.join("Resources/horizon.icns"), ICON)?;for (i, name) in PROGRAMS.into_iter().enumerate() {let (from, to) = (version.join(name), programs.join(name));@@ -105,6 +120,20 @@ mod tests {));let plist = fs::read_to_string(version.join("Horizon.app/Contents/Info.plist")).unwrap();assert!(plist.contains("<string>Horizon</string>"));+ // The mic prompt macOS needs before a native mod may open the microphone: a key with a+ // nonempty localized value, not the placeholder the template ships with.+ let (_, rest) = plist+ .split_once("<key>NSMicrophoneUsageDescription</key>")+ .expect("Info.plist has NSMicrophoneUsageDescription");+ let value = rest+ .split_once("</string>")+ .expect("the key has a string value")+ .0+ .split_once("<string>")+ .expect("an opening tag")+ .1;+ assert!(!value.is_empty());+ assert!(!plist.contains("__MIC_DESCRIPTION__"));assert_eq!(fs::read(version.join("Horizon.app/Contents/Resources/horizon.icns")).unwrap(),ICON@@ -143,4 +172,12 @@ mod tests {assert!(ensure(&version).is_err());fs::remove_dir_all(&version).unwrap();}++ #[test]+ fn xml_escapes_the_characters_plist_strings_must_not_carry() {+ assert_eq!(+ crate::shortcut::xml(r#"a & b < c > "d""#),+ r#"a & b < c > "d""#+ );+ }}diff --git a/launcher/src/shortcut.rs b/launcher/src/shortcut.rsindex b4e97abd4..11f55810d 100644--- a/launcher/src/shortcut.rs+++ b/launcher/src/shortcut.rs@@ -112,7 +112,7 @@ fn sh_quote(text: &str) -> String {format!("'{}'", text.replace('\'', r"'\''"))}-fn xml(text: &str) -> String {+pub(crate) fn xml(text: &str) -> String {text.replace('&', "&").replace('<', "<").replace('>', ">")