Skip to content

Instantly share code, notes, and snippets.

@velnias75
Last active January 31, 2023 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velnias75/f7a6e44b1dc114a95264fcb47dc35fed to your computer and use it in GitHub Desktop.
Save velnias75/f7a6e44b1dc114a95264fcb47dc35fed to your computer and use it in GitHub Desktop.
Transparent fabric mod folder version switcher for Minecraft
#!/bin/bash
export DRI_PRIME=1
export vblank_mode=0
$DROPCACHES="$HOME/bin/drop_caches.sh"
if [ -x $DROPCACHES ];
then
sync
sudo $DROPCACHES
fi
sudo cpufreq-set -c 0 -g schedutil
sudo cpufreq-set -c 1 -g schedutil
OPWD=`pwd`
CMD="$@"
if [[ "$CMD" == *"JavaCheck.jar"* ]]
then
exit 1
fi
GAMEDIR=`echo $CMD | grep -o "\\-\\-gameDir [^ ]*" | sed 's/--gameDir //'`
cd $GAMEDIR
FABVER=`echo $CMD | grep -o "\\-\\-version fabric\-loader\-\([0-9\\.\\-]\)*"`
if [[ $FABVER =~ \-\-version\ fabric\-loader\-([0-9\.]+)\-([0-9\.]+) ]]
then
MCVER="${BASH_REMATCH[2]}"
fi
case $MCVER in
"1.16.5")
JVM="/opt/graalvm-ce-java11-21.1.0/bin/java"
JOPTS=""
;;
*)
JVM="/opt/graalvm-ce-java19-22.3.1/bin/java" ;
JOPTS="-Djava.net.preferIPv6Addresses=true -XX:+EnableJVMCI -XX:+UseJVMCICompiler -Dgraal.LoopRotation=true -Dgraal.PartialUnroll=true -Dgraal.VectorizeSIMD=true -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1"
;;
esac
MODFOLDER="$GAMEDIR/mods.$MCVER"
if [ -d "$MODFOLDER" ];
then
rm -rf mods
ln -s $MODFOLDER "$GAMEDIR/mods"
fi
cd $OPWD
exec obs-glcapture nice -n -16 $JVM "$@" $JOPTS
sudo cpufreq-set -c 1 -g ondemand
sudo cpufreq-set -c 0 -g ondemand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment