Skip to content

Instantly share code, notes, and snippets.

@Abrifq
Last active March 21, 2025 13:29
Show Gist options
  • Save Abrifq/cfc4edd95268880e5b602421df23a297 to your computer and use it in GitHub Desktop.
Save Abrifq/cfc4edd95268880e5b602421df23a297 to your computer and use it in GitHub Desktop.
Update/Patch Optifine in modpack.jar for Tekkit Classic 3.1.2 on Linux
#!/bin/bash
# Huge thanks to https://forums.technicpack.net/topic/21017-how-can-i-remove-optifine-from-tekkit/ for giving me an idea!
# Also huge thanks to Internet Archive and the user sp614x for archiving an old version of optifine! Couldn't do it without them.
#
# Get the link of this file by right clicking the Raw button on upper right corner and clicking "Copy link" or "Copy address"
# Download this to a folder with modpack.jar and run via `. patch-optifine.sh`
# You can download this in a terminal with wget: `wget <link you just copied>` (without the angle brackets, of course)
#
# This file is licensed via GPL-3.0-or-better, so contributions are welcome. ^_^
# Ensure the jar command exists
command -v jar
if [ $? -eq 1 ]
then
echo "are you sure you installed java?"
return 1;
fi
# Ensure modpack.jar exists
if [ ! -f modpack.jar ]
then
echo "modpack.jar is not in this folder!"
echo "copy modpack.jar here and run this script again!"
echo "Try going to the folder and then opening a terminal, then, run this command:"
echo "cp modpack.jar "\'`pwd`\'
return 2;
fi
# Ensure wget exists
command -v wget
if [ $? -eq 1 ]
then
echo "wget not found, please install it."
return 3;
fi
wget --tries=3 https://archive.org/download/opti-fine-1.7.10-hd-u-e-7_202409/OptiFine_1.2.5_HD_U_C7.zip -O optifine.zip
if [ $? -ne 0 ]
then
echo "Failed downloading optifine. Check your internet or the archive.org url."
echo "If the archive.org link has changed or something, try contacting the person who gave you this script."
if [ -f optifine.zip ]; then rm optifine.zip; fi
return 4;
fi
# test both modpack.jar and optifine.zip to make sure we can operate on them
unzip -tq modpack.jar
if [ $? -ne 0 ]
then
echo "modpack.jar file is broken! try to redownload the modpack and copy the file here again."
return 5
fi
unzip -tq optifine.zip
if [ $? -ne 0 ]
then
echo "optifine.zip file is broken! try to contact the person who gave you this script!"
return 6
fi
unzip -q optifine.zip -d optifine
echo "Extracted optifine"
# Make a backup just in case something goes wrong
BACKUPFILENAME='~modpack.jar.from.'`date +%Y_%m_%d__%H_%M_%S`
cp modpack.jar $BACKUPFILENAME
echo "Copied the original modpack.jar file to ${BACKUPFILENAME}."
echo "If you need it for something, you can get it from there."
cd optifine
jar uf ../modpack.jar *.class template.natural.properties ctm.png
SURGERYRESULT=$?
cd ..
rm -r optifine/ optifine.zip
echo "cleaned up optifine files."
if [ $SURGERYRESULT -ne 0 ]
then
echo "couldn't operate on the modpack file."
if [ `stat --printf=%U modpack.jar` -ne `whoami` ]
then
echo "the file is owned by someone else."
echo "try changing the owner to yourself with this command: sudo chown ${USER} modpack.jar"
echo "and try running this script again."
fi
return 7
else
echo "successfully operated on modpack.jar and now you should be able to use optifine without glitches!"
echo "don't forget to copy modpack.jar from here to where you got it from originally."
echo "and if you need the old file back, remember, it's in this folder and named ${BACKUPFILENAME}"
echo "just rename it back to modpack.jar and it will be usable again!"
echo "(use this command for renaming): mv ${BACKUPFILENAME} modpack.jar"
fi
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment