Created
November 1, 2026 15:28
-
-
Save randerzander/02efe1ae2c9c1936ec8e99c94cb2f18b to your computer and use it in GitHub Desktop.
Cross-platform Minecraft Java offline-profile launcher for Linux and macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # Launch the latest vanilla Java Edition with a local/offline username. | |
| # Supported on Linux and macOS (Intel and Apple Silicon). | |
| # Usage: ./start-client.sh [username] [version] | |
| # Overrides: MC_USERNAME=Player, MC_VERSION=release, MC_MEMORY=4G | |
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" | |
| CLIENT_DIR="$SCRIPT_DIR/client" | |
| VENV_DIR="$CLIENT_DIR/launcher-venv" | |
| USERNAME="${1:-${MC_USERNAME:-Dad}}" | |
| VERSION="${2:-${MC_VERSION:-release}}" | |
| MC_MEMORY="${MC_MEMORY:-4G}" | |
| if [[ ! "$USERNAME" =~ ^[A-Za-z0-9_]{3,16}$ ]]; then | |
| echo "Username must be 3-16 characters using only letters, numbers, and underscores." >&2 | |
| exit 1 | |
| fi | |
| case "$(uname -s)" in | |
| Linux|Darwin) ;; | |
| *) echo "This script currently supports Linux and macOS." >&2; exit 1 ;; | |
| esac | |
| if ! command -v python3 >/dev/null 2>&1; then | |
| echo "Python 3 is required." >&2 | |
| if [[ "$(uname -s)" == "Darwin" ]]; then | |
| echo "On macOS, install it with Homebrew: brew install python" >&2 | |
| fi | |
| exit 1 | |
| fi | |
| mkdir -p "$CLIENT_DIR" | |
| if [[ ! -x "$VENV_DIR/bin/python" ]]; then | |
| echo "Creating the local launcher environment..." | |
| if ! python3 -m venv "$VENV_DIR"; then | |
| echo "Could not create a Python virtual environment." >&2 | |
| if [[ "$(uname -s)" == "Darwin" ]]; then | |
| echo "Install Homebrew Python with: brew install python" >&2 | |
| fi | |
| exit 1 | |
| fi | |
| fi | |
| echo "Updating PortableMC..." | |
| "$VENV_DIR/bin/python" -m pip install --quiet --upgrade portablemc | |
| echo "Launching Minecraft $VERSION as '$USERNAME' (offline profile)..." | |
| echo "This profile can join this project's local server, but not online-mode servers." | |
| exec "$VENV_DIR/bin/python" -m portablemc \ | |
| --main-dir "$CLIENT_DIR/game" \ | |
| start "$VERSION" \ | |
| --username "$USERNAME" \ | |
| "--jvm-arg=-Xmx${MC_MEMORY}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment