forked from asagilmore/MinecraftSplitscreenSteamdeck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-minecraft-splitscreen.sh
More file actions
executable file
Β·248 lines (218 loc) Β· 9.28 KB
/
install-minecraft-splitscreen.sh
File metadata and controls
executable file
Β·248 lines (218 loc) Β· 9.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#!/bin/bash
# =============================================================================
# Minecraft Splitscreen Steam Deck Installer - MODULAR VERSION
# =============================================================================
#
# This is the new, clean modular entry point for the Minecraft Splitscreen installer.
# All functionality has been moved to organized modules for better maintainability.
# Required modules are automatically downloaded as temporary files when the script runs.
#
# Features:
# - Automatic temporary module downloading (modules are cleaned up after completion)
# - Automatic Java detection and installation
# - Complete Fabric dependency chain implementation
# - API filtering for Fabric-compatible mods (Modrinth + CurseForge)
# - Enhanced error handling with multiple fallback mechanisms
# - User-friendly mod selection interface
# - Steam Deck optimized installation
# - Comprehensive Steam and desktop integration
#
# No additional setup, Java installation, token files, or module downloads required - just run this script.
# Modules are downloaded temporarily and automatically cleaned up when the script completes.
#
# =============================================================================
set -euo pipefail # Exit on error, undefined vars, pipe failures
# =============================================================================
# CLEANUP AND SIGNAL HANDLING
# =============================================================================
# Global variable for modules directory (will be set later)
MODULES_DIR=""
# Cleanup function to remove temporary modules directory
cleanup() {
if [[ -n "$MODULES_DIR" ]] && [[ -d "$MODULES_DIR" ]]; then
echo "π§Ή Cleaning up temporary modules..."
rm -rf "$MODULES_DIR"
fi
}
# Set up trap to cleanup on script exit (normal or error)
trap cleanup EXIT INT TERM
# =============================================================================
# MODULE DOWNLOADING AND LOADING
# =============================================================================
# Get the directory where this script is located
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Create a temporary directory for modules that will be cleaned up automatically
MODULES_DIR="$(mktemp -d -t minecraft-modules-XXXXXX)"
# GitHub repository information (modify these URLs to match your actual repository)
readonly REPO_BASE_URL="https://raw.githubusercontent.com/PeterVive/MinecraftSplitscreenSteamdeck/main/modules"
# List of required module files
readonly MODULE_FILES=(
"utilities.sh"
"java_management.sh"
"launcher_setup.sh"
"version_management.sh"
"lwjgl_management.sh"
"mod_management.sh"
"instance_creation.sh"
"polymc_setup.sh"
"steam_integration.sh"
"desktop_launcher.sh"
"main_workflow.sh"
)
# Function to download modules if they don't exist
download_modules() {
echo "π Downloading required modules to temporary directory..."
echo "π Temporary modules directory: $MODULES_DIR"
echo "π Repository URL: $REPO_BASE_URL"
# Temporarily disable strict error handling for downloads
set +e
# The temporary directory is already created by mktemp
local downloaded_count=0
local failed_count=0
# Download each required module
for module in "${MODULE_FILES[@]}"; do
local module_path="$MODULES_DIR/$module"
local module_url="$REPO_BASE_URL/$module"
echo "β¬οΈ Downloading module: $module"
echo " URL: $module_url"
# Download the module file
if command -v curl >/dev/null 2>&1; then
curl_output=$(curl -fsSL "$module_url" -o "$module_path" 2>&1)
curl_exit_code=$?
if [[ $curl_exit_code -eq 0 ]]; then
chmod +x "$module_path"
((downloaded_count++))
echo "β
Downloaded: $module"
else
echo "β Failed to download: $module"
echo " Curl exit code: $curl_exit_code"
echo " Error: $curl_output"
((failed_count++))
fi
elif command -v wget >/dev/null 2>&1; then
wget_output=$(wget -q "$module_url" -O "$module_path" 2>&1)
wget_exit_code=$?
if [[ $wget_exit_code -eq 0 ]]; then
chmod +x "$module_path"
((downloaded_count++))
echo "β
Downloaded: $module"
else
echo "β Failed to download: $module"
echo " Wget exit code: $wget_exit_code"
echo " Error: $wget_output"
((failed_count++))
fi
else
echo "β Error: Neither curl nor wget is available"
echo "Please install curl or wget to download modules automatically"
echo "Or manually download all modules from: $REPO_BASE_URL"
# Re-enable strict error handling before exiting
set -euo pipefail
exit 1
fi
done
# Re-enable strict error handling
set -euo pipefail
if [[ $failed_count -gt 0 ]]; then
echo "β Failed to download $failed_count module(s)"
echo "βΉοΈ This might be because:"
echo " - The repository doesn't exist or is private"
echo " - The modules haven't been uploaded to the repository yet"
echo " - Network connectivity issues"
echo ""
echo "π§ For now, you can place the modules manually in the same directory as this script:"
echo " mkdir -p '$SCRIPT_DIR/modules'"
echo " # Then copy all .sh module files to that directory"
echo ""
echo "π Or check if the repository exists at: https://github.com/PeterVive/MinecraftSplitscreenSteamdeck"
exit 1
fi
echo "β
Downloaded $downloaded_count module(s) to temporary directory"
echo "βΉοΈ Modules will be automatically cleaned up when script completes"
}
# Download modules if needed
# First check if modules exist locally, if not try to download them
if [[ -d "$SCRIPT_DIR/modules" ]]; then
echo "π Found local modules directory, copying to temporary location..."
cp -r "$SCRIPT_DIR/modules/"* "$MODULES_DIR/"
chmod +x "$MODULES_DIR"/*.sh
echo "β
Copied local modules to temporary directory"
else
download_modules
fi
# Verify all modules are now present
for module in "${MODULE_FILES[@]}"; do
if [[ ! -f "$MODULES_DIR/$module" ]]; then
echo "β Error: Required module missing: $module"
echo "Please check your internet connection or download manually from:"
echo "$REPO_BASE_URL/$module"
exit 1
fi
done
# Source all module files to load their functions
# Load modules in dependency order
source "$MODULES_DIR/utilities.sh"
source "$MODULES_DIR/java_management.sh"
source "$MODULES_DIR/launcher_setup.sh"
source "$MODULES_DIR/version_management.sh"
source "$MODULES_DIR/lwjgl_management.sh"
source "$MODULES_DIR/mod_management.sh"
source "$MODULES_DIR/instance_creation.sh"
source "$MODULES_DIR/polymc_setup.sh"
source "$MODULES_DIR/steam_integration.sh"
source "$MODULES_DIR/desktop_launcher.sh"
source "$MODULES_DIR/main_workflow.sh"
# =============================================================================
# GLOBAL VARIABLES
# =============================================================================
# Script configuration paths
readonly TARGET_DIR="$HOME/.local/share/PrismLauncher"
readonly POLYMC_DIR="$HOME/.local/share/PolyMC"
# Runtime variables (set during execution)
JAVA_PATH=""
MC_VERSION=""
FABRIC_VERSION=""
LWJGL_VERSION=""
USE_POLYMC=false
# Mod configuration arrays
declare -a REQUIRED_SPLITSCREEN_MODS=("Controllable (Fabric)" "Splitscreen Support")
declare -a REQUIRED_SPLITSCREEN_IDS=("317269" "yJgqfSDR")
# Master list of all available mods with their metadata
# Format: "Mod Name|platform|mod_id"
declare -a MODS=(
"Better Name Visibility|modrinth|pSfNeCCY"
"Controllable (Fabric)|curseforge|317269"
"Full Brightness Toggle|modrinth|aEK1KhsC"
"In-Game Account Switcher|modrinth|cudtvDnd"
"Just Zoom|modrinth|iAiqcykM"
"Legacy4J|modrinth|gHvKJofA"
"Mod Menu|modrinth|mOgUt4GM"
"Old Combat Mod|modrinth|dZ1APLkO"
"Reese's Sodium Options|modrinth|Bh37bMuy"
"Sodium|modrinth|AANobbMI"
"Sodium Dynamic Lights|modrinth|PxQSWIcD"
"Sodium Extra|modrinth|PtjYWJkn"
"Sodium Extras|modrinth|vqqx0QiE"
"Sodium Options API|modrinth|Es5v4eyq"
"Splitscreen Support|modrinth|yJgqfSDR"
)
# Runtime mod tracking arrays (populated during execution)
declare -a SUPPORTED_MODS=()
declare -a MOD_DESCRIPTIONS=()
declare -a MOD_URLS=()
declare -a MOD_IDS=()
declare -a MOD_TYPES=()
declare -a MOD_DEPENDENCIES=()
declare -a FINAL_MOD_INDEXES=()
declare -a MISSING_MODS=()
# =============================================================================
# SCRIPT ENTRY POINT
# =============================================================================
# Execute main function if script is run directly
# This allows the script to be sourced for testing without auto-execution
if [[ "${BASH_SOURCE[0]}" == "${0}" ]] && [[ -z "${TESTING_MODE:-}" ]]; then
main "$@"
fi
# =============================================================================
# END OF MODULAR MINECRAFT SPLITSCREEN INSTALLER
# =============================================================================