Skip to content

Instantly share code, notes, and snippets.

@niw
Last active January 15, 2022 03:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niw/21160b97b1cd30cae322f768aba73573 to your computer and use it in GitHub Desktop.
Save niw/21160b97b1cd30cae322f768aba73573 to your computer and use it in GitHub Desktop.
A simple patch script to workaround Minecraft nativeUpdater crash on macOS Monterey
#!/usr/bin/env bash
set -euo pipefail
readonly MINECRAFT_APP_PATH=/Applications/Minecraft.app
if [[ ! -d $MINECRAFT_APP_PATH ]]; then
echo "$MINECRAFT_APP_PATH is not found." >&2
exit 1
fi
readonly NATIVE_UPDATER_PATH="$MINECRAFT_APP_PATH/Contents/Minecraft Updater.app/Contents/MacOS/nativeUpdater"
if [[ ! -f $NATIVE_UPDATER_PATH ]]; then
echo "$NATIVE_UPDATER_PATH is not found." >&2
exit 1
fi
readonly NATIVE_UPDATER_SHA256=$(cat "$NATIVE_UPDATER_PATH"|openssl dgst -sha256 -hex)
case $NATIVE_UPDATER_SHA256 in
85e795049588f459ee4fe573a3080aed52bb524de12d82340cd0a861bca1cf8e)
POSITION="0x572f"
;;
c25ed91f224073c52d276118505fd9d0110815c8f63776a4da2d336ffd595e04)
POSITION="0x54af"
;;
d4d74c70864a62bda7d862660a125165bc4b8aa03571addc53e509bc7729055e | \
d895fa1eb349ad1e1f73c23cfe37b371bc1f1b570dcb7f34239469ea0202363e)
echo "Patch has been applied to $NATIVE_UPDATER_PATH. SHA256 = $NATIVE_UPDATER_SHA256" >&2
exit 1
;;
*)
echo "Unknown $NATIVE_UPDATER_PATH binary. SHA256 = $NATIVE_UPDATER_SHA256" >&2
exit 1
;;
esac
readonly POSITION
xattr -r -d com.apple.quarantine "$MINECRAFT_APP_PATH"
codesign --remove-signature "$NATIVE_UPDATER_PATH"
readonly BYTE=$(dd if="$NATIVE_UPDATER_PATH" bs=1 count=1 skip=$POSITION 2>/dev/null|xxd -p)
if [[ $BYTE != "74" ]]; then
echo "Unknown instruction at $POSITION: $BYTE" >&2
exit 1
fi
printf "\xeb"|dd conv=notrunc of="$NATIVE_UPDATER_PATH" bs=1 seek=$POSITION 2>/dev/null
echo "Patched."
@niw
Copy link
Author

niw commented Nov 20, 2021

@boodahDEV
Copy link

Thanks friend! Your script helped me a lot ...
The truth was I had days trying to solve somehow being able to play Minecraft on my Mac with Monterey with this error.
Justo had little more than 3 weeks without being able to play. I thank you a lot.

Thanks!

@dhje0ng
Copy link

dhje0ng commented Dec 19, 2021

Thank you. I solved the crash problem that occurs in mac os 12.1 month through this script.

@george-popa-repos
Copy link

You are the best. Thank you very much! Solved the issue

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