@echo off
color 2F

:: To change text color and background color of lines
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do     rem"') do (
  set "DEL=%%a"
)


:: Install forge
echo.
echo --------------------------------------- Forge Installation ----------------------------------------
echo.
call :colorEcho 2a " - Installing Forge"
echo.
javaw -jar "%CD%\forge\forge-1.16.1.jar"
call :colorEcho 2a " - Forge installation done"
del *.log
echo.







:: Check if mods folder exists, if not create folder
echo.
echo -------------------------------- Check if the 'mods' folder exists --------------------------------
echo.
call :colorEcho 2a " - Checking if mods folder exists..."
echo.
IF NOT EXIST C:\Users\%USERNAME%\AppData\Roaming\.minecraft\mods (
    call :colorEcho 2c "    - Mods folder doesn't exist..."
    echo.
    call :colorEcho 2a "    - Creating mods folder..."
    echo.
    mkdir "C:\Users\%USERNAME%\AppData\Roaming\.minecraft\mods"
    call :colorEcho 2a "    - Folder created!"
    echo.
)
call :colorEcho 2a "    - Folder already exists!"
echo.
echo.
echo ------------------------------- Check if the mods are in the folder -------------------------------
echo.

IF NOT EXIST "C:\Users\%USERNAME%\AppData\Roaming\.minecraft\mods\mod*.jar" (
  :: Transfering mods to the Minecraft mods folder
  call :colorEcho 2c " - Mods not in the folder. Transfering mods to the Minecraft mods folder..."
  echo.
  copy "%CD%\mods\mod*.jar" "C:\Users\%USERNAME%\AppData\Roaming\.minecraft\mods" >nul 2>&1
  echo.
  echo ------------------------------------ Opening Minecraft folder -------------------------------------
  echo.
) else (
  call :colorEcho 2a " - Skiping file transfer. Files already in the folder..."
  echo.
  echo.
  echo ------------------------------------ Opening Minecraft folder -------------------------------------
  echo.
)


:: Open the .minecraft folder (Minecraft files)
call :colorEcho 2a " - Opening Minecraft folder..."
echo.
%SystemRoot%\explorer.exe "C:\Users\%USERNAME%\AppData\Roaming\.minecraft"
echo.
echo ------------------------------------------ Exit program -------------------------------------------
echo.
:: Pause batch file and ask to exit setup
pause>nul|set/p =Press any key to exit setup...
exit


:: Colors
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i