Skip to content

Instantly share code, notes, and snippets.

@cnaude
Created October 21, 2017 15:40
Show Gist options
  • Save cnaude/9bb754d1cc6037279ceec8c7d1ccfd02 to your computer and use it in GitHub Desktop.
Save cnaude/9bb754d1cc6037279ceec8c7d1ccfd02 to your computer and use it in GitHub Desktop.
Install Optifine into MultiMC instance on Linux workstation
#!/bin/bash
MULTIMCDIR=/home/cnaude/Minecraft/MultiMC
if [[ -z "$2" ]]; then
echo "** Usage: $0 [Optifine.jar] [instance]"
exit 1
fi
FILE=$1
if [ ! -e "$FILE" ]; then
echo "** Unable to read $FILE"
exit 1
fi
JARFILE=$(basename $FILE)
VERSION=$(echo $JARFILE | sed 's/OptiFine_//g' | sed 's/.jar//g')
NEWJAR="OptiFine-${VERSION}.jar"
MCVERSION=$(echo $VERSION | sed 's/OptiFine_//g'| sed 's/_.*//g')
INSTANCE=$2
INSTANCEDIR=${MULTIMCDIR}/instances/${INSTANCE}
PATCHESDIR=${INSTANCEDIR}/patches
LWVERSION=1.12
LIBDIR=${MULTIMCDIR}/libraries/optifine/OptiFine/${VERSION}
if [[ ! -d $LIBDIR ]]; then
mkdir -p $LIBDIR
fi
cp $FILE $LIBDIR/$NEWJAR
if [[ $? -eq 0 ]]; then
echo "** Copied ${FILE} to ${LIBDIR}/${NEWJAR}"
fi
if [[ ! -d $INSTANCEDIR ]]; then
echo "** Unable to find ${INSTANCEDIR}"
echo 1
fi
if [[ ! -d $PATCHESDIR ]]; then
mkdir -p $PATCHESDIR
fi
cat <<JSON > ${INSTANCEDIR}/patches/optifine.json
{
"+libraries": [
{
"name": "net.minecraft:launchwrapper:${LWVERSION}"
},
{
"name": "optifine:OptiFine:${VERSION}",
"MMC-hint": "local"
}
],
"+tweakers": [ "optifine.OptiFineTweaker" ],
"fileId": "optifine.OptiFine",
"mainClass": "net.minecraft.launchwrapper.Launch",
"mcVersion": "${MCVERSION}",
"name": "OptiFine",
"order": 200,
"version": "${VERSION}"
}
JSON
if [ $? -eq 0 ]; then
echo "** Created ${INSTANCEDIR}/patches/optifine.json"
fi
@atiedebee
Copy link

atiedebee commented May 30, 2019

so what do i do with this???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment