#!/bin/bash
# Aetherbound: clean up Forge natives + macOS quarantine flags.
# Double-click whenever TLauncher errors with
# "A fájl írási művelete tilos .../1.20.1-forge-47.4.9/natives".
#
# Standalone version — auto-detects .minecraft. Use this if you can't find
# the copy that lives inside .minecraft, or if you never re-ran the
# installer.

MC=""
for d in \
  "$HOME/Library/Application Support/minecraft" \
  "$HOME/Library/Application Support/.minecraft" \
  "$HOME/.minecraft"; do
  if [ -d "$d" ]; then MC="$d"; break; fi
done
if [ -z "$MC" ]; then
  echo "No Minecraft folder found. Run install-mac.command first."
  read -n 1 -s -r -p "Press any key to close..."; echo; exit 1
fi

echo "Cleaning $MC ..."
rm -rf "$MC/versions/1.20.1-forge-47.4.9/natives"
chmod -R u+w "$MC" 2>/dev/null
xattr -dr com.apple.quarantine "$MC" 2>/dev/null
echo
echo "Done. Now open TLauncher and click Play."
echo "(Settings -> Java must still point at:"
echo " $MC/aetherbound-jdk17/Contents/Home/bin/java )"
read -n 1 -s -r -p "Press any key to close..."
echo
