#!/bin/bash # ============================================================================= # Minecraft Splitscreen Steam Deck Installer - Main Workflow Module # ============================================================================= # # This module contains the main orchestration logic for the complete splitscreen # installation process. It coordinates all the other modules and provides # comprehensive status reporting and user guidance. # # Functions provided: # - main: Primary function that orchestrates the complete installation process # # ============================================================================= # main: Primary function that orchestrates the complete splitscreen installation process # # INSTALLATION WORKFLOW: # 1. WORKSPACE SETUP: Create directories and initialize environment # 2. CORE SETUP: Java detection, PrismLauncher download, CLI verification # 3. VERSION DETECTION: Minecraft and Fabric version determination # 4. ACCOUNT SETUP: Download offline splitscreen player accounts # 5. MOD COMPATIBILITY: Query APIs and determine compatible mod versions # 6. USER SELECTION: Interactive mod selection interface # 7. INSTANCE CREATION: Create 4 splitscreen instances with PrismLauncher CLI # 8. LAUNCHER OPTIMIZATION: Setup PollyMC and cleanup PrismLauncher (if successful) # 9. INTEGRATION: Optional Steam and desktop launcher integration # 10. COMPLETION: Summary report and usage instructions # # ERROR HANDLING STRATEGY: # - Each phase has fallback mechanisms to ensure installation can complete # - Non-critical failures (like PollyMC setup) don't halt the entire process # - Comprehensive error reporting helps users understand any issues # - Multiple validation checkpoints ensure data integrity # # DUAL-LAUNCHER APPROACH: # The script uses an optimized strategy combining two launchers: # - PrismLauncher: CLI automation for reliable instance creation with proper Fabric setup # - PollyMC: Offline-friendly gameplay launcher without forced authentication # - Smart cleanup: Removes PrismLauncher after successful PollyMC setup to save space main() { print_header "๐ŸŽฎ MINECRAFT SPLITSCREEN INSTALLER ๐ŸŽฎ" print_info "Advanced installation system with dual-launcher optimization" print_info "Strategy: PrismLauncher CLI automation โ†’ PollyMC gameplay โ†’ Smart cleanup" echo "" # ============================================================================= # WORKSPACE INITIALIZATION PHASE # ============================================================================= # WORKSPACE SETUP: Create and navigate to working directory # All temporary files, downloads, and initial setup happen in TARGET_DIR # This provides a clean, isolated environment for the installation process print_progress "Initializing installation workspace: $TARGET_DIR" mkdir -p "$TARGET_DIR" cd "$TARGET_DIR" || exit 1 print_success "โœ… Workspace initialized successfully" # ============================================================================= # CORE SYSTEM REQUIREMENTS VALIDATION # ============================================================================= download_prism_launcher # Download PrismLauncher AppImage for CLI automation if ! verify_prism_cli; then # Test CLI functionality (non-fatal if it fails) print_info "PrismLauncher CLI unavailable - will use manual instance creation" fi # ============================================================================= # VERSION DETECTION AND CONFIGURATION # ============================================================================= get_minecraft_version # Determine target Minecraft version (user choice or latest) detect_java # Automatically detect, install, and configure correct Java version for selected Minecraft version get_fabric_version # Get compatible Fabric loader version from API get_lwjgl_version # Detect appropriate LWJGL version for Minecraft version # ============================================================================= # OFFLINE ACCOUNTS CONFIGURATION # ============================================================================= print_progress "Setting up offline accounts for splitscreen gameplay..." print_info "Downloading pre-configured offline accounts for Player 1-4" # OFFLINE ACCOUNTS DOWNLOAD: Get splitscreen player account configurations # These accounts enable splitscreen without requiring multiple Microsoft accounts # Each player (P1, P2, P3, P4) gets a separate offline profile for identification if ! wget -O accounts.json "https://raw.githubusercontent.com/FlyingEwok/MinecraftSplitscreenSteamdeck/main/accounts.json"; then print_warning "โš ๏ธ Failed to download accounts.json from repository" print_info " โ†’ Attempting to use local copy if available..." if [[ ! -f "accounts.json" ]]; then print_error "โŒ No accounts.json found - splitscreen accounts may require manual setup" print_info " โ†’ Splitscreen will still work but players may have generic names" fi else print_success "โœ… Offline splitscreen accounts configured successfully" print_info " โ†’ P1, P2, P3, P4 player accounts ready for offline gameplay" fi # ============================================================================= # MOD ECOSYSTEM SETUP PHASE # ============================================================================= check_mod_compatibility # Query Modrinth/CurseForge APIs for compatible versions select_user_mods # Interactive mod selection interface with categories # ============================================================================= # MINECRAFT INSTANCE CREATION PHASE # ============================================================================= create_instances # Create 4 splitscreen instances using PrismLauncher CLI with comprehensive fallbacks # ============================================================================= # LAUNCHER OPTIMIZATION PHASE: Advanced launcher configuration # ============================================================================= setup_pollymc # Download PollyMC, migrate instances, verify, cleanup PrismLauncher # ============================================================================= # SYSTEM INTEGRATION PHASE: Optional platform integration # ============================================================================= setup_steam_integration # Add splitscreen launcher to Steam library (optional) create_desktop_launcher # Create native desktop launcher and app menu entry (optional) # ============================================================================= # INSTALLATION COMPLETION AND STATUS REPORTING # ============================================================================= print_header "๐ŸŽ‰ INSTALLATION ANALYSIS AND COMPLETION REPORT" # ============================================================================= # MISSING MODS ANALYSIS: Report any compatibility issues # ============================================================================= # MISSING MODS REPORT: Alert user to any mods that couldn't be installed # This helps users understand if specific functionality might be unavailable # Common causes: no Fabric version available, API changes, temporary download issues local missing_count=0 if [[ ${#MISSING_MODS[@]} -gt 0 ]]; then missing_count=${#MISSING_MODS[@]} fi if [[ $missing_count -gt 0 ]]; then echo "" print_warning "=====================" print_warning "โš ๏ธ MISSING MODS ANALYSIS" print_warning "=====================" print_warning "The following mods could not be installed:" print_info "Common causes: No compatible Fabric version, API issues, download failures" echo "" for mod in "${MISSING_MODS[@]}"; do echo " โŒ $mod" done print_warning "=====================" print_info "These mods can be installed manually later if compatible versions become available" print_info "The splitscreen functionality will work without these optional mods" fi # ============================================================================= # COMPREHENSIVE INSTALLATION SUCCESS REPORT # ============================================================================= echo "" echo "==========================================" echo "๐ŸŽฎ MINECRAFT SPLITSCREEN INSTALLATION COMPLETE! ๐ŸŽฎ" echo "==========================================" echo "" # ============================================================================= # LAUNCHER STRATEGY SUCCESS ANALYSIS # ============================================================================= # LAUNCHER STRATEGY REPORT: Explain which approach was successful and the benefits # The dual-launcher approach provides the best of both worlds when successful if [[ "$USE_POLLYMC" == true ]]; then echo "โœ… OPTIMIZED INSTALLATION SUCCESSFUL!" echo "" echo "๐Ÿ”ง DUAL-LAUNCHER STRATEGY COMPLETED:" echo " ๐Ÿ› ๏ธ PrismLauncher: CLI automation for reliable instance creation โœ… COMPLETED" echo " ๐ŸŽฎ PollyMC: Primary launcher for offline splitscreen gameplay โœ… ACTIVE" echo " ๐Ÿงน Smart cleanup: Removes PrismLauncher after successful setup โœ… CLEANED" echo "" echo "๐ŸŽฏ STRATEGY BENEFITS ACHIEVED:" echo " โ€ข Reliable instance creation through proven CLI automation" echo " โ€ข Offline-friendly gameplay without forced Microsoft login prompts" echo " โ€ข Optimized disk usage through intelligent cleanup" echo " โ€ข Best performance for splitscreen scenarios" echo "" echo "โœ… Primary launcher: PollyMC (optimized for splitscreen)" echo "โœ… All instances migrated and verified in PollyMC" echo "โœ… Temporary PrismLauncher files cleaned up successfully" else echo "โœ… FALLBACK INSTALLATION SUCCESSFUL!" echo "" echo "๐Ÿ”ง FALLBACK STRATEGY USED:" echo " ๐Ÿ› ๏ธ PrismLauncher: Instance creation + primary launcher โœ… ACTIVE" echo " โš ๏ธ PollyMC: Download/setup encountered issues, using PrismLauncher for everything" echo "" echo "๐Ÿ“‹ FALLBACK EXPLANATION:" echo " โ€ข PollyMC setup failed (network issues, system compatibility, or download problems)" echo " โ€ข PrismLauncher provides full functionality as backup launcher" echo " โ€ข Splitscreen works perfectly with PrismLauncher" echo "" echo "โœ… Primary launcher: PrismLauncher (proven reliability)" echo "โš ๏ธ Note: PollyMC optimization unavailable, but full functionality preserved" fi # ============================================================================= # TECHNICAL ACHIEVEMENT SUMMARY # ============================================================================= # INSTALLATION COMPONENTS SUMMARY: List all successfully completed setup elements echo "" echo "๐Ÿ† TECHNICAL ACHIEVEMENTS COMPLETED:" echo "โœ… Java 21+ detection and configuration" echo "โœ… Automated instance creation via PrismLauncher CLI" echo "โœ… Complete Fabric dependency chain implementation" echo "โœ… 4 splitscreen instances created and configured (Player 1-4)" echo "โœ… Fabric mod loader installation with proper dependency resolution" echo "โœ… Compatible mod versions detected and downloaded via API filtering" echo "โœ… Splitscreen-specific configurations applied to all instances" echo "โœ… Offline player accounts configured for splitscreen gameplay" echo "โœ… Java memory settings optimized for splitscreen performance" echo "โœ… Instance verification and launcher registration completed" echo "โœ… Comprehensive automatic dependency resolution system" echo "" # ============================================================================= # USER GUIDANCE AND LAUNCH INSTRUCTIONS # ============================================================================= echo "๐Ÿš€ READY TO PLAY SPLITSCREEN MINECRAFT!" echo "" # LAUNCH METHODS: Comprehensive guide to starting splitscreen Minecraft echo "๐ŸŽฎ HOW TO LAUNCH SPLITSCREEN MINECRAFT:" echo "" # PRIMARY LAUNCH METHOD: Direct script execution echo "1. ๐Ÿ”ง DIRECT LAUNCH (Recommended):" if [[ "$USE_POLLYMC" == true ]]; then echo " Command: $HOME/.local/share/PollyMC/minecraftSplitscreen.sh" echo " Description: Optimized PollyMC launcher with automatic controller detection" else echo " Command: $TARGET_DIR/minecraftSplitscreen.sh" echo " Description: PrismLauncher-based splitscreen with automatic controller detection" fi echo "" # ALTERNATIVE LAUNCH METHODS: Other integration options echo "2. ๐Ÿ–ฅ๏ธ DESKTOP LAUNCHER:" echo " Method: Double-click desktop shortcut or search 'Minecraft Splitscreen' in app menu" echo " Availability: $(if [[ -f "$HOME/Desktop/MinecraftSplitscreen.desktop" ]]; then echo "โœ… Configured"; else echo "โŒ Not configured"; fi)" echo "" echo "3. ๐ŸŽฏ STEAM INTEGRATION:" echo " Method: Launch from Steam library or Big Picture mode" echo " Benefits: Steam Deck Game Mode integration, Steam Input support" echo " Availability: $(if grep -q "PollyMC\|PrismLauncher" ~/.steam/steam/userdata/*/config/shortcuts.vdf 2>/dev/null; then echo "โœ… Configured"; else echo "โŒ Not configured"; fi)" echo "" # ============================================================================= # SYSTEM REQUIREMENTS AND TECHNICAL DETAILS # ============================================================================= echo "โš™๏ธ SYSTEM CONFIGURATION DETAILS:" echo "" # LAUNCHER DETAILS: Technical information about the setup if [[ "$USE_POLLYMC" == true ]]; then echo "๐Ÿ› ๏ธ LAUNCHER CONFIGURATION:" echo " โ€ข Instance creation: PrismLauncher CLI (automated)" echo " โ€ข Gameplay launcher: PollyMC (offline-optimized)" echo " โ€ข Strategy: Best of both worlds approach" echo " โ€ข Benefits: CLI automation + offline gameplay + no forced login" else echo "๐Ÿ› ๏ธ LAUNCHER CONFIGURATION:" echo " โ€ข Primary launcher: PrismLauncher (all functions)" echo " โ€ข Strategy: Single launcher approach" echo " โ€ข Note: PollyMC optimization unavailable, but fully functional" fi echo "" # MINECRAFT ACCOUNT REQUIREMENTS: Important user information echo "๐Ÿ’ณ ACCOUNT REQUIREMENTS:" if [[ "$USE_POLLYMC" == true ]]; then echo " โ€ข Microsoft account: Required for initial setup and updates" echo " โ€ข Account type: PAID Minecraft Java Edition required" echo " โ€ข Login frequency: Minimal (PollyMC is offline-friendly)" echo " โ€ข Splitscreen: Uses offline accounts (P1, P2, P3, P4) after initial login" else echo " โ€ข Microsoft account: Required for launcher access" echo " โ€ข Account type: PAID Minecraft Java Edition required" echo " โ€ข Note: PrismLauncher may prompt for periodic authentication" echo " โ€ข Splitscreen: Uses offline accounts (P1, P2, P3, P4) after login" fi echo "" # CONTROLLER INFORMATION: Hardware requirements and tips echo "๐ŸŽฎ CONTROLLER CONFIGURATION:" echo " โ€ข Supported: Xbox, PlayStation, generic USB/Bluetooth controllers" echo " โ€ข Detection: Automatic (1-4 controllers supported)" echo " โ€ข Steam Deck: Built-in controls + external controllers" echo " โ€ข Recommendation: Use wired controllers for best performance" echo "" # ============================================================================= # INSTALLATION LOCATION SUMMARY # ============================================================================= echo "๐Ÿ“ INSTALLATION LOCATIONS:" if [[ "$USE_POLLYMC" == true ]]; then echo " โ€ข Primary installation: $HOME/.local/share/PollyMC/" echo " โ€ข Launcher executable: $HOME/.local/share/PollyMC/PollyMC-Linux-x86_64.AppImage" echo " โ€ข Splitscreen script: $HOME/.local/share/PollyMC/minecraftSplitscreen.sh" echo " โ€ข Instance data: $HOME/.local/share/PollyMC/instances/" echo " โ€ข Account configuration: $HOME/.local/share/PollyMC/accounts.json" echo " โ€ข Temporary build files: Successfully removed after setup โœ…" else echo " โ€ข Primary installation: $TARGET_DIR" echo " โ€ข Launcher executable: $TARGET_DIR/PrismLauncher.AppImage" echo " โ€ข Splitscreen script: $TARGET_DIR/minecraftSplitscreen.sh" echo " โ€ข Instance data: $TARGET_DIR/instances/" echo " โ€ข Account configuration: $TARGET_DIR/accounts.json" fi echo "" # ============================================================================= # ADVANCED TECHNICAL FEATURE SUMMARY # ============================================================================= echo "๐Ÿ”ง ADVANCED FEATURES IMPLEMENTED:" echo " โ€ข Complete Fabric dependency chain with proper version matching" echo " โ€ข API-based mod compatibility verification (Modrinth + CurseForge)" echo " โ€ข Sophisticated version parsing with semantic version support" echo " โ€ข Automatic dependency resolution and installation" echo " โ€ข Enhanced error handling with multiple fallback strategies" echo " โ€ข Instance verification and launcher registration" echo " โ€ข Smart cleanup with disk space optimization" if [[ "$USE_POLLYMC" == true ]]; then echo " โ€ข Dual-launcher optimization strategy successfully implemented" fi echo " โ€ข Cross-platform Linux compatibility (Steam Deck + Desktop)" echo " โ€ข Professional Steam and desktop environment integration" echo "" # ============================================================================= # FINAL SUCCESS MESSAGE AND NEXT STEPS # ============================================================================= # Display summary of any optional dependencies that couldn't be installed local missing_summary_count=0 if [[ ${#MISSING_MODS[@]} -gt 0 ]]; then missing_summary_count=${#MISSING_MODS[@]} fi if [[ $missing_summary_count -gt 0 ]]; then echo "" echo "๐Ÿ“‹ INSTALLATION SUMMARY" echo "=======================" echo "The following optional dependencies could not be installed:" for missing_mod in "${MISSING_MODS[@]}"; do echo " โ€ข $missing_mod" done echo "" echo "โ„น๏ธ These are typically optional dependencies that don't support Minecraft $MC_VERSION" echo " The core splitscreen functionality will work perfectly without them." echo "" fi echo "๐ŸŽ‰ INSTALLATION COMPLETE - ENJOY SPLITSCREEN MINECRAFT! ๐ŸŽ‰" echo "" echo "Next steps:" echo "1. Connect your controllers (1-4 supported)" echo "2. Launch using any of the methods above" echo "3. The system will automatically detect controller count and launch appropriate instances" echo "4. Each player gets their own screen and can play independently" echo "" echo "For troubleshooting or updates, visit:" echo "https://github.com/FlyingEwok/MinecraftSplitscreenSteamdeck" echo "==========================================" }