From cae5b33c3b63220d584d6e1fc290c9c9533d91bf Mon Sep 17 00:00:00 2001 From: Darto KLoning Date: Sat, 3 Oct 2026 16:02:19 +0700 Subject: [PATCH] dining bench facing fix --- PORTING-NOTES.md | 4 + compile.bat | 337 ------------------ compile.sh | 125 ------- gradle.properties | 2 +- .../common/blocks/DiningBenchBlock.java | 6 +- test.bat | 39 -- test.sh | 28 -- workflow.bat | 203 +++++++++++ workflow.sh | 178 +++++++++ 9 files changed, 391 insertions(+), 531 deletions(-) delete mode 100644 compile.bat delete mode 100644 compile.sh delete mode 100644 test.bat delete mode 100644 test.sh create mode 100644 workflow.bat create mode 100644 workflow.sh diff --git a/PORTING-NOTES.md b/PORTING-NOTES.md index e89d331..15f653f 100644 --- a/PORTING-NOTES.md +++ b/PORTING-NOTES.md @@ -126,3 +126,7 @@ The remaining major migration area is the 26.2 extract/submit rendering pipeline - Removed client-side fake success from `SittableBlock.sitOn`; `Seat.sit` is server-authoritative like the reference implementation. - Seat blocks now return `SUCCESS` after the empty-hand interaction attempt, matching the reference block behavior. - Added concise server-side Seat attempt/result diagnostics so a failed mount is visible in `latest.log`. + +## 4.0.15-fabric-26.2 +- Dining Bench now captures the player's horizontal facing when sitting, instead of creating a free-rotation seat with a fixed initial world yaw. +- This lets the same Dining Bench be used from either side: face north and sit north, face south and sit south, independent of the bench's placement facing. diff --git a/compile.bat b/compile.bat deleted file mode 100644 index 31617a9..0000000 --- a/compile.bat +++ /dev/null @@ -1,337 +0,0 @@ -@echo off -setlocal EnableExtensions EnableDelayedExpansion - -REM ============================================================ -REM Handcrafted - Fabric Build Script -REM Windows -REM ============================================================ - -cd /d "%~dp0" - -set "BUILD_ONLY=0" -if /I "%~1"=="--build-only" set "BUILD_ONLY=1" - -set "GRADLE_PROPERTIES=%CD%\gradle.properties" -set "LOCAL_GRADLE_DIR=%CD%\.gradle-local" -set "GRADLE_VERSION=9.7.1" -set "GRADLE_HOME=%LOCAL_GRADLE_DIR%\gradle-%GRADLE_VERSION%" -set "GRADLE_BIN=%GRADLE_HOME%\bin\gradle.bat" -set "GIT_ONLY=0" - -set "MOD_VERSION=" -set "MINECRAFT_VERSION=" -set "MAVEN_GROUP=" - -if not exist "%GRADLE_PROPERTIES%" ( - echo [ERROR] gradle.properties tidak ditemukan. - goto :failed -) - -for /f "usebackq tokens=1,* delims==" %%A in ("%GRADLE_PROPERTIES%") do ( - if "%%A"=="mod_version" set "MOD_VERSION=%%B" - if "%%A"=="minecraft_version" set "MINECRAFT_VERSION=%%B" - if "%%A"=="maven_group" set "MAVEN_GROUP=%%B" - if "%%A"=="archives_base_name" set "ARCHIVES_BASE_NAME=%%B" -) - -if not defined MOD_VERSION set "MOD_VERSION=unknown" -if not defined MINECRAFT_VERSION set "MINECRAFT_VERSION=26.2" -if not defined MAVEN_GROUP set "MAVEN_GROUP=id.dartokloning" - -if not defined ARCHIVES_BASE_NAME set "ARCHIVES_BASE_NAME=handcrafted" -set "JAR_PATH=%CD%\build\libs\%ARCHIVES_BASE_NAME%-%MOD_VERSION%.jar" - -echo ============================================ -echo Handcrafted - Fabric %MINECRAFT_VERSION% Build -echo Version: %MOD_VERSION% -echo Namespace: earth.terrarium.handcrafted -echo Mod ID: handcrafted -echo ============================================ - -REM release.bat selalu melakukan build ulang melalui --build-only. -if "%BUILD_ONLY%"=="0" if exist "%JAR_PATH%" ( - echo. - echo [INFO] JAR untuk v%MOD_VERSION% sudah pernah dibuild: - echo %JAR_PATH% - echo. - choice /C CG /N /M "[C] Compile ulang / [G] Git saja: " - if errorlevel 2 ( - set "GIT_ONLY=1" - goto :git_integration - ) -) - -where java.exe >nul 2>&1 -if errorlevel 1 ( - echo [ERROR] Java tidak ditemukan di PATH. - echo Install JDK 25, buka terminal baru, lalu jalankan script lagi. - goto :failed -) - -for /f "delims=" %%J in ('where java.exe 2^>nul') do ( - set "JAVA_PATH=%%J" - goto :java_path_found -) - -:java_path_found -echo [INFO] Java executable: %JAVA_PATH% - -set "JAVA_VERSION=" -for /f "tokens=2" %%V in ('java --version 2^>^&1 ^| findstr /R /C:"^openjdk " /C:"^java "') do ( - if not defined JAVA_VERSION set "JAVA_VERSION=%%V" -) - -if not defined JAVA_VERSION ( - echo [ERROR] Tidak dapat membaca versi Java. - goto :failed -) - -for /f "tokens=1 delims=." %%M in ("%JAVA_VERSION%") do set "JAVA_MAJOR=%%M" - -if not "%JAVA_MAJOR%"=="25" ( - echo [ERROR] Java 25 diperlukan. - echo [INFO] Java yang terdeteksi: %JAVA_VERSION% - goto :failed -) - -echo [OK] Java 25 terdeteksi. - -if exist "%GRADLE_BIN%" goto :gradle_ready - -echo [INFO] Gradle %GRADLE_VERSION% belum tersedia. -echo [INFO] Mengunduh distribusi resmi... - -if not exist "%LOCAL_GRADLE_DIR%" mkdir "%LOCAL_GRADLE_DIR%" - -set "GRADLE_ZIP=%LOCAL_GRADLE_DIR%\gradle-%GRADLE_VERSION%-bin.zip" -set "GRADLE_URL=https://services.gradle.org/distributions/gradle-%GRADLE_VERSION%-bin.zip" - -where curl.exe >nul 2>&1 -if errorlevel 1 ( - echo [ERROR] curl.exe tidak ditemukan. - goto :failed -) - -curl.exe -L --fail --progress-bar "%GRADLE_URL%" -o "%GRADLE_ZIP%" -if errorlevel 1 ( - echo [ERROR] Gagal mengunduh Gradle %GRADLE_VERSION%. - goto :failed -) - -echo [INFO] Mengekstrak Gradle %GRADLE_VERSION%... -powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Expand-Archive -LiteralPath '%GRADLE_ZIP%' -DestinationPath '%LOCAL_GRADLE_DIR%' -Force" -if errorlevel 1 ( - echo [ERROR] Gagal mengekstrak Gradle. - goto :failed -) - -del /q "%GRADLE_ZIP%" >nul 2>&1 - -if not exist "%GRADLE_BIN%" ( - echo [ERROR] Gradle berhasil diekstrak tetapi executable tidak ditemukan. - goto :failed -) - -:gradle_ready -echo [OK] Gradle %GRADLE_VERSION% tersedia. -echo [INFO] Menjalankan clean build Handcrafted v%MOD_VERSION%... -echo. - -call "%GRADLE_BIN%" clean build --no-daemon -if errorlevel 1 goto :build_failed - -echo. -echo ============================================ -echo BUILD SUCCESS -echo ============================================ - -if exist "%JAR_PATH%" ( - echo JAR: - echo %JAR_PATH% -) else ( - echo [WARN] Build berhasil, tetapi JAR utama tidak ditemukan pada: - echo %JAR_PATH% -) - -if "%BUILD_ONLY%"=="1" exit /b 0 - -echo. -choice /C YN /N /M "Commit dan push perubahan ke Git/Gitea? [Y/N]: " -if errorlevel 2 goto :skip_git -if errorlevel 1 goto :git_integration - -:git_integration -echo. -echo ============================================ -echo Git Integration -echo ============================================ -if "%GIT_ONLY%"=="1" echo [INFO] Mode Git-only: build dilewati karena JAR v%MOD_VERSION% sudah tersedia. - -where git.exe >nul 2>&1 -if errorlevel 1 ( - echo [ERROR] Git tidak ditemukan di PATH. - goto :git_failed -) - -git rev-parse --is-inside-work-tree >nul 2>&1 -if errorlevel 1 ( - echo [ERROR] Folder ini belum menjadi Git repository. - echo. - echo Jalankan terlebih dahulu: - echo git init - echo git branch -M main - echo git remote add origin ^ - echo. - goto :git_failed -) - -echo [INFO] Memeriksa perubahan... -set "HAS_CHANGES=" -for /f "delims=" %%G in ('git status --porcelain') do set "HAS_CHANGES=1" - -if defined HAS_CHANGES ( - echo. - echo Perubahan ditemukan: - git status --short - echo. - - call :suggest_commit_message - echo [SUGGEST] Commit message: !SUGGESTED_COMMIT! - echo [INFO] Tekan Enter untuk memakai saran tersebut, atau ketik pesan sendiri. - set "COMMIT_MESSAGE=" - set /p "COMMIT_MESSAGE=Commit message [!SUGGESTED_COMMIT!]: " - if not defined COMMIT_MESSAGE set "COMMIT_MESSAGE=!SUGGESTED_COMMIT!" - - echo. - echo [INFO] Menambahkan perubahan ke staging... - git add -A - if errorlevel 1 ( - echo [ERROR] git add gagal. - goto :git_failed - ) - - echo [INFO] Membuat commit... - git commit -m "!COMMIT_MESSAGE!" - if errorlevel 1 ( - echo [ERROR] git commit gagal. - goto :git_failed - ) -) else ( - echo [INFO] Tidak ada perubahan source yang perlu di-commit. - echo [INFO] Akan mencoba push commit lokal yang belum terkirim, jika ada. -) - -set "CURRENT_BRANCH=" -for /f "delims=" %%B in ('git branch --show-current') do set "CURRENT_BRANCH=%%B" - -if not defined CURRENT_BRANCH ( - echo [ERROR] Tidak dapat menentukan branch Git aktif. - goto :git_failed -) - -git remote get-url origin >nul 2>&1 -if errorlevel 1 ( - echo [ERROR] Remote Git 'origin' belum dikonfigurasi. - echo Commit lokal tetap tersimpan. - goto :git_failed -) - -call :push_branch_with_retry -if errorlevel 1 goto :git_failed - -echo. -echo [SUCCESS] Push ke Git/Gitea berhasil. -goto :success - -:suggest_commit_message -set "SUGGESTED_COMMIT=Update Handcrafted v%MOD_VERSION%" -set "HAS_SRC_CHANGE=" -set "HAS_SCRIPT_CHANGE=" -set "HAS_DOC_CHANGE=" -for /f "delims=" %%F in ('git status --porcelain') do ( - set "LINE=%%F" - echo !LINE! | findstr /I /C:"src/" >nul && set "HAS_SRC_CHANGE=1" - echo !LINE! | findstr /I /C:"compile.bat" /C:"compile.sh" /C:"release.bat" /C:"release.sh" >nul && set "HAS_SCRIPT_CHANGE=1" - echo !LINE! | findstr /I /C:"README.md" /C:"LICENSE" >nul && set "HAS_DOC_CHANGE=1" -) -exit /b 0 - -:push_branch_with_retry -set /a PUSH_ROUND=1 -:push_round_start -set /a PUSH_ATTEMPT=1 -:push_attempt_start -echo. -echo [INFO] Push attempt !PUSH_ATTEMPT!/3 ^(round !PUSH_ROUND!^) ke origin/!CURRENT_BRANCH!... -git push origin "!CURRENT_BRANCH!" -if not errorlevel 1 exit /b 0 - -echo [WARN] Push attempt !PUSH_ATTEMPT!/3 gagal. -if !PUSH_ATTEMPT! LSS 3 ( - set /a PUSH_ATTEMPT+=1 - echo [INFO] Mencoba lagi dalam 2 detik... - timeout /t 2 /nobreak >nul - goto :push_attempt_start -) - -echo. -echo ============================================ -echo GIT PUSH FAILED - 3 ATTEMPTS -echo ============================================ -echo [INFO] Commit lokal tetap aman dan tidak perlu compile ulang. -choice /C YN /N /M "Coba push 3x lagi? [Y/N]: " -if errorlevel 2 exit /b 1 -set /a PUSH_ROUND+=1 -goto :push_round_start - -:skip_git -echo. -echo [INFO] Git commit/push dilewati. -goto :success - -:success -echo. -echo ============================================ -echo Handcrafted v%MOD_VERSION% selesai. -echo ============================================ -echo. -pause -exit /b 0 - -:build_failed -echo. -echo ============================================ -echo BUILD FAILED -echo ============================================ -echo. -echo [ERROR] Build gagal. -echo [INFO] Git Integration tidak dijalankan. -echo. -if "%BUILD_ONLY%"=="1" exit /b 1 -pause -exit /b 1 - -:git_failed -echo. -echo ============================================ -echo GIT FAILED -echo ============================================ -echo. -if "%GIT_ONLY%"=="1" ( - echo [INFO] Build tidak dijalankan; JAR v%MOD_VERSION% yang sudah ada tetap aman. -) else ( - echo [INFO] Build Handcrafted tetap berhasil. -) -echo [INFO] Commit lokal tetap tersimpan. -echo [INFO] Jalankan compile.bat lagi; jika JAR versi sama terdeteksi, pilih G untuk Git-only. -echo. -pause -exit /b 2 - -:failed -echo. -echo Build gagal. -echo. -if "%BUILD_ONLY%"=="1" exit /b 1 -pause -exit /b 1 diff --git a/compile.sh b/compile.sh deleted file mode 100644 index 5c1a2c5..0000000 --- a/compile.sh +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env bash -set -u - -# ============================================================ -# Handcrafted - Fabric Build Script -# Linux / macOS -# ============================================================ - -SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" -cd "$SCRIPT_DIR" || exit 1 - -BUILD_ONLY=0 -[[ "${1:-}" == "--build-only" ]] && BUILD_ONLY=1 - -GRADLE_PROPERTIES="$PWD/gradle.properties" -LOCAL_GRADLE_DIR="$PWD/.gradle-local" -GRADLE_VERSION="9.7.1" -GRADLE_HOME="$LOCAL_GRADLE_DIR/gradle-$GRADLE_VERSION" -GRADLE_BIN="$GRADLE_HOME/bin/gradle" -GIT_ONLY=0 - -pause_if_needed() { [[ $BUILD_ONLY -eq 0 ]] && read -r -p "Tekan Enter untuk melanjutkan..." _ || true; } -fail() { echo; echo "[ERROR] $1"; pause_if_needed; exit 1; } - -[[ -f "$GRADLE_PROPERTIES" ]] || fail "gradle.properties tidak ditemukan." - -get_prop() { sed -n "s/^$1=//p" "$GRADLE_PROPERTIES" | tail -n 1 | tr -d '\r'; } -MOD_VERSION="$(get_prop mod_version)"; MOD_VERSION="${MOD_VERSION:-unknown}" -MINECRAFT_VERSION="$(get_prop minecraft_version)"; MINECRAFT_VERSION="${MINECRAFT_VERSION:-26.2}" -MAVEN_GROUP="$(get_prop maven_group)"; MAVEN_GROUP="${MAVEN_GROUP:-id.dartokloning}" -ARCHIVES_BASE_NAME="$(get_prop archives_base_name)"; ARCHIVES_BASE_NAME="${ARCHIVES_BASE_NAME:-handcrafted}" -JAR_PATH="$PWD/build/libs/$ARCHIVES_BASE_NAME-$MOD_VERSION.jar" - -echo "============================================" -echo " Handcrafted - Fabric $MINECRAFT_VERSION Build" -echo " Version: $MOD_VERSION" -echo " Namespace: earth.terrarium.handcrafted" -echo " Mod ID: handcrafted" -echo "============================================" - -if [[ $BUILD_ONLY -eq 0 && -f "$JAR_PATH" ]]; then - echo; echo "[INFO] JAR untuk v$MOD_VERSION sudah pernah dibuild:"; echo " $JAR_PATH"; echo - read -r -p "[C] Compile ulang / [G] Git saja: " ans - if [[ "$ans" == "g" || "$ans" == "G" ]]; then GIT_ONLY=1; fi -fi - -if [[ $GIT_ONLY -eq 0 ]]; then - command -v java >/dev/null 2>&1 || fail "Java tidak ditemukan di PATH. Install JDK 25, buka terminal baru, lalu jalankan script lagi." - JAVA_PATH="$(command -v java)" - echo "[INFO] Java executable: $JAVA_PATH" - JAVA_VERSION="$(java --version 2>&1 | head -n 1 | awk '{print $2}' | tr -d '"')" - JAVA_MAJOR="${JAVA_VERSION%%.*}" - [[ "$JAVA_MAJOR" == "25" ]] || fail "Java 25 diperlukan. Java yang terdeteksi: $JAVA_VERSION" - echo "[OK] Java 25 terdeteksi." - - if [[ ! -x "$GRADLE_BIN" ]]; then - echo "[INFO] Gradle $GRADLE_VERSION belum tersedia." - echo "[INFO] Mengunduh distribusi resmi..." - mkdir -p "$LOCAL_GRADLE_DIR" - GRADLE_ZIP="$LOCAL_GRADLE_DIR/gradle-$GRADLE_VERSION-bin.zip" - GRADLE_URL="https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip" - if command -v curl >/dev/null 2>&1; then - curl -L --fail --progress-bar "$GRADLE_URL" -o "$GRADLE_ZIP" || fail "Gagal mengunduh Gradle $GRADLE_VERSION." - elif command -v wget >/dev/null 2>&1; then - wget -O "$GRADLE_ZIP" "$GRADLE_URL" || fail "Gagal mengunduh Gradle $GRADLE_VERSION." - else - fail "curl atau wget tidak ditemukan." - fi - command -v unzip >/dev/null 2>&1 || fail "unzip tidak ditemukan. Install unzip lalu jalankan script lagi." - echo "[INFO] Mengekstrak Gradle $GRADLE_VERSION..." - unzip -q -o "$GRADLE_ZIP" -d "$LOCAL_GRADLE_DIR" || fail "Gagal mengekstrak Gradle." - rm -f "$GRADLE_ZIP" - [[ -x "$GRADLE_BIN" ]] || fail "Gradle berhasil diekstrak tetapi executable tidak ditemukan." - fi - - echo "[OK] Gradle $GRADLE_VERSION tersedia." - echo "[INFO] Menjalankan clean build Handcrafted v$MOD_VERSION..."; echo - "$GRADLE_BIN" clean build --no-daemon || { echo; echo "============================================"; echo " BUILD FAILED"; echo "============================================"; echo "[ERROR] Build gagal."; echo "[INFO] Git Integration tidak dijalankan."; pause_if_needed; exit 1; } - echo; echo "============================================"; echo " BUILD SUCCESS"; echo "============================================" - if [[ -f "$JAR_PATH" ]]; then echo "JAR:"; echo "$JAR_PATH"; else echo "[WARN] Build berhasil, tetapi JAR utama tidak ditemukan pada:"; echo "$JAR_PATH"; fi - [[ $BUILD_ONLY -eq 1 ]] && exit 0 - echo - read -r -p "Commit dan push perubahan ke Git/Gitea? [Y/N]: " ans - [[ "$ans" == "y" || "$ans" == "Y" ]] || { echo; echo "[INFO] Git commit/push dilewati."; echo; echo "============================================"; echo " Handcrafted v$MOD_VERSION selesai."; echo "============================================"; pause_if_needed; exit 0; } -fi - -echo; echo "============================================"; echo " Git Integration"; echo "============================================" -[[ $GIT_ONLY -eq 1 ]] && echo "[INFO] Mode Git-only: build dilewati karena JAR v$MOD_VERSION sudah tersedia." -command -v git >/dev/null 2>&1 || { echo "[ERROR] Git tidak ditemukan di PATH."; exit 2; } -git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { echo "[ERROR] Folder ini belum menjadi Git repository."; echo "Jalankan: git init && git branch -M main && git remote add origin "; exit 2; } - -if [[ -n "$(git status --porcelain)" ]]; then - echo; echo "Perubahan ditemukan:"; git status --short; echo - SUGGESTED_COMMIT="Update Handcrafted v$MOD_VERSION" - echo "[SUGGEST] Commit message: $SUGGESTED_COMMIT" - read -r -p "Commit message [$SUGGESTED_COMMIT]: " COMMIT_MESSAGE - COMMIT_MESSAGE="${COMMIT_MESSAGE:-$SUGGESTED_COMMIT}" - git add -A || exit 2 - git commit -m "$COMMIT_MESSAGE" || exit 2 -else - echo "[INFO] Tidak ada perubahan source yang perlu di-commit." -fi - -CURRENT_BRANCH="$(git branch --show-current)" -[[ -n "$CURRENT_BRANCH" ]] || { echo "[ERROR] Tidak dapat menentukan branch Git aktif."; exit 2; } -git remote get-url origin >/dev/null 2>&1 || { echo "[ERROR] Remote Git 'origin' belum dikonfigurasi. Commit lokal tetap tersimpan."; exit 2; } - -round=1 -while true; do - for attempt in 1 2 3; do - echo; echo "[INFO] Push attempt $attempt/3 (round $round) ke origin/$CURRENT_BRANCH..." - if git push origin "$CURRENT_BRANCH"; then - echo; echo "[SUCCESS] Push ke Git/Gitea berhasil." - echo; echo "============================================"; echo " Handcrafted v$MOD_VERSION selesai."; echo "============================================" - pause_if_needed; exit 0 - fi - echo "[WARN] Push attempt $attempt/3 gagal." - [[ $attempt -lt 3 ]] && { echo "[INFO] Mencoba lagi dalam 2 detik..."; sleep 2; } - done - echo; echo "============================================"; echo " GIT PUSH FAILED - 3 ATTEMPTS"; echo "============================================" - echo "[INFO] Commit lokal tetap aman dan tidak perlu compile ulang." - read -r -p "Coba push 3x lagi? [Y/N]: " ans - [[ "$ans" == "y" || "$ans" == "Y" ]] || { echo "[INFO] Commit lokal tetap tersimpan."; exit 2; } - round=$((round + 1)) -done diff --git a/gradle.properties b/gradle.properties index e18d50c..f97567d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G org.gradle.parallel=true org.gradle.caching=true -mod_version=4.0.14 +mod_version=4.0.15 maven_group=earth.terrarium.handcrafted archives_base_name=handcrafted diff --git a/src/main/java/earth/terrarium/handcrafted/common/blocks/DiningBenchBlock.java b/src/main/java/earth/terrarium/handcrafted/common/blocks/DiningBenchBlock.java index 7761e7b..eab1794 100644 --- a/src/main/java/earth/terrarium/handcrafted/common/blocks/DiningBenchBlock.java +++ b/src/main/java/earth/terrarium/handcrafted/common/blocks/DiningBenchBlock.java @@ -68,7 +68,11 @@ public class DiningBenchBlock extends HorizontalDirectionalBlock implements Sitt @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { - this.sitOn(level, pos, player, null); + // A dining bench has no backrest, so its sitting direction should be + // chosen by the player at the moment they sit rather than by the + // bench block's placement facing. This also avoids the old null/free- + // rotation seat starting at the same world yaw every time. + this.sitOn(level, pos, player, player.getDirection()); return InteractionResult.SUCCESS; } diff --git a/test.bat b/test.bat deleted file mode 100644 index f41d41c..0000000 --- a/test.bat +++ /dev/null @@ -1,39 +0,0 @@ -@echo off -setlocal EnableExtensions -cd /d "%~dp0" - -echo ============================================ -echo Handcrafted - Fabric Test -echo ============================================ -echo [C] Run Minecraft Client -echo [S] Run Dedicated Server -echo [Q] Keluar -echo. -choice /C CSQ /N /M "Pilih test: " -if errorlevel 3 exit /b 0 -if errorlevel 2 goto :server - -:client -echo. -echo [INFO] Menjalankan Fabric development client... -call gradlew.bat runClient -goto :result - -:server -echo. -echo [INFO] Menjalankan Fabric development server... -echo [INFO] Pada run pertama, jika server berhenti karena EULA, -echo buka run\eula.txt, ubah eula=true, lalu jalankan test.bat lagi. -call gradlew.bat runServer - -:result -if errorlevel 1 ( - echo. - echo [ERROR] Test gagal / Minecraft keluar dengan error. - pause - exit /b 1 -) -echo. -echo [OK] Test session selesai tanpa Gradle error. -pause -exit /b 0 diff --git a/test.sh b/test.sh deleted file mode 100644 index 3c68bf6..0000000 --- a/test.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -set -u -SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" -cd "$SCRIPT_DIR" || exit 1 - -echo "============================================" -echo " Handcrafted - Fabric Test" -echo " Linux / macOS" -echo "============================================" -echo "[C] Run Minecraft Client" -echo "[S] Run Dedicated Server" -echo "[Q] Keluar" -echo -read -r -p "Pilih test: " choice - -case "$choice" in - c|C) TASK="runClient"; echo; echo "[INFO] Menjalankan Fabric development client..." ;; - s|S) TASK="runServer"; echo; echo "[INFO] Menjalankan Fabric development server..."; echo "[INFO] Pada run pertama, jika server berhenti karena EULA,"; echo " buka run/eula.txt, ubah eula=true, lalu jalankan test.sh lagi." ;; - q|Q) exit 0 ;; - *) echo "[ERROR] Pilihan tidak valid."; exit 1 ;; -esac - -if [[ ! -f ./gradlew ]]; then echo "[ERROR] gradlew tidak ditemukan."; exit 1; fi -[[ -x ./gradlew ]] || chmod +x ./gradlew -./gradlew "$TASK" -status=$? -if [[ $status -ne 0 ]]; then echo; echo "[ERROR] Test gagal / Minecraft keluar dengan error."; exit $status; fi -echo; echo "[OK] Test session selesai tanpa Gradle error." diff --git a/workflow.bat b/workflow.bat new file mode 100644 index 0000000..bd65dd8 --- /dev/null +++ b/workflow.bat @@ -0,0 +1,203 @@ +@echo off +setlocal EnableExtensions EnableDelayedExpansion +cd /d "%~dp0" + +set "PROPS=%CD%\gradle.properties" +if not exist "%PROPS%" ( + echo [ERROR] gradle.properties tidak ditemukan. + pause + exit /b 1 +) + +:refresh +set "MOD_VERSION=" +set "MINECRAFT_VERSION=" +set "ARCHIVES_BASE_NAME=" +for /f "usebackq tokens=1,* delims==" %%A in ("%PROPS%") do ( + if "%%A"=="mod_version" set "MOD_VERSION=%%B" + if "%%A"=="minecraft_version" set "MINECRAFT_VERSION=%%B" + if "%%A"=="archives_base_name" set "ARCHIVES_BASE_NAME=%%B" +) +if not defined MOD_VERSION set "MOD_VERSION=unknown" +if not defined MINECRAFT_VERSION set "MINECRAFT_VERSION=26.2" +if not defined ARCHIVES_BASE_NAME set "ARCHIVES_BASE_NAME=handcrafted" + +set "JAR_PATH=%CD%\build\libs\%ARCHIVES_BASE_NAME%-%MOD_VERSION%.jar" +set "TAG=v%MOD_VERSION%" + +if exist "%JAR_PATH%" goto :menu4 + +echo. +echo ============================================ +echo Handcrafted Workflow +echo Minecraft : %MINECRAFT_VERSION% +echo Version : %MOD_VERSION% +echo JAR : belum ditemukan +echo ============================================ +echo. +echo Build untuk versi ini belum ada. Menjalankan compile... +call :compile +if errorlevel 1 goto :menu_nojar +goto :menu4 + +:menu_nojar +echo. +echo Build gagal / JAR belum tersedia. +echo [1] Push Git +echo [2] Mod Testing +echo [3] Exit +choice /C 123 /N /M "Pilih: " +if errorlevel 3 exit /b 0 +if errorlevel 2 (call :test & goto :refresh) +if errorlevel 1 (call :push & goto :refresh) + +:menu4 +echo. +echo ============================================ +echo Handcrafted Workflow +echo Minecraft : %MINECRAFT_VERSION% +echo Version : %MOD_VERSION% +echo JAR : ditemukan +echo ============================================ +echo [1] Push Git +echo [2] Mod Testing +echo [3] Make Release +echo [4] Exit +choice /C 1234 /N /M "Pilih: " +if errorlevel 4 exit /b 0 +if errorlevel 3 (call :release & goto :after_release) +if errorlevel 2 (call :test & goto :after_test) +if errorlevel 1 (call :push & goto :after_push) + +:after_push +echo. +echo [1] Mod Testing +echo [2] Make Release +echo [3] Exit +choice /C 123 /N /M "Pilih: " +if errorlevel 3 exit /b 0 +if errorlevel 2 (call :release & goto :after_release) +if errorlevel 1 (call :test & goto :after_test) + +:after_test +echo. +echo [1] Push Git +echo [2] Make Release +echo [3] Exit +choice /C 123 /N /M "Pilih: " +if errorlevel 3 exit /b 0 +if errorlevel 2 (call :release & goto :after_release) +if errorlevel 1 (call :push & goto :after_push) + +:after_release +echo. +echo [1] Push Git +echo [2] Mod Testing +echo [3] Exit +choice /C 123 /N /M "Pilih: " +if errorlevel 3 exit /b 0 +if errorlevel 2 (call :test & goto :after_test) +if errorlevel 1 (call :push & goto :after_push) + +:compile +echo. +echo [COMPILE] Building %ARCHIVES_BASE_NAME% %MOD_VERSION%... +if exist "%CD%\compile.bat" ( + call "%CD%\compile.bat" --build-only +) else if exist "%CD%\gradlew.bat" ( + call "%CD%\gradlew.bat" clean build --console=plain +) else ( + echo [ERROR] compile.bat maupun gradlew.bat tidak ditemukan. + exit /b 1 +) +if errorlevel 1 ( + echo [ERROR] Compile gagal. + exit /b 1 +) +if not exist "%JAR_PATH%" ( + echo [ERROR] Build selesai tetapi JAR tidak ditemukan: + echo %JAR_PATH% + exit /b 1 +) +echo [OK] JAR: %JAR_PATH% +exit /b 0 + +:push +echo. +echo [GIT] Push... +where git.exe >nul 2>&1 || (echo [ERROR] Git tidak ditemukan.& exit /b 1) +git rev-parse --is-inside-work-tree >nul 2>&1 || ( + echo [ERROR] Folder belum menjadi Git repository. + echo Jalankan: git init + exit /b 1 +) +git remote get-url origin >nul 2>&1 || (echo [ERROR] Remote origin belum dikonfigurasi.& exit /b 1) + +set "HAS_CHANGES=" +for /f "delims=" %%G in ('git status --porcelain') do set "HAS_CHANGES=1" +if defined HAS_CHANGES ( + git status --short + set "MSG=" + set /p "MSG=Commit message [Handcrafted %MOD_VERSION%]: " + if not defined MSG set "MSG=Handcrafted %MOD_VERSION%" + git add -A || exit /b 1 + git commit -m "!MSG!" || exit /b 1 +) else ( + echo [INFO] Working tree bersih. +) + +set "BRANCH=" +for /f "delims=" %%B in ('git branch --show-current') do set "BRANCH=%%B" +if not defined BRANCH (echo [ERROR] Branch aktif tidak ditemukan.& exit /b 1) +git push origin "!BRANCH!" +if errorlevel 1 (echo [ERROR] Push gagal.& exit /b 1) +echo [OK] Push selesai. +exit /b 0 + +:test +echo. +echo [TEST] Menjalankan Minecraft test client... +if exist "%CD%\gradlew.bat" ( + call "%CD%\gradlew.bat" runClient --console=plain +) else ( + echo [ERROR] gradlew.bat tidak ditemukan. + exit /b 1 +) +set "RC=%ERRORLEVEL%" +if not "%RC%"=="0" echo [WARN] Test client selesai dengan exit code %RC%. +exit /b 0 + +:release +echo. +if not exist "%JAR_PATH%" ( + echo [ERROR] Release dibatalkan: JAR %MOD_VERSION% tidak ditemukan. + exit /b 1 +) +where git.exe >nul 2>&1 || (echo [ERROR] Git tidak ditemukan.& exit /b 1) +git rev-parse --is-inside-work-tree >nul 2>&1 || (echo [ERROR] Bukan Git repository.& exit /b 1) + +git rev-parse "%TAG%" >nul 2>&1 +if not errorlevel 1 ( + echo [INFO] Tag %TAG% sudah ada. Tidak membuat ulang. + exit /b 0 +) + +echo JAR : %JAR_PATH% +echo Tag : %TAG% +choice /C YN /N /M "Buat release tag %TAG%? [Y/N]: " +if errorlevel 2 exit /b 0 + +git tag -a "%TAG%" -m "Handcrafted v%MOD_VERSION% for Fabric %MINECRAFT_VERSION%" +if errorlevel 1 (echo [ERROR] Gagal membuat tag.& exit /b 1) + +git remote get-url origin >nul 2>&1 +if not errorlevel 1 ( + git push origin "%TAG%" + if errorlevel 1 ( + echo [WARN] Tag lokal dibuat, tetapi push tag gagal. + exit /b 1 + ) +) +echo [OK] Release tag %TAG% selesai. +echo [INFO] JAR release: %JAR_PATH% +exit /b 0 diff --git a/workflow.sh b/workflow.sh new file mode 100644 index 0000000..4a83dfc --- /dev/null +++ b/workflow.sh @@ -0,0 +1,178 @@ +#!/usr/bin/env bash +set -u +cd "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" || exit 1 + +[[ -f gradle.properties ]] || { echo "[ERROR] gradle.properties tidak ditemukan."; exit 1; } + +get_prop() { sed -n "s/^$1=//p" gradle.properties | tail -n 1 | tr -d '\r'; } + +refresh() { + MOD_VERSION="$(get_prop mod_version)"; MOD_VERSION="${MOD_VERSION:-unknown}" + MINECRAFT_VERSION="$(get_prop minecraft_version)"; MINECRAFT_VERSION="${MINECRAFT_VERSION:-26.2}" + ARCHIVES_BASE_NAME="$(get_prop archives_base_name)"; ARCHIVES_BASE_NAME="${ARCHIVES_BASE_NAME:-handcrafted}" + JAR_PATH="$PWD/build/libs/$ARCHIVES_BASE_NAME-$MOD_VERSION.jar" + TAG="v$MOD_VERSION" +} + +compile_mod() { + echo + echo "[COMPILE] Building $ARCHIVES_BASE_NAME $MOD_VERSION..." + if [[ -f ./compile.sh ]]; then + bash ./compile.sh --build-only || return 1 + elif [[ -f ./gradlew ]]; then + chmod +x ./gradlew 2>/dev/null || true + ./gradlew clean build --console=plain || return 1 + else + echo "[ERROR] compile.sh maupun gradlew tidak ditemukan." + return 1 + fi + [[ -f "$JAR_PATH" ]] || { echo "[ERROR] JAR tidak ditemukan: $JAR_PATH"; return 1; } + echo "[OK] JAR: $JAR_PATH" +} + +push_git() { + echo + echo "[GIT] Push..." + command -v git >/dev/null 2>&1 || { echo "[ERROR] Git tidak ditemukan."; return 1; } + git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { + echo "[ERROR] Folder belum menjadi Git repository." + echo "Jalankan: git init" + return 1 + } + git remote get-url origin >/dev/null 2>&1 || { echo "[ERROR] Remote origin belum dikonfigurasi."; return 1; } + + if [[ -n "$(git status --porcelain)" ]]; then + git status --short + read -r -p "Commit message [Handcrafted $MOD_VERSION]: " msg + msg="${msg:-Handcrafted $MOD_VERSION}" + git add -A || return 1 + git commit -m "$msg" || return 1 + else + echo "[INFO] Working tree bersih." + fi + + branch="$(git branch --show-current)" + [[ -n "$branch" ]] || { echo "[ERROR] Branch aktif tidak ditemukan."; return 1; } + git push origin "$branch" || { echo "[ERROR] Push gagal."; return 1; } + echo "[OK] Push selesai." +} + +test_mod() { + echo + echo "[TEST] Menjalankan Minecraft test client..." + if [[ -f ./gradlew ]]; then + chmod +x ./gradlew 2>/dev/null || true + ./gradlew runClient --console=plain + rc=$? + [[ $rc -eq 0 ]] || echo "[WARN] Test client selesai dengan exit code $rc." + else + echo "[ERROR] gradlew tidak ditemukan." + return 1 + fi + return 0 +} + +make_release() { + echo + [[ -f "$JAR_PATH" ]] || { echo "[ERROR] Release dibatalkan: JAR $MOD_VERSION tidak ditemukan."; return 1; } + command -v git >/dev/null 2>&1 || { echo "[ERROR] Git tidak ditemukan."; return 1; } + git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { echo "[ERROR] Bukan Git repository."; return 1; } + + if git rev-parse "$TAG" >/dev/null 2>&1; then + echo "[INFO] Tag $TAG sudah ada. Tidak membuat ulang." + return 0 + fi + + echo "JAR : $JAR_PATH" + echo "Tag : $TAG" + read -r -p "Buat release tag $TAG? [Y/N]: " ans + [[ "$ans" =~ ^[Yy]$ ]] || return 0 + + git tag -a "$TAG" -m "Handcrafted v$MOD_VERSION for Fabric $MINECRAFT_VERSION" || return 1 + if git remote get-url origin >/dev/null 2>&1; then + git push origin "$TAG" || { echo "[WARN] Tag lokal dibuat, tetapi push tag gagal."; return 1; } + fi + echo "[OK] Release tag $TAG selesai." + echo "[INFO] JAR release: $JAR_PATH" +} + +menu4() { + echo + echo "============================================" + echo " Handcrafted Workflow" + echo " Minecraft : $MINECRAFT_VERSION" + echo " Version : $MOD_VERSION" + echo " JAR : ditemukan" + echo "============================================" + echo "[1] Push Git" + echo "[2] Mod Testing" + echo "[3] Make Release" + echo "[4] Exit" + read -r -p "Pilih: " x + case "$x" in + 1) push_git; after_push ;; + 2) test_mod; after_test ;; + 3) make_release; after_release ;; + *) exit 0 ;; + esac +} + +after_push() { + while true; do + echo; echo "[1] Mod Testing"; echo "[2] Make Release"; echo "[3] Exit" + read -r -p "Pilih: " x + case "$x" in + 1) test_mod; after_test; return ;; + 2) make_release; after_release; return ;; + *) exit 0 ;; + esac + done +} + +after_test() { + while true; do + echo; echo "[1] Push Git"; echo "[2] Make Release"; echo "[3] Exit" + read -r -p "Pilih: " x + case "$x" in + 1) push_git; after_push; return ;; + 2) make_release; after_release; return ;; + *) exit 0 ;; + esac + done +} + +after_release() { + while true; do + echo; echo "[1] Push Git"; echo "[2] Mod Testing"; echo "[3] Exit" + read -r -p "Pilih: " x + case "$x" in + 1) push_git; after_push; return ;; + 2) test_mod; after_test; return ;; + *) exit 0 ;; + esac + done +} + +refresh +if [[ ! -f "$JAR_PATH" ]]; then + echo + echo "[INFO] Build $MOD_VERSION belum ditemukan. Compile otomatis..." + compile_mod || true +fi + +refresh +if [[ -f "$JAR_PATH" ]]; then + menu4 +else + echo + echo "Build belum tersedia." + echo "[1] Push Git" + echo "[2] Mod Testing" + echo "[3] Exit" + read -r -p "Pilih: " x + case "$x" in + 1) push_git; after_push ;; + 2) test_mod; after_test ;; + *) exit 0 ;; + esac +fi