Java And Minecraft


Java, and therefore Minecraft, have a shitty habit of breaking (certainly consistently for me) with random things as non rendering textures, missing polygons and the dreaded "white screen of death" on Minecraft bootup.

On top of that the technic launcher (which is a great tool) doesn't appear to work well with the standard JRE from the Arch Linux repos. It doesn't appear to define a main class and so java just breaks with a fatal error. To fix that you need to launch the jar file with a specific class loading.

I created this really quick and dirty script (not fully tested) to move the current tekkit folder to a backup area and then redownload it.

Edit: Updated the script to provide better basic functions, including an option to restore from a backup.

#!/bin/bash switch=${1,,} # General variables technicDir="~/.techniclauncher" curDate=$(date +%d+m+y) curDir="$technicDir/tekkit" cleDir () { oldDate=$(date --date="-"$old"days" +%d%m%y) oldDir="$technicDir/backup/$oldDate" for old in $(seq 7 28); do # Checks for three weeks of backups if [ -d "$oldDir" ]; then # Check if the old backup exist rm -rf $oldDir # Removes oldest 2 weeks fi done echo "Old backups pruned." } bakDir () { if [ -d "$curDir" ]; then # Check the tekkit folder exists cp -R $technicDir/tekkit $technicDir/backup/$curDate else echo "No Tekkit folder found, chances are it's already backed up." exit 0 fi } resDir () { usrDate=$2 # Get the date to restore if [ -d "$resDir" ]; then # Check the backup exists $resDir="$technicDir/backup/$usrDate" bakDir # Backup current directory first cp -R $resDir $curDir # Copy the backup to the real tekkit folder else echo "Backup from date selected not found!" exit 0 fi } playGame () { # Run the technic launcher (change memory as required) LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$JAVA_HOME/lib/amd64/:$JAVA_HOME/lib/i386/:$JAVA_HOME/jre/lib/amd64/:$JAVA_HOME/jre/lib/i386/" # Change paths as required exec /opt/java/jre/bin/java -Xmx4096M -Xms4096M -cp /opt/games/technic/technic.jar org.spoutcraft.launcher.Main $@ } showHelp () { echo -e "-b --backup\t\tBackup the currently active Tekkit folder" echo -e "-r --restore\t\tRestore a backup from a set date [DDMMYY]" echo -e "-p --play\t\tPlay the gme!" echo -e "Anthing else will show this help message." } # Switch checking if [[ $switch == "-b" || $switch == "--backup" ]]; then cleDir bakDir exit 0 elif [[ $switch == "-r" || $switch == "--restore" ]]; then resDir exit 0 elif [[ $switch == "-p" || $switch == "--play" ]]; then playGame exit 0 else showHelp exit 0 fi