### Clone LeviLauncher Repository Source: https://github.com/liteldev/levilaunchroid/blob/main/README.md Use this command to clone the LeviLauncher project from GitHub. Ensure you have Git installed. ```bash git clone https://github.com/LiteLDev/LeviLaunchroid.git ``` -------------------------------- ### Launch Minecraft Version with LeviLauncher Source: https://context7.com/liteldev/levilaunchroid/llms.txt Launches a specified Minecraft version using MinecraftLauncher. This process includes showing a loading dialog, loading native libraries, injecting mods, and starting the MinecraftActivity. Ensure the context is an Activity. ```java MinecraftLauncher launcher = new MinecraftLauncher(activity); GameVersion version = VersionManager.get(activity).getSelectedVersion(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_MAIN); launcher.launch(intent, version); // MinecraftLauncher will: // 1. Show a LoadingDialog on the UI thread // 2. Spawn a background thread that calls GamePackageManager.getInstance() // 3. Conditionally load c++_shared, fmod, MediaDecoders, HttpClient, minecraftpe, gxcore // 4. Call ModNativeLoader.loadEnabledSoMods() to inject .so mods // 5. Start MinecraftActivity with extras: // - "MC_SRC" → path to base.apk.levi // - "MC_SPLIT_SRC" → ArrayList of split APK paths // - "MODS_ENABLED" → boolean // - "MINECRAFT_VERSION" → e.g. "1.21.110" // - "MINECRAFT_VERSION_DIR" → directory name for version isolation // - "MC_PATH" → isolation dir path (if enabled) ``` -------------------------------- ### Manage Minecraft Versions with VersionManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt Use VersionManager to discover, select, and manage different Minecraft installations. It persists the selected version and can trigger library repair for corrupted installs. ```java VersionManager vm = VersionManager.get(context); List installed = vm.getInstalledVersions(); List custom = vm.getCustomVersions(); GameVersion target = custom.get(0); vm.setSelectedVersion(target); GameVersion selected = vm.getSelectedVersion(); String modsPath = VersionManager.getSelectedModsDir(context); VersionManager.attemptRepairLibs(activity, selected); ``` -------------------------------- ### VersionManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt Manages multi-version Minecraft installs, including system-installed and custom APK-imported versions. It persists the user's selected version and provides library repair functionality. ```APIDOC ## `VersionManager` — Manage multi-version Minecraft installs Singleton that discovers both system-installed Minecraft packages and custom APK-imported versions stored on the device. Persists the user's selected version across sessions via `SharedPreferences`. Provides library repair for corrupted installs. ### Methods * **`get(Context context)`**: Get the singleton instance of `VersionManager`. * **`getInstalledVersions()`**: Returns a list of system-installed `GameVersion` objects. * **`getCustomVersions()`**: Returns a list of APK-imported `GameVersion` objects. * **`setSelectedVersion(GameVersion target)`**: Selects and persists the target `GameVersion`. * **`getSelectedVersion()`**: Retrieves the currently selected `GameVersion`. * **`getSelectedModsDir(Context context)`**: Gets the path to the mods directory for the selected version. * **`attemptRepairLibs(Activity activity, GameVersion version)`**: Triggers a library repair dialog for the specified version. ### `GameVersion` Properties * **`directoryName`**: (String) The name of the version directory. * **`versionCode`**: (String) The version code. * **`displayName`**: (String) A human-readable label for the version. * **`versionDir`**: (File) The directory where the version is stored. * **`isInstalled`**: (Boolean) Indicates if the version is system-installed (true) or APK-imported (false). * **`modsDir`**: (File) The directory for mods of this version. ``` -------------------------------- ### Get Mod Files Source: https://context7.com/liteldev/levilaunchroid/llms.txt Lists all downloadable files for a specific mod, with pagination support. ```APIDOC ## `getModFiles` ### Description Retrieves a paginated list of downloadable files associated with a specific Minecraft mod. ### Method `CurseForgeClient.getModFiles` ### Parameters - `modId` (int) - The unique ID of the mod. - `index` (int) - The pagination index (starting from 0). - `pageSize` (int) - The number of files to retrieve per page. - `callback` (CurseForgeCallback) - A callback to handle the response or errors. ### Response #### Success Response (ModFilesResponse) Contains a list of `ContentFile` objects, each representing a downloadable file for the mod. ### Response Example ```json { "data": [ { "fileName": "example-mod-1.0.zip", "downloadUrl": "https://example.com/mods/example-mod-1.0.zip" } ] } ``` ``` -------------------------------- ### Get Content Description Source: https://context7.com/liteldev/levilaunchroid/llms.txt Retrieves the HTML description for a specific mod identified by its ID. ```APIDOC ## `getContentDescription` ### Description Retrieves the detailed HTML description for a specific Minecraft mod or add-on. ### Method `CurseForgeClient.getContentDescription` ### Parameters - `contentId` (int) - The unique ID of the content (mod/add-on). - `callback` (CurseForgeCallback) - A callback to handle the HTML description string or errors. ### Response #### Success Response (String) The HTML content of the mod's description. ### Response Example ```html

Mod Title

This is the mod description.

``` ``` -------------------------------- ### GamePackageManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt A singleton responsible for detecting installed Minecraft packages, extracting native libraries from APKs into a cache directory, and providing methods to load these libraries via JNI. It supports both system-installed and APK-imported (isolated) Minecraft versions. ```APIDOC ## GamePackageManager — Resolve and load Minecraft native libraries ### Description Singleton that detects the installed Minecraft package (`com.mojang.minecraftpe`, `.beta`, or `.preview`), extracts required native libraries from the APK ZIP into a cache directory, and exposes `loadLibrary()` / `loadAllLibraries()` for JNI loading. Supports both system-installed and APK-imported (isolated) versions. ### Singleton Instance ```kotlin val gpm = GamePackageManager.getInstance(context.applicationContext, version) ``` ### Methods #### `loadLibrary(String libName)` Loads a single library by its short name (without `lib` prefix and `.so` suffix). - **Returns**: `Boolean` - `true` if the library was loaded successfully, `false` otherwise. #### `loadAllLibraries(Set excludeLibs)` Loads all required native libraries and system libraries, with an option to exclude specific libraries. - **Parameters**: - `excludeLibs` (Set) - A set of library names to exclude from loading. ### Properties - **`packageContext`**: `Context` - The underlying package context. - **`assets`**: `AssetManager` - The asset manager for the package. - **`versionName`**: `String?` - The version name of the Minecraft package (e.g., "1.21.110"). ### Initialization State ```kotlin val ready: Boolean = GamePackageManager.isInitialized() ``` ### Required Libraries (Extracted from APK) - `libc++_shared.so` - `libfmod.so` - `libMediaDecoders_Android.so` - `libHttpClient.Android.so` - `libminecraftpe.so` ### System-Loaded Libraries (via `System.loadLibrary`) - `libPlayFabMultiplayer.so` - `libmaesdk.so` - `libpairipcore.so` - `libgxcore.so` ``` -------------------------------- ### Get CurseForge Content Description Source: https://context7.com/liteldev/levilaunchroid/llms.txt Retrieves the HTML description for a specific mod identified by its ID. The description is loaded into a WebView. ```java // Get HTML description for a specific mod cf.getContentDescription(12345, new CurseForgeClient.CurseForgeCallback() { public void onSuccess(String html) { webView.loadData(html, "text/html", "utf-8"); } public void onError(Throwable t) { Log.e("CF", t.getMessage()); } }); ``` -------------------------------- ### CurseForgeClient Constants Source: https://context7.com/liteldev/levilaunchroid/llms.txt Provides constants for sorting options and game IDs used with the CurseForgeClient. For example, SORT_POPULARITY is "2" and GAME_ID_MINECRAFT is 78022. ```java // Sort constants: SORT_POPULARITY="2", SORT_LAST_UPDATED="3", // SORT_NAME="4", SORT_TOTAL_DOWNLOADS="6" // Minecraft GAME_ID: CurseForgeClient.GAME_ID_MINECRAFT = 78022 ``` -------------------------------- ### MinecraftLauncher.launch() Source: https://context7.com/liteldev/levilaunchroid/llms.txt Launches a specified Minecraft version after resolving its GameVersion, loading native libraries, and injecting enabled SO mods. It handles version-conditional library loading and displays a loading dialog during the process. ```APIDOC ## MinecraftLauncher.launch() — Launch a Minecraft version ### Description Resolves the target `GameVersion`, loads its native libraries via `GamePackageManager`, injects enabled SO mods through `ModNativeLoader`, and starts `MinecraftActivity`. Handles version-conditional library loading (MAESDK, HttpClient, PlayFab) based on semantic version comparison. ### Method Signature ```java launcher.launch(Intent intent, GameVersion version) ``` ### Parameters - **intent** (Intent) - An Intent object that can carry extras for the MinecraftActivity. - **version** (GameVersion) - The GameVersion object representing the Minecraft version to launch. ### Internal Steps 1. Show a `LoadingDialog` on the UI thread. 2. Spawn a background thread to call `GamePackageManager.getInstance()`. 3. Conditionally load native libraries: `c++_shared`, `fmod`, `MediaDecoders`, `HttpClient`, `minecraftpe`, `gxcore`. 4. Call `ModNativeLoader.loadEnabledSoMods()` to inject `.so` mods. 5. Start `MinecraftActivity` with specific extras: - `"MC_SRC"` → path to base.apk.levi - `"MC_SPLIT_SRC"` → ArrayList of split APK paths - `"MODS_ENABLED"` → boolean - `"MINECRAFT_VERSION"` → e.g. "1.21.110" - `"MINECRAFT_VERSION_DIR"` → directory name for version isolation - `"MC_PATH"` → isolation dir path (if enabled) ``` -------------------------------- ### Configure UnpairCore Library Build Source: https://github.com/liteldev/levilaunchroid/blob/main/app/src/main/cpp/unpaircore/CMakeLists.txt Sets up the C++ standard, finds source files, and defines the shared library target with include directories and linked libraries. ```cmake cmake_minimum_required(VERSION 3.22) project(pairipcore LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) file(GLOB_RECURSE UNPAIRCORE_SRC CONFIGURE_DEPENDS "src/*.cpp") add_library(pairipcore SHARED ${UNPAIRCORE_SRC}) target_include_directories(pairipcore PRIVATE src ${CMAKE_SOURCE_DIR}/preloader/src ) target_link_libraries(pairipcore PRIVATE android log preloader ) ``` -------------------------------- ### Find and Link Libraries for inbuiltmods Source: https://github.com/liteldev/levilaunchroid/blob/main/app/src/main/cpp/inbuiltmods/CMakeLists.txt Finds the 'log' and 'EGL' libraries and links them privately to the inbuiltmods target, along with the 'preloader' library. This ensures necessary dependencies are available. ```cmake find_library(log-lib log) find_library(egl-lib EGL) target_link_libraries(inbuiltmods PRIVATE preloader ${log-lib} ${egl-lib} ) ``` -------------------------------- ### Search Content Source: https://context7.com/liteldev/levilaunchroid/llms.txt Searches for add-ons based on a query string, class ID, game version, pagination, and sorting preferences. ```APIDOC ## `searchContent` ### Description Searches for Minecraft add-ons (mods, resource packs, etc.) from CurseForge based on various criteria. ### Method `CurseForgeClient.searchContent` ### Parameters - `query` (String) - The search query string. - `classId` (int) - The CurseForge class ID (e.g., 4559 for behavior packs, 12 for resource packs, 0 for all). - `gameVersion` (String) - The Minecraft game version filter (e.g., "1.21.0", or "All" for no filter). - `index` (int) - The pagination index (starting from 0). - `pageSize` (int) - The number of results per page. - `sortOrder` (String) - The sorting order constant (e.g., `CurseForgeClient.SORT_POPULARITY`). - `sortDirection` (String) - The direction of sorting, either "asc" or "desc". - `callback` (CurseForgeCallback) - A callback to handle the response or errors. ### Response #### Success Response (ContentSearchResponse) Contains a list of `Content` items matching the search criteria. ### Response Example ```json { "data": [ { "name": "Example Mod Name", "downloadCount": 12345, "id": 67890 } ] } ``` ``` -------------------------------- ### Set Include Directories for inbuiltmods Source: https://github.com/liteldev/levilaunchroid/blob/main/app/src/main/cpp/inbuiltmods/CMakeLists.txt Specifies private include directories for the inbuiltmods library. 'src' and a path relative to the current source directory are added. ```cmake target_include_directories(inbuiltmods PRIVATE src ${CMAKE_CURRENT_SOURCE_DIR}/../preloader/src ) ``` -------------------------------- ### ModNativeLoader.loadEnabledSoMods Source: https://context7.com/liteldev/levilaunchroid/llms.txt Injects native SO mods at launch by copying enabled mod directories to the app cache, marking them read-only, and loading them. ```APIDOC ## `ModNativeLoader.loadEnabledSoMods()` — Inject native SO mods at launch Copies all enabled mod directories from `version.modsDir` to the app cache, marks them read-only, calls `System.load()` for each, then invokes the native preloader (`nativeLoadMod`) to finish mod initialization. Prunes stale cached entries from previous sessions. ### Methods * **`loadEnabledSoMods(ModManager modManager, File cacheDir)`**: Loads all enabled SO mods for the current version into the cache directory. * **`ensurePreloaderLoaded()`**: (Static) Ensures the preloader native library is loaded, attempting `System.loadLibrary("preloader")` once and caching the result. ### Internal Flow 1. For each enabled Mod in `mm.getMods()`: a. Copy `//` → `/mods//` b. Set the entry `.so` file read-only. c. `System.load("/mods//libMyMod.so")` d. If preloader is available: `ModManager.initializeLoadedMod(libPath, mod)` 2. Delete any cached mod directories not in the current enabled set. ``` -------------------------------- ### List CurseForge Mod Files Source: https://context7.com/liteldev/levilaunchroid/llms.txt Lists downloadable files for a given mod ID, with support for pagination. Displays the file name and download URL. ```java // List downloadable files for a mod (paginated) cf.getModFiles(12345, 0, 10, new CurseForgeClient.CurseForgeCallback() { public void onSuccess(ModFilesResponse res) { for (ContentFile f : res.data) { Log.d("CF", f.fileName + " → " + f.downloadUrl); } } public void onError(Throwable t) { Log.e("CF", t.getMessage()); } }); ``` -------------------------------- ### Configure inbuiltmods CMake Project Source: https://github.com/liteldev/levilaunchroid/blob/main/app/src/main/cpp/inbuiltmods/CMakeLists.txt Sets the minimum CMake version, project name, and C++ standard for the inbuiltmods library. Ensure C++20 is supported and required. ```cmake cmake_minimum_required(VERSION 3.22) project(inbuiltmods LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` -------------------------------- ### Resolve and Load Minecraft Native Libraries with GamePackageManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt Manages the resolution and loading of native libraries for Minecraft. It supports both system-installed and APK-imported versions, allowing for loading individual libraries or all required ones, with options to exclude specific libraries. Access to package context and assets is also provided. ```kotlin val version: GameVersion = VersionManager.get(context).selectedVersion val gpm = GamePackageManager.getInstance(context.applicationContext, version) val loaded: Boolean = gpm.loadLibrary("minecraftpe") val exclude = setOf("c++_shared", "HttpClient.Android") gpm.loadAllLibraries(excludeLibs = exclude) val pkgCtx: Context = gpm.getPackageContext() val assets: AssetManager = gpm.getAssets() val versionName: String? = gpm.getVersionName() // Required libs extracted from APK: // libc++_shared.so, libfmod.so, libMediaDecoders_Android.so, // libHttpClient.Android.so, libminecraftpe.so // System-loaded libs (via System.loadLibrary): // libPlayFabMultiplayer.so, libmaesdk.so, libpairipcore.so, libgxcore.so val ready: Boolean = GamePackageManager.isInitialized() ``` -------------------------------- ### InbuiltModManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt Manages bundled gameplay enhancement overlays (mods) and their user preferences. Allows enabling, disabling, and configuring various mods. ```APIDOC ## InbuiltModManager — Built-in gameplay overlay mods Manages the set of bundled gameplay enhancement overlays (FPS display, zoom, auto-sprint, snap-look, CPS display, virtual cursor, etc.). Persists user preferences (enabled state, keybinds, overlay positions, opacity, sizes) in `SharedPreferences`. ### Methods - **`getAllMods(Context context)`**: Retrieves all available built-in mods. - **`getAddedMods(Context context)`**: Gets only the user-selected (added) mods. - **`addMod(ModIds modId)`**: Adds a mod by its ID. - **`removeMod(ModIds modId)`**: Removes a mod by its ID. - **`isModAdded(ModIds modId)`**: Checks if a mod is currently added. - **`setOverlayButtonSize(ModIds modId, int size)`**: Configures the button size for an overlay mod. - **`setOverlayOpacity(ModIds modId, int opacity)`**: Configures the opacity for an overlay mod. - **`setOverlayPosition(ModIds modId, int x, int y)`**: Configures the position for an overlay mod. - **`setOverlayLocked(ModIds modId, boolean locked)`**: Locks or unlocks an overlay mod's position. - **`setZoomLevel(int level)`**: Sets the zoom level for the zoom mod. - **`setZoomKeybind(int keyCode)`**: Sets the keybind for the zoom mod. - **`setAutoSprintKeybind(int keyCode)`**: Sets the keybind for the auto-sprint mod. - **`setCursorSensitivity(int sensitivity)`**: Sets the sensitivity for the virtual cursor mod. - **`setModMenuEnabled(boolean enabled)`**: Enables or disables the mod menu overlay. - **`setModMenuOpacity(int opacity)`**: Configures the opacity of the mod menu overlay. - **`setModMenuButtonOpacity(int opacity)`**: Configures the opacity of the mod menu button. - **`setNotificationsEnabled(boolean enabled)`**: Enables or disables notifications. ### Example Usage ```java InbuiltModManager ibm = InbuiltModManager.getInstance(context); // Retrieve mods List all = ibm.getAllMods(context); List active = ibm.getAddedMods(context); // Add/remove mods ibm.addMod(ModIds.FPS_DISPLAY); ibm.removeMod(ModIds.TOGGLE_HUD); boolean added = ibm.isModAdded(ModIds.ZOOM); // Configure overlays ibm.setOverlayButtonSize(ModIds.FPS_DISPLAY, 64); ibm.setOverlayOpacity(ModIds.FPS_DISPLAY, 80); ibm.setOverlayPosition(ModIds.FPS_DISPLAY, 100, 200); ibm.setOverlayLocked(ModIds.FPS_DISPLAY, true); // Zoom mod settings ibm.setZoomLevel(70); ibm.setZoomKeybind(KeyEvent.KEYCODE_C); // Auto-sprint keybind ibm.setAutoSprintKeybind(KeyEvent.KEYCODE_CTRL_LEFT); // Cursor sensitivity ibm.setCursorSensitivity(150); // Mod menu settings ibm.setModMenuEnabled(true); ibm.setModMenuOpacity(90); ibm.setModMenuButtonOpacity(75); ibm.setNotificationsEnabled(false); ``` ``` -------------------------------- ### Manage Built-in Mods with InbuiltModManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt InbuiltModManager controls bundled gameplay enhancement mods, persisting user preferences. Use it to retrieve, add, remove, and configure mods, including their appearance and keybinds. ```java InbuiltModManager ibm = InbuiltModManager.getInstance(context); // Retrieve all available built-in mods List all = ibm.getAllMods(context); // ModIds: QUICK_DROP, CAMERA_PERSPECTIVE, TOGGLE_HUD, AUTO_SPRINT, // CHICK_PET, ZOOM, FPS_DISPLAY, CPS_DISPLAY, SNAPLOOK, VIRTUAL_CURSOR // Get only added (user-selected) mods List active = ibm.getAddedMods(context); // Add / remove a mod by its ID ibm.addMod(ModIds.FPS_DISPLAY); ibm.removeMod(ModIds.TOGGLE_HUD); boolean added = ibm.isModAdded(ModIds.ZOOM); // false after removal // Configure overlay appearance per mod ibm.setOverlayButtonSize(ModIds.FPS_DISPLAY, 64); // dp ibm.setOverlayOpacity(ModIds.FPS_DISPLAY, 80); // 0–100 ibm.setOverlayPosition(ModIds.FPS_DISPLAY, 100, 200); // x, y pixels ibm.setOverlayLocked(ModIds.FPS_DISPLAY, true); // Zoom mod settings ibm.setZoomLevel(70); // 10–100 ibm.setZoomKeybind(KeyEvent.KEYCODE_C); // Auto-sprint keybind ibm.setAutoSprintKeybind(KeyEvent.KEYCODE_CTRL_LEFT); // Cursor sensitivity (virtual cursor overlay) ibm.setCursorSensitivity(150); // 10–300 // Mod menu overlay settings ibm.setModMenuEnabled(true); ibm.setModMenuOpacity(90); ibm.setModMenuButtonOpacity(75); ibm.setNotificationsEnabled(false); ``` -------------------------------- ### Search CurseForge Content Source: https://context7.com/liteldev/levilaunchroid/llms.txt Searches for Minecraft add-ons based on a query string, class ID, game version, and sorting preferences. Requires an API key injected at build time. ```java CurseForgeClient cf = CurseForgeClient.getInstance(); // API key is injected at build time via BuildConfig.CURSEFORGE_API_KEY // Search for add-ons (classId=4559 for behavior packs, 12 for resource packs, etc.) cf.searchContent( "gravity", // query string 4559, // CurseForge classId (0 = all) "1.21.0", // Minecraft game version filter ("All" = no filter) 0, // pagination index 20, // page size CurseForgeClient.SORT_POPULARITY, // "2" "desc", new CurseForgeClient.CurseForgeCallback() { public void onSuccess(ContentSearchResponse res) { for (Content item : res.data) { Log.d("CF", item.name + " | downloads=" + item.downloadCount + " | id=" + item.id); } } public void onError(Throwable t) { Log.e("CF", t.getMessage()); } } ); ``` -------------------------------- ### ModManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt Manages the lifecycle of native SO mods, including discovery, enable/disable state, load order, and configuration persistence. It also watches for filesystem changes. ```APIDOC ## `ModManager` — SO mod lifecycle management Thread-safe singleton that manages the full lifecycle of native SO mods: discovery (directory-based with `manifest.json`), enable/disable state, load order, config persistence, and filesystem watching via `FileObserver`. Automatically migrates legacy top-level `.so` files into the structured directory format. ### Methods * **`getInstance()`**: Get the singleton instance of `ModManager`. * **`setCurrentVersion(GameVersion version)`**: Binds the `ModManager` to the currently selected game version, creating its mods directory if absent and loading `mods_config.json`. * **`getMods()`**: Returns a list of `Mod` objects, ordered according to `mods_config.json`. * **`setModEnabled(String modId, boolean enabled)`**: Enables or disables a mod identified by its directory ID. * **`deleteMod(String modId)`**: Deletes the entire mod directory for the given mod ID. * **`reorderMods(List reorderedMods)`**: Reorders the mods, affecting their load order. * **`getModsChangedLiveData()`**: Returns a `LiveData` object that emits updates when the mod list changes. ### `Mod` Properties * **`getId()`**: (String) The unique identifier of the mod (directory ID). * **`getDisplayName()`**: (String) The human-readable name of the mod. * **`isEnabled()`**: (Boolean) Indicates if the mod is currently enabled. * **`getEntryPath()`**: (String) The path to the mod's entry point (e.g., the SO file). ### Mod Directory Structure * `version.modsDir/` * `MyMod_v1/` * `manifest.json` (required: `{ "type": "preload-native", "name": "My Mod", "entry": "libMyMod.so", "author": "...", "version": "1.0.0" }`) * `libMyMod.so` (the native library to inject) ``` -------------------------------- ### Define inbuiltmods Shared Library Source: https://github.com/liteldev/levilaunchroid/blob/main/app/src/main/cpp/inbuiltmods/CMakeLists.txt Defines the inbuiltmods library as a SHARED library, listing its source files. This makes the library available for dynamic linking. ```cmake add_library(inbuiltmods SHARED src/common/transition.cpp src/zoom/zoom.cpp src/fps/fps.cpp src/snaplook/snaplook.cpp ) ``` -------------------------------- ### Manage Minecraft Worlds with WorldManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt Use WorldManager to import, export, backup, and transfer Minecraft worlds. All operations are asynchronous and report progress via a callback. Ensure to shut down the executor when done. ```java WorldManager wm = new WorldManager(context); wm.setCurrentVersion(selectedVersion); // → worlds directory: /games/com.mojang/minecraftWorlds/ // List worlds List worlds = wm.getWorlds(); // worlds.get(0).getName() → folder name / world name // worlds.get(0).getFile() → File reference // worlds.get(0).isValid() → checks for level.dat presence WorldManager.WorldOperationCallback cb = new WorldManager.WorldOperationCallback() { public void onSuccess(String msg) { Log.i("World", msg); } public void onError(String err) { Log.e("World", err); } public void onProgress(int pct) { progressBar.setProgress(pct); } }; // Import a .mcworld ZIP from a content URI Uri worldUri = /* result from file picker */; wm.importWorld(worldUri, cb); // → extracts ZIP, finds level.dat, copies to worlds directory // Export to a URI (e.g. SAF document) Uri exportUri = /* SAF output URI */; wm.exportWorld(worlds.get(0), exportUri, cb); // → zips world directory and writes to exportUri // Backup (saves to external storage: games/org.levimc/backups/worlds/) wm.backupWorld(worlds.get(0), cb); // → creates WorldName_20250101_120000.mcworld // Transfer world to another version's worlds directory File targetVersionWorlds = new File(otherVersion.versionDir, "games/com.mojang/minecraftWorlds"); wm.transferWorld(worlds.get(0), targetVersionWorlds, cb); // Shutdown executor when done (e.g. in onDestroy) wm.shutdown(); ``` -------------------------------- ### MsftAccountStore - Multi-account persistence Source: https://context7.com/liteldev/levilaunchroid/llms.txt Manages a JSON-backed list of Microsoft/Xbox accounts. Supports add/update, removal, active-account switching, and lookup by account ID. ```APIDOC ## `MsftAccountStore` — Multi-account persistence Manages a JSON-backed list of Microsoft/Xbox accounts (`Xal.Accounts.json`). Supports add/update, removal, active-account switching, and lookup by account ID. ```java // List all stored accounts List accounts = MsftAccountStore.list(context); for (MsftAccountStore.MsftAccount acct : accounts) { Log.d("Accounts", acct.id + " | " + acct.xboxGamertag + " | active=" + acct.active + " | xuid=" + acct.xuid); } // Add or update (upsert by msUserId) MsftAccountStore.MsftAccount acct = MsftAccountStore.addOrUpdate( context, msaToken.getUserId(), // Microsoft user ID (unique key) msaToken.getRefreshToken(), "CoolPlayer123", // Xbox gamertag "CoolPlayer", // Minecraft username "2535412345678901", // XUID "https://avatar.url/pic.png" ); // Set the active account (only one active at a time) MsftAccountStore.setActive(context, acct.id); // Find by UUID MsftAccountStore.MsftAccount found = MsftAccountStore.find(context, acct.id); // Remove an account (also deletes XAL token storage for that user) MsftAccountStore.remove(context, acct.id); ``` ``` -------------------------------- ### ResourcePackManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt Handles import, export, deletion, and transfer of Minecraft resource, behavior, and skin packs. It automatically classifies packs by parsing their manifest. ```APIDOC ## ResourcePackManager — Resource/behavior/skin pack management Handles import (`.mcpack`, `.mcaddon`), export, deletion, and cross-version transfer of Minecraft packs. Automatically classifies packs as resource, behavior, or skin type by parsing `manifest.json` module types. ### Methods - **`getResourcePacks()`**: Lists all resource packs. - **`getBehaviorPacks()`**: Lists all behavior packs. - **`getSkinPacks()`**: Lists all skin packs. - **`importPack(Uri packUri, PackOperationCallback cb)`**: Imports a `.mcpack` or `.mcaddon` from a content URI. - **`exportPack(ResourcePackItem pack, Uri exportUri, PackOperationCallback cb)`**: Exports a pack to a specified URI. - **`deletePack(ResourcePackItem pack, PackOperationCallback cb)`**: Deletes a pack. - **`transferPack(ResourcePackItem pack, File targetBehaviorDir, PackOperationCallback cb)`**: Transfers a pack to another version's directory. - **`shutdown()`**: Shuts down the executor. ### Example Usage ```java ResourcePackManager rpm = new ResourcePackManager(context); rpm.setCurrentVersion(selectedVersion); // List packs List rp = rpm.getResourcePacks(); List bp = rpm.getBehaviorPacks(); List sp = rpm.getSkinPacks(); ResourcePackManager.PackOperationCallback cb = new ResourcePackManager.PackOperationCallback() { public void onSuccess(String msg) { Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show(); } public void onError(String err) { Log.e("Pack", err); } public void onProgress(int pct) {} }; // Import a pack Uri packUri = /* file picker result */; rpm.importPack(packUri, cb); // Export a pack rpm.exportPack(rp.get(0), exportUri, cb); // Delete a pack rpm.deletePack(bp.get(0), cb); // Transfer pack File targetBehaviorDir = new File(otherVersion.versionDir, "games/com.mojang/behavior_packs"); rpm.transferPack(bp.get(0), targetBehaviorDir, cb); rpm.shutdown(); ``` ``` -------------------------------- ### Manage SO Mod Lifecycle with ModManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt ModManager handles the lifecycle of native SO mods, including discovery, enabling/disabling, load order, and configuration persistence. It automatically migrates legacy mod files. ```java ModManager mm = ModManager.getInstance(); GameVersion version = VersionManager.get(context).getSelectedVersion(); mm.setCurrentVersion(version); List mods = mm.getMods(); for (Mod mod : mods) { Log.d("Mods", mod.getId() + " | " + mod.getDisplayName() + " | enabled=" + mod.isEnabled() + " | entry=" + mod.getEntryPath()); } mm.setModEnabled("MyMod_v1", true); mm.setModEnabled("MyMod_v1", false); mm.deleteMod("MyMod_v1"); List reordered = new ArrayList<>(mods); Collections.swap(reordered, 0, 1); mm.reorderMods(reordered); mm.getModsChangedLiveData().observe(lifecycleOwner, v -> { List updated = mm.getMods(); adapter.submitList(updated); }); ``` -------------------------------- ### Complete Microsoft/Xbox Authentication Flow Source: https://context7.com/liteldev/levilaunchroid/llms.txt Handles the full OAuth 2.0, Xbox Live, and XSTS authentication chain for Minecraft multiplayer. Requires an OkHttpClient instance and captures an authorization code from a redirect. Persists account details after successful authentication. ```java OkHttpClient httpClient = new OkHttpClient(); // ── Step 1: Build the browser authorization URL ────────────────────────── String codeVerifier = OAuth20Util.generateCodeVerifier(); String codeChallenge = OAuth20Util.generateCodeChallenge(codeVerifier); String state = UUID.randomUUID().toString(); String authUrl = MsftAuthManager.buildAuthorizeUrl( MsftAuthManager.DEFAULT_CLIENT_ID, MsftAuthManager.DEFAULT_SCOPE, codeChallenge, state ); // Open authUrl in a WebView/CustomTab; capture the redirect code param // ── Step 2: Exchange authorization code for OAuth token ────────────────── OAuth20Token msaToken = MsftAuthManager.exchangeCodeForToken( httpClient, MsftAuthManager.DEFAULT_CLIENT_ID, authorizationCode, // from redirect codeVerifier, MsftAuthManager.DEFAULT_SCOPE ); // ── Step 3: Perform full Xbox + XSTS auth chain ────────────────────────── MsftAuthManager.XboxAuthResult result = MsftAuthManager.performXboxAuth( httpClient, msaToken, context ); // result.xstsToken() → XSTS token for multiplayer.minecraft.net // result.gamertag() → "CoolPlayer123" // result.avatarUrl() → "https://..." // result.device() → XboxDevice (key + device token) // ── Step 4: Fetch Minecraft identity chain ──────────────────────────────── Pair identity = MsftAuthManager.fetchMinecraftIdentity( httpClient, result.xstsToken() ); // identity.first → Minecraft display name // identity.second → XUID // ── Step 5: Persist the account ────────────────────────────────────────── MsftAuthManager.saveAccount(context, msaToken, result.gamertag(), identity.first, identity.second, result.avatarUrl()); // ── Refresh existing account (subsequent launches) ─────────────────────── MsftAccountStore.MsftAccount saved = MsftAccountStore.list(context).get(0); MsftAuthManager.XboxAuthResult refreshed = MsftAuthManager.refreshAndAuth(httpClient, saved, context); ``` -------------------------------- ### Manage Resource Packs with ResourcePackManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt ResourcePackManager handles import, export, deletion, and transfer of Minecraft resource, behavior, and skin packs. It automatically classifies packs by parsing manifest.json. Remember to shut down the manager when finished. ```java ResourcePackManager rpm = new ResourcePackManager(context); rpm.setCurrentVersion(selectedVersion); // → resource_packs, behavior_packs, skin_packs directories under // /games/com.mojang/ // List packs by type List rp = rpm.getResourcePacks(); List bp = rpm.getBehaviorPacks(); List sp = rpm.getSkinPacks(); ResourcePackManager.PackOperationCallback cb = new ResourcePackManager.PackOperationCallback() { public void onSuccess(String msg) { Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show(); } public void onError(String err) { Log.e("Pack", err); } public void onProgress(int pct) {} }; // Import a .mcpack or .mcaddon from a content URI Uri packUri = /* file picker result */; rpm.importPack(packUri, cb); // → for .mcaddon: unpacks each contained .mcpack // → reads manifest.json to detect type (resources / data / skin_pack) // → copies to appropriate directory with a random UUID name // Export a pack to a URI rpm.exportPack(rp.get(0), exportUri, cb); // Delete a pack rpm.deletePack(bp.get(0), cb); // Transfer pack to another version File targetBehaviorDir = new File(otherVersion.versionDir, "games/com.mojang/behavior_packs"); rpm.transferPack(bp.get(0), targetBehaviorDir, cb); rpm.shutdown(); ``` -------------------------------- ### Add or Update Microsoft/Xbox Account Source: https://context7.com/liteldev/levilaunchroid/llms.txt Adds a new Microsoft/Xbox account or updates an existing one based on the Microsoft User ID (msUserId). Requires account details including refresh token, gamertag, Minecraft username, XUID, and avatar URL. ```java // Add or update (upsert by msUserId) MsftAccountStore.MsftAccount acct = MsftAccountStore.addOrUpdate( context, msaToken.getUserId(), // Microsoft user ID (unique key) msaToken.getRefreshToken(), "CoolPlayer123", // Xbox gamertag "CoolPlayer", // Minecraft username "2535412345678901", // XUID "https://avatar.url/pic.png" ); ``` -------------------------------- ### WorldManager Source: https://context7.com/liteldev/levilaunchroid/llms.txt Manages Minecraft world data including import, export, backup, and transfer operations. It operates asynchronously and reports progress via callbacks. ```APIDOC ## WorldManager — World import, export, backup, and transfer Manages Minecraft world data within a version's isolated directory (`games/com.mojang/minecraftWorlds`). All operations are async via a single-thread executor and report progress through `WorldOperationCallback`. ### Methods - **`getWorlds()`**: Lists all available worlds. - **`importWorld(Uri worldUri, WorldOperationCallback cb)`**: Imports a `.mcworld` ZIP from a content URI. - **`exportWorld(WorldItem world, Uri exportUri, WorldOperationCallback cb)`**: Exports a world to a specified URI. - **`backupWorld(WorldItem world, WorldOperationCallback cb)`**: Backs up a world to external storage. - **`transferWorld(WorldItem world, File targetVersionWorlds, WorldOperationCallback cb)`**: Transfers a world to another version's worlds directory. - **`shutdown()`**: Shuts down the executor. ### Example Usage ```java WorldManager wm = new WorldManager(context); wm.setCurrentVersion(selectedVersion); // List worlds List worlds = wm.getWorlds(); WorldManager.WorldOperationCallback cb = new WorldManager.WorldOperationCallback() { public void onSuccess(String msg) { Log.i("World", msg); } public void onError(String err) { Log.e("World", err); } public void onProgress(int pct) { progressBar.setProgress(pct); } }; // Import a .mcworld ZIP Uri worldUri = /* result from file picker */; wm.importWorld(worldUri, cb); // Export to a URI Uri exportUri = /* SAF output URI */; wm.exportWorld(worlds.get(0), exportUri, cb); // Backup world wm.backupWorld(worlds.get(0), cb); // Transfer world File targetVersionWorlds = new File(otherVersion.versionDir, "games/com.mojang/minecraftWorlds"); wm.transferWorld(worlds.get(0), targetVersionWorlds, cb); // Shutdown executor wm.shutdown(); ``` ``` -------------------------------- ### Load Enabled SO Mods with ModNativeLoader Source: https://context7.com/liteldev/levilaunchroid/llms.txt ModNativeLoader injects enabled native SO mods into the Minecraft process at launch. It copies mods to the app cache, marks them read-only, and loads them using System.load(). ```java ModManager mm = ModManager.getInstance(); mm.setCurrentVersion(version); ModNativeLoader.loadEnabledSoMods(mm, context.getCacheDir()); boolean preloaderReady = ModManager.ensurePreloaderLoaded(); ``` -------------------------------- ### Set Active Microsoft/Xbox Account Source: https://context7.com/liteldev/levilaunchroid/llms.txt Designates a specific account as the active one. Only one account can be active at a time. ```java // Set the active account (only one active at a time) MsftAccountStore.setActive(context, acct.id); ``` -------------------------------- ### MsftAuthManager - Full Microsoft/Xbox authentication flow Source: https://context7.com/liteldev/levilaunchroid/llms.txt Implements the complete OAuth 2.0 + Xbox Live + XSTS authentication chain required for Minecraft multiplayer. Handles device token issuance, user auth, multiple XSTS relying-party tokens, and Minecraft identity chain parsing. ```APIDOC ## `MsftAuthManager` — Full Microsoft/Xbox authentication flow Implements the complete OAuth 2.0 + Xbox Live + XSTS authentication chain required for Minecraft multiplayer. Handles device token issuance, user auth, multiple XSTS relying-party tokens (Minecraft, Xbox Live, PlayFab, Realms), and Minecraft identity chain parsing. ```java OkHttpClient httpClient = new OkHttpClient(); // ── Step 1: Build the browser authorization URL ────────────────────────── String codeVerifier = OAuth20Util.generateCodeVerifier(); String codeChallenge = OAuth20Util.generateCodeChallenge(codeVerifier); String state = UUID.randomUUID().toString(); String authUrl = MsftAuthManager.buildAuthorizeUrl( MsftAuthManager.DEFAULT_CLIENT_ID, MsftAuthManager.DEFAULT_SCOPE, codeChallenge, state ); // Open authUrl in a WebView/CustomTab; capture the redirect code param // ── Step 2: Exchange authorization code for OAuth token ────────────────── OAuth20Token msaToken = MsftAuthManager.exchangeCodeForToken( httpClient, MsftAuthManager.DEFAULT_CLIENT_ID, authorizationCode, // from redirect codeVerifier, MsftAuthManager.DEFAULT_SCOPE ); // ── Step 3: Perform full Xbox + XSTS auth chain ────────────────────────── MsftAuthManager.XboxAuthResult result = MsftAuthManager.performXboxAuth( httpClient, msaToken, context ); // result.xstsToken() → XSTS token for multiplayer.minecraft.net // result.gamertag() → "CoolPlayer123" // result.avatarUrl() → "https://..." // result.device() → XboxDevice (key + device token) // ── Step 4: Fetch Minecraft identity chain ──────────────────────────────── Pair identity = MsftAuthManager.fetchMinecraftIdentity( httpClient, result.xstsToken() ); // identity.first → Minecraft display name // identity.second → XUID // ── Step 5: Persist the account ────────────────────────────────────────── MsftAuthManager.saveAccount(context, msaToken, result.gamertag(), identity.first, identity.second, result.avatarUrl()); // ── Refresh existing account (subsequent launches) ─────────────────────── MsftAccountStore.MsftAccount saved = MsftAccountStore.list(context).get(0); MsftAuthManager.XboxAuthResult refreshed = MsftAuthManager.refreshAndAuth(httpClient, saved, context); ``` ``` -------------------------------- ### List Stored Microsoft/Xbox Accounts Source: https://context7.com/liteldev/levilaunchroid/llms.txt Retrieves a list of all previously stored Microsoft/Xbox accounts. Useful for displaying accounts to the user or for refreshing existing sessions. ```java // List all stored accounts List accounts = MsftAccountStore.list(context); for (MsftAccountStore.MsftAccount acct : accounts) { Log.d("Accounts", acct.id + " | " + acct.xboxGamertag + " | active=" + acct.active + " | xuid=" + acct.xuid); } ``` -------------------------------- ### Find Microsoft/Xbox Account by ID Source: https://context7.com/liteldev/levilaunchroid/llms.txt Retrieves a specific Microsoft/Xbox account using its unique ID. ```java // Find by UUID MsftAccountStore.MsftAccount found = MsftAccountStore.find(context, acct.id); ``` -------------------------------- ### Remove Microsoft/Xbox Account Source: https://context7.com/liteldev/levilaunchroid/llms.txt Removes a Microsoft/Xbox account from storage and also deletes associated XAL token storage for that user. ```java // Remove an account (also deletes XAL token storage for that user) MsftAccountStore.remove(context, acct.id); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.