diff --git a/.github/actions/local-action/action.yml b/.github/actions/local-action/action.yml index c11787d..ee21f0a 100644 --- a/.github/actions/local-action/action.yml +++ b/.github/actions/local-action/action.yml @@ -109,7 +109,7 @@ runs: shell: bash - name: Download mc-runtime-test jar ${{ inputs.mc-runtime-test }} if: ${{ inputs.mc-runtime-test != 'none' }} - run: wget -O run/mods/mc-runtime-test-${{ inputs.mc }}-2.0.0-${{ inputs.mc-runtime-test }}-release.jar https://github.com/3arthqu4ke/mc-runtime-test/releases/download/2.0.0/mc-runtime-test-${{ inputs.mc }}-2.0.0-${{ inputs.mc-runtime-test }}-release.jar + run: wget -O run/mods/mc-runtime-test-${{ inputs.mc }}-2.1.0-${{ inputs.mc-runtime-test }}-release.jar https://github.com/3arthqu4ke/mc-runtime-test/releases/download/2.1.0/mc-runtime-test-${{ inputs.mc }}-2.1.0-${{ inputs.mc-runtime-test }}-release.jar shell: bash - name: Download fabric-api jar ${{ inputs.fabric-api }} if: ${{ inputs.fabric-api != 'none' }} diff --git a/.github/workflows/build-all-matrix-artifacts.yml b/.github/workflows/build-all-matrix-artifacts.yml index 46f1c94..01e017e 100644 --- a/.github/workflows/build-all-matrix-artifacts.yml +++ b/.github/workflows/build-all-matrix-artifacts.yml @@ -9,6 +9,8 @@ jobs: matrix: version: - { dir: api, mc: api, lex: api, neo: api, java: 8 } + - { dir: 1_21, mc: 1.21, lex: 51.0.24, neo: 96-beta, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, lex: 50.1.10, neo: 119, java: 21 } - { dir: 1_20, mc: 1.20.4, lex: 49.0.38, neo: 219, java: 17 } - { dir: 1_20, mc: 1.20.3, lex: 49.0.2, neo: 8-beta, java: 17 } - { dir: 1_20, mc: 1.20.2, lex: 48.1.0, neo: 88, java: 17 } @@ -36,7 +38,7 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./${{ matrix.version.dir }} - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} -Pneoforge_version=${{ matrix.version.neo }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} -Pneoforge_version=${{ matrix.version.neo }} --stacktrace - name: Upload ${{ matrix.version.mc }} Jars uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/build-all-matrix.yml b/.github/workflows/build-all-matrix.yml index 4665abf..f69eeba 100644 --- a/.github/workflows/build-all-matrix.yml +++ b/.github/workflows/build-all-matrix.yml @@ -9,6 +9,8 @@ jobs: matrix: version: - { dir: api, mc: api, lex: api, neo: api, java: 8 } + - { dir: 1_21, mc: 1.21, lex: 51.0.24, neo: 96-beta, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, lex: 50.1.10, neo: 119, java: 21 } - { dir: 1_20, mc: 1.20.4, lex: 49.0.38, neo: 219, java: 17 } - { dir: 1_20, mc: 1.20.3, lex: 49.0.2, neo: 8-beta, java: 17 } - { dir: 1_20, mc: 1.20.2, lex: 48.1.0, neo: 88, java: 17 } diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index c2d0724..1f5e9f4 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -23,3 +23,7 @@ jobs: uses: 3arthqu4ke/mc-runtime-test/.github/workflows/build-matrix-1.20.1.yml@main build-1_20: uses: 3arthqu4ke/mc-runtime-test/.github/workflows/build-matrix-1.20.yml@main + build-1_20_6: + uses: 3arthqu4ke/mc-runtime-test/.github/workflows/build-matrix-1.20.6.yml@main + build-1_21: + uses: 3arthqu4ke/mc-runtime-test/.github/workflows/build-matrix-1.21.yml@main diff --git a/.github/workflows/build-api.yml b/.github/workflows/build-api.yml index 4c4b3e6..c1bbd77 100644 --- a/.github/workflows/build-api.yml +++ b/.github/workflows/build-api.yml @@ -26,4 +26,4 @@ jobs: - name: Build with Gradle working-directory: ./api run: | - ./gradlew build + ./gradlew build --stacktrace diff --git a/.github/workflows/build-matrix-1.12.yml b/.github/workflows/build-matrix-1.12.yml index 9d27674..6b29532 100644 --- a/.github/workflows/build-matrix-1.12.yml +++ b/.github/workflows/build-matrix-1.12.yml @@ -20,4 +20,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./1_12 - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} --stacktrace diff --git a/.github/workflows/build-matrix-1.16.yml b/.github/workflows/build-matrix-1.16.yml index 0520d02..fb136cd 100644 --- a/.github/workflows/build-matrix-1.16.yml +++ b/.github/workflows/build-matrix-1.16.yml @@ -21,4 +21,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./1_16 - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} --stacktrace diff --git a/.github/workflows/build-matrix-1.17.yml b/.github/workflows/build-matrix-1.17.yml index 81eb076..5e3f23e 100644 --- a/.github/workflows/build-matrix-1.17.yml +++ b/.github/workflows/build-matrix-1.17.yml @@ -20,4 +20,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./1_17 - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} --stacktrace diff --git a/.github/workflows/build-matrix-1.18.yml b/.github/workflows/build-matrix-1.18.yml index 1dc6439..b54e484 100644 --- a/.github/workflows/build-matrix-1.18.yml +++ b/.github/workflows/build-matrix-1.18.yml @@ -21,4 +21,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./1_18 - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} --stacktrace diff --git a/.github/workflows/build-matrix-1.19.yml b/.github/workflows/build-matrix-1.19.yml index 7fb6f59..e02b4a5 100644 --- a/.github/workflows/build-matrix-1.19.yml +++ b/.github/workflows/build-matrix-1.19.yml @@ -20,4 +20,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./1_19 - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} --stacktrace diff --git a/.github/workflows/build-matrix-1.20.1.yml b/.github/workflows/build-matrix-1.20.1.yml index c514a9d..fd9e5a5 100644 --- a/.github/workflows/build-matrix-1.20.1.yml +++ b/.github/workflows/build-matrix-1.20.1.yml @@ -20,4 +20,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./1_20/1_20_1 - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} --stacktrace diff --git a/.github/workflows/build-matrix-1.20.6.yml b/.github/workflows/build-matrix-1.20.6.yml new file mode 100644 index 0000000..66366ab --- /dev/null +++ b/.github/workflows/build-matrix-1.20.6.yml @@ -0,0 +1,23 @@ +name: Build Matrix 1.20+ +on: + workflow_dispatch: + workflow_call: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + version: [ {mc: 1.20.6, lex: 50.1.10, neo: 119} ] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: adopt + - name: Grant execute permission for gradlew + working-directory: ./1_20/1_20_6 + run: chmod +x gradlew + - name: Build + working-directory: ./1_20/1_20_6 + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} -Pneoforge_version=${{ matrix.version.neo }} --stacktrace diff --git a/.github/workflows/build-matrix-1.20.yml b/.github/workflows/build-matrix-1.20.yml index 7697b4a..7cc4bf9 100644 --- a/.github/workflows/build-matrix-1.20.yml +++ b/.github/workflows/build-matrix-1.20.yml @@ -20,4 +20,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./1_20 - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} -Pneoforge_version=${{ matrix.version.neo }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} -Pneoforge_version=${{ matrix.version.neo }} --stacktrace diff --git a/.github/workflows/build-matrix-1.21.yml b/.github/workflows/build-matrix-1.21.yml new file mode 100644 index 0000000..487b2dc --- /dev/null +++ b/.github/workflows/build-matrix-1.21.yml @@ -0,0 +1,23 @@ +name: Build Matrix 1.21+ +on: + workflow_dispatch: + workflow_call: + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + version: [ {mc: 1.21, lex: 51.0.24, neo: 96-beta} ] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: adopt + - name: Grant execute permission for gradlew + working-directory: ./1_21 + run: chmod +x gradlew + - name: Build + working-directory: ./1_21 + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} -Pneoforge_version=${{ matrix.version.neo }} --stacktrace diff --git a/.github/workflows/build-matrix-1.7.yml b/.github/workflows/build-matrix-1.7.yml index a96ee6f..3aafc53 100644 --- a/.github/workflows/build-matrix-1.7.yml +++ b/.github/workflows/build-matrix-1.7.yml @@ -20,4 +20,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./1_7_10 - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} --stacktrace diff --git a/.github/workflows/build-matrix-1.8.yml b/.github/workflows/build-matrix-1.8.yml index 6016956..d4cd5a1 100644 --- a/.github/workflows/build-matrix-1.8.yml +++ b/.github/workflows/build-matrix-1.8.yml @@ -20,4 +20,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./1_8_9 - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} --stacktrace diff --git a/.github/workflows/build-specific-reusable.yml b/.github/workflows/build-specific-reusable.yml index 64fe53b..d994045 100644 --- a/.github/workflows/build-specific-reusable.yml +++ b/.github/workflows/build-specific-reusable.yml @@ -47,4 +47,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./${{ inputs.dir }} - run: ./gradlew build -Pminecraft_version=${{ inputs.mc }} -Plexforge_version=${{ inputs.lex }} -Pneoforge_version=${{ inputs.neo }} + run: ./gradlew build -Pminecraft_version=${{ inputs.mc }} -Plexforge_version=${{ inputs.lex }} -Pneoforge_version=${{ inputs.neo }} --stacktrace diff --git a/.github/workflows/build-specific.yml b/.github/workflows/build-specific.yml index 93a16fd..06009f5 100644 --- a/.github/workflows/build-specific.yml +++ b/.github/workflows/build-specific.yml @@ -41,4 +41,4 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./${{ github.event.inputs.dir }} - run: ./gradlew build -Pminecraft_version=${{ github.event.inputs.mc }} -Plexforge_version=${{ github.event.inputs.lex }} -Pneoforge_version=${{ github.event.inputs.neo }} + run: ./gradlew build -Pminecraft_version=${{ github.event.inputs.mc }} -Plexforge_version=${{ github.event.inputs.lex }} -Pneoforge_version=${{ github.event.inputs.neo }} --stacktrace diff --git a/.github/workflows/fabric.yml b/.github/workflows/fabric.yml index ad9549f..b9d4969 100644 --- a/.github/workflows/fabric.yml +++ b/.github/workflows/fabric.yml @@ -42,7 +42,7 @@ jobs: - name: Configure Accessibility run: echo onboardAccessibility:false >> run/options.txt - name: Build - run: ./gradlew build + run: ./gradlew build --stacktrace - name: Copy mod run: cp build/libs/mc-runtime-test-*-fabric-release.jar run/mods - name: LS mods dir diff --git a/.github/workflows/release-all.yml b/.github/workflows/release-all.yml index 255e8c8..bfefa1c 100644 --- a/.github/workflows/release-all.yml +++ b/.github/workflows/release-all.yml @@ -11,6 +11,8 @@ jobs: matrix: version: - { dir: api, mc: api, lex: api, neo: api, java: 8 } + - { dir: 1_21, mc: 1.21, lex: 51.0.24, neo: 96-beta, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, lex: 50.1.10, neo: 119, java: 21 } - { dir: 1_20, mc: 1.20.4, lex: 49.0.38, neo: 219, java: 17 } - { dir: 1_20, mc: 1.20.3, lex: 49.0.2, neo: 8-beta, java: 17 } - { dir: 1_20, mc: 1.20.2, lex: 48.1.0, neo: 88, java: 17 } @@ -38,7 +40,7 @@ jobs: run: chmod +x gradlew - name: Build working-directory: ./${{ matrix.version.dir }} - run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} -Pneoforge_version=${{ matrix.version.neo }} + run: ./gradlew build -Pminecraft_version=${{ matrix.version.mc }} -Plexforge_version=${{ matrix.version.lex }} -Pneoforge_version=${{ matrix.version.neo }} --stacktrace - name: Upload ${{ matrix.version.mc }} Jars uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/run-gametests-latest.yml b/.github/workflows/run-gametests-latest.yml index 7fb2fd4..e207b97 100644 --- a/.github/workflows/run-gametests-latest.yml +++ b/.github/workflows/run-gametests-latest.yml @@ -17,7 +17,7 @@ jobs: run: chmod +x gradlew - name: Build Gametest working-directory: ./gametest - run: ./gradlew build + run: ./gradlew build --stacktrace - uses: actions/upload-artifact@v4 with: name: gametest-jars @@ -36,7 +36,7 @@ jobs: run: chmod +x gradlew - name: Build latest working-directory: ./1_20 - run: ./gradlew build + run: ./gradlew build --stacktrace - uses: actions/upload-artifact@v4 with: name: latest-jars @@ -47,9 +47,9 @@ jobs: strategy: matrix: version: - - { dir: 1_20, mc: 1.20.4, type: lexforge, modloader: forge, regex: .*forge.*, java: 17 } - - { dir: 1_20, mc: 1.20.4, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 17 } - - { dir: 1_20, mc: 1.20.4, type: fabric, modloader: fabric, regex: .*fabric.*, java: 17 } + - { dir: 1_20, mc: 1.20.6, type: lexforge, modloader: forge, regex: .*forge.*, java: 21 } + - { dir: 1_20, mc: 1.20.6, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 21 } + - { dir: 1_20, mc: 1.20.6, type: fabric, modloader: fabric, regex: .*fabric.*, java: 21 } runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -58,12 +58,12 @@ jobs: run: mkdir -p run/mods - name: Copy mod files run: | - cp gametest-jars/clientgametest-1.20.4-2.0.0-fabric.jar run/mods - cp gametest-jars/clientgametest-1.20.4-2.0.0-neoforge.jar run/mods - cp gametest-jars/clientgametest-1.20.4-2.0.0-lexforge.jar run/mods - cp latest-jars/mc-runtime-test-1.20.4-2.0.0-fabric-release.jar run/mods - cp latest-jars/mc-runtime-test-1.20.4-2.0.0-lexforge-release.jar run/mods - cp latest-jars/mc-runtime-test-1.20.4-2.0.0-neoforge-release.jar run/mods + cp gametest-jars/clientgametest-1.20.6-2.1.0-fabric.jar run/mods + cp gametest-jars/clientgametest-1.20.6-2.1.0-neoforge.jar run/mods + cp gametest-jars/clientgametest-1.20.6-2.1.0-lexforge.jar run/mods + cp latest-jars/mc-runtime-test-1.20.6-2.1.0-fabric-release.jar run/mods + cp latest-jars/mc-runtime-test-1.20.6-2.1.0-lexforge-release.jar run/mods + cp latest-jars/mc-runtime-test-1.20.6-2.1.0-neoforge-release.jar run/mods - name: Run game for version id: local-action uses: ./.github/actions/local-action diff --git a/.github/workflows/run-latest.yml b/.github/workflows/run-latest.yml index f154a6c..32a845b 100644 --- a/.github/workflows/run-latest.yml +++ b/.github/workflows/run-latest.yml @@ -8,9 +8,9 @@ jobs: strategy: matrix: version: - - { dir: 1_20, mc: 1.20.4, type: lexforge, modloader: forge, regex: .*forge.*, java: 17 } - - { dir: 1_20, mc: 1.20.4, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 17 } - - { dir: 1_20, mc: 1.20.4, type: fabric, modloader: fabric, regex: .*fabric.*, java: 17 } + - { dir: 1_20/1_20_6, mc: 1.20.6, type: lexforge, modloader: forge, regex: .*forge.*, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, type: fabric, modloader: fabric, regex: .*fabric.*, java: 21 } uses: 3arthqu4ke/mc-runtime-test/.github/workflows/run-specific-reusable.yml@main with: dir: ${{ matrix.version.dir }} diff --git a/.github/workflows/run-matrix-with-hmc.yml b/.github/workflows/run-matrix-with-hmc.yml index 9b1e08b..3bbbb80 100644 --- a/.github/workflows/run-matrix-with-hmc.yml +++ b/.github/workflows/run-matrix-with-hmc.yml @@ -8,6 +8,12 @@ jobs: strategy: matrix: version: + - { dir: 1_21, mc: 1.21, type: lexforge, modloader: forge, regex: .*forge.*, java: 21 } + - { dir: 1_21, mc: 1.21, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 21 } + - { dir: 1_21, mc: 1.21, type: fabric, modloader: fabric, regex: .*fabric.*, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, type: lexforge, modloader: forge, regex: .*forge.*, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, type: fabric, modloader: fabric, regex: .*fabric.*, java: 21 } - { dir: 1_20, mc: 1.20.4, type: lexforge, modloader: forge, regex: .*forge.*, java: 17 } - { dir: 1_20, mc: 1.20.4, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 17 } - { dir: 1_20, mc: 1.20.4, type: fabric, modloader: fabric, regex: .*fabric.*, java: 17 } diff --git a/.github/workflows/run-matrix.yml b/.github/workflows/run-matrix.yml index 3ccfaf7..4bab436 100644 --- a/.github/workflows/run-matrix.yml +++ b/.github/workflows/run-matrix.yml @@ -10,6 +10,12 @@ jobs: strategy: matrix: version: + - { dir: 1_21, mc: 1.21, type: lexforge, modloader: forge, regex: .*forge.*, java: 21 } + - { dir: 1_21, mc: 1.21, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 21 } + - { dir: 1_21, mc: 1.21, type: fabric, modloader: fabric, regex: .*fabric.*, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, type: lexforge, modloader: forge, regex: .*forge.*, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 21 } + - { dir: 1_20/1_20_6, mc: 1.20.6, type: fabric, modloader: fabric, regex: .*fabric.*, java: 21 } - { dir: 1_20, mc: 1.20.4, type: lexforge, modloader: forge, regex: .*forge.*, java: 17 } - { dir: 1_20, mc: 1.20.4, type: neoforge, modloader: neoforge, regex: .*neoforge.*, java: 17 } - { dir: 1_20, mc: 1.20.4, type: fabric, modloader: fabric, regex: .*fabric.*, java: 17 } diff --git a/.github/workflows/run-specific-reusable.yml b/.github/workflows/run-specific-reusable.yml index 30d5f5a..89fbfe5 100644 --- a/.github/workflows/run-specific-reusable.yml +++ b/.github/workflows/run-specific-reusable.yml @@ -99,7 +99,7 @@ jobs: run: echo onboardAccessibility:false >> run/options.txt - name: Build working-directory: ./${{ inputs.dir }} - run: ./gradlew build --stracktrace + run: ./gradlew build --stacktrace - name: Copy mod run: cp ${{ inputs.dir }}/build/libs/mc-runtime-test-*-${{ inputs.type }}-release.jar run/mods - name: LS mods dir diff --git a/.github/workflows/run-specific-xvfb.yml b/.github/workflows/run-specific-xvfb.yml new file mode 100644 index 0000000..ab23c4c --- /dev/null +++ b/.github/workflows/run-specific-xvfb.yml @@ -0,0 +1,98 @@ +name: Run MC with Xvfb +on: + workflow_dispatch: + inputs: + dir: + description: 'The directory to build in' + required: true + default: '1_20' + mc: + description: 'The MC version to build' + required: true + default: '1.20.4' + type: + description: 'The type to of jar to use (lexforge, neoforge or fabric)' + required: true + default: 'lexforge' + modloader: + description: 'The modloader to install with HeadlessMc (forge, neoforge or fabric)' + required: true + default: 'forge' + regex: + description: 'Regex to match the MC version to launch (forge is like 1.20.4-forge and fabric starts with fabric-1.20)' + required: true + default: 'fabric.*1.20.4' + java: + description: 'The Java version to use' + required: true + default: '17' + java-distribution: + description: 'The Java distribution to use' + required: false + default: 'adopt' + headlessmc-command: + description: 'Arguments for the headlessmc command.' + required: false + default: '--jvm -Djava.awt.headless=true' + type: string + download-hmc: + description: 'Whether to download headlessmc or not, if not you need to provide a file called headlessmc-launcher.jar.' + required: false + default: 'true' + type: string + hmc-version: + description: 'The version of headlessmc to download.' + required: false + default: '1.10.2' + type: string + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: ${{ github.event.inputs.java }} + distribution: ${{ github.event.inputs.java-distribution }} + - name: Grant execute permission for gradlew + working-directory: ./${{ github.event.inputs.dir }} + run: chmod +x gradlew + - name: Setup HeadlessMC directory + run: mkdir HeadlessMC + - name: Configure HeadlessMC java versions + run: echo hmc.java.versions=$JAVA_HOME/bin/java > HeadlessMC/config.properties + - name: Configure HeadlessMC game directory + run: echo hmc.gamedir=$PWD/run >> HeadlessMC/config.properties + - name: Configure offline mode + run: echo hmc.offline=true >> HeadlessMC/config.properties + - name: Configure Exceptions + run: echo hmc.rethrow.launch.exceptions=true >> HeadlessMC/config.properties + - name: Configure Failing on wrong command + run: echo hmc.exit.on.failed.command=true >> HeadlessMC/config.properties + - name: Configure Dummy Assets + run: echo hmc.assets.dummy=true >> HeadlessMC/config.properties + - name: Get HeadlessMC + if: ${{ github.event.inputs.download-hmc == 'true' }} + run: wget -O headlessmc-launcher.jar https://github.com/3arthqu4ke/headlessmc/releases/download/${{ github.event.inputs.hmc-version }}/headlessmc-launcher-${{ github.event.inputs.hmc-version }}.jar + - name: Download ${{ github.event.inputs.mc }} + run: java -jar headlessmc-launcher.jar --command download ${{ github.event.inputs.mc }} + - name: Download ${{ github.event.inputs.modloader }} ${{ github.event.inputs.mc }} + run: java -jar headlessmc-launcher.jar --command ${{ github.event.inputs.modloader }} ${{ github.event.inputs.mc }} --java ${{ github.event.inputs.java }} + - name: List versions + run: java -jar headlessmc-launcher.jar --command versions + - name: Make mods dir + run: mkdir -p run/mods + - name: Configure Accessibility + run: echo onboardAccessibility:false >> run/options.txt + - name: Build + working-directory: ./${{ github.event.inputs.dir }} + run: ./gradlew build --stacktrace + - name: Copy mod + run: cp ${{ github.event.inputs.dir }}/build/libs/mc-runtime-test-*-${{ github.event.inputs.type }}-release.jar run/mods + - name: LS mods dir + run: ls run/mods + - name: Run game with xvfb + uses: modmuss50/xvfb-action@v1 + with: + run: java -jar headlessmc-launcher.jar --command launch ${{ github.event.inputs.regex }} -regex ${{ github.event.inputs.headlessmc-command }} diff --git a/.github/workflows/run-specific.yml b/.github/workflows/run-specific.yml index da39a35..62434f2 100644 --- a/.github/workflows/run-specific.yml +++ b/.github/workflows/run-specific.yml @@ -1,4 +1,4 @@ -name: Run MC +name: Run MC with lwjgl on: workflow_dispatch: inputs: @@ -30,15 +30,10 @@ on: description: 'The Java distribution to use' required: false default: 'adopt' - xvfb: - description: 'Runs the game with Xvfb, if false, you should probably use the -lwjgl option in headlessmc.' - required: false - default: 'true' - type: string headlessmc-command: description: 'Arguments for the headlessmc command.' required: false - default: '--jvm -Djava.awt.headless=true' + default: '-lwjgl --jvm -Djava.awt.headless=true' type: string download-hmc: description: 'Whether to download headlessmc or not, if not you need to provide a file called headlessmc-launcher.jar.' @@ -97,13 +92,7 @@ jobs: run: cp ${{ github.event.inputs.dir }}/build/libs/mc-runtime-test-*-${{ github.event.inputs.type }}-release.jar run/mods - name: LS mods dir run: ls run/mods - - name: Run game with xvfb - uses: modmuss50/xvfb-action@v1 - if: ${{ github.event.inputs.xvfb == 'true' }} - with: - run: java -jar headlessmc-launcher.jar --command launch ${{ github.event.inputs.regex }} -regex ${{ github.event.inputs.headlessmc-command }} - name: Run game - if: ${{ github.event.inputs.xvfb != 'true' }} run: java -jar headlessmc-launcher.jar --command launch ${{ github.event.inputs.regex }} -regex ${{ github.event.inputs.headlessmc-command }} shell: bash diff --git a/1_20/1_20_6/.gitignore b/1_20/1_20_6/.gitignore new file mode 100644 index 0000000..10db306 --- /dev/null +++ b/1_20/1_20_6/.gitignore @@ -0,0 +1,43 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr +/libs/ +/logs/ +/.architectury-transformer/ diff --git a/1_20/1_20_6/build.gradle b/1_20/1_20_6/build.gradle new file mode 100644 index 0000000..1d001b9 --- /dev/null +++ b/1_20/1_20_6/build.gradle @@ -0,0 +1,245 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + id 'com.github.johnrengelman.shadow' version '7.1.2' + id 'java' + id 'maven-publish' + id 'xyz.wagyourtail.unimined' version '1.1.1' +} + +group 'me.earth' +version "$minecraft_version-${project(':api').project_version}" + +base { + archivesName = 'mc-runtime-test' +} + +sourceSets { + fabric + neoforge + lexforge +} + +repositories { + mavenCentral() + maven { + url = "https://files.minecraftforge.net/maven" + } + maven { + name = "sponge" + url = "https://repo.spongepowered.org/maven" + } + maven { + url = "https://maven.wagyourtail.xyz/releases" + } + + maven { + name = '3arthMaven' + url = 'https://3arthqu4ke.github.io/maven' + } +} + +unimined.minecraft { + version project.minecraft_version + + mappings { + mojmap() + // intermediary() + // yarn(1) + + devFallbackNamespace "mojmap" + + /*stub.withMappings("intermediary", ["yarn"]) { + c("net/minecraft/class_1927", []) { + m("method_55109", "()Lnet/minecraft/class_243;", ["getPos"]) + } + }*/ + } + + defaultRemapJar = false +} + +unimined.minecraft(sourceSets.fabric) { + combineWith(sourceSets.main) + + fabric { + loader project.fabric_version + } + + defaultRemapJar = true +} + +unimined.minecraft(sourceSets.neoforge) { + combineWith(sourceSets.main) + + neoForged { + loader project.neoforge_version + mixinConfig 'mc_runtime_test.mixins.json' + } + + minecraftRemapper.config { + // neoforge adds 1 conflict, where 2 interfaces have a method with the same name on yarn/mojmap, + // but the method has different names in the intermediary mappings. + // this is a conflict because they have a class that extends both interfaces. + // this shouldn't be a problem as long as named mappings don't make the name of those 2 methods different. + ignoreConflicts(true) + } + + defaultRemapJar = true +} + +unimined.minecraft(sourceSets.lexforge) { + combineWith(sourceSets.main) + + minecraftForge { + loader project.lexforge_version + mixinConfig 'mc_runtime_test.mixins.json' + } + + minecraftRemapper.config { + ignoreConflicts(true) + } + + defaultRemapJar = true +} + +configurations { + mainImplementation + lwjglAgent.extendsFrom runtimeOnly + jarLibs + implementation.extendsFrom jarLibs +} + +for (String platform_capitalized : ['Fabric', 'Neoforge', 'Lexforge']) { + def platform = platform_capitalized.toLowerCase() + def remapJarTask = tasks.named("remap${platform_capitalized}Jar", AbstractArchiveTask).get() + def shadowTask = tasks.register("${platform}ShadowJar", ShadowJar) { + dependsOn(remapJarTask) + it.group = 'build' + it.archiveClassifier = "${platform}-release" + from remapJarTask.outputs + it.configurations += [ project.configurations.jarLibs ] + } + + tasks.named('build') { finalizedBy(shadowTask) } +} + +dependencies { + compileOnly 'org.spongepowered:mixin:0.8.5-SNAPSHOT' + compileOnly 'me.earth.headlessmc:headlessmc:1.8.1' + lwjglAgent 'me.earth.headlessmc:headlessmc-lwjgl:1.8.1' + // yes, I actually want this at runtime to use assertions! + jarLibs 'org.junit.jupiter:junit-jupiter-api:5.10.1' + jarLibs project(':api') +} + +afterEvaluate { + fabricRunClient { + standardInput = System.in + if (rootProject.property('hmc.lwjgl').toBoolean()) { + jvmArgs += ["-javaagent:${configurations.lwjglAgent.files.iterator().next()}"] + systemProperties['joml.nounsafe'] = 'true' + systemProperties['fabric.systemLibraries'] = "${configurations.lwjglAgent.files.iterator().next()}" + } + } +} + +processFabricResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +processNeoforgeResources { + inputs.property "version", project.version + + filesMatching("META-INF/mods.toml") { + expand "version": project.version + } +} + +processLexforgeResources { + inputs.property "version", project.version + + filesMatching("META-INF/mods.toml") { + expand "version": project.version + } +} + +// Forge Runs seem to have problems running from the build/classes folder +// So instead we just run from the built jar +afterEvaluate { + lexforgeRunClient { + dependsOn(lexforgeJar) + classpath = classpath.filter { + !it.toString().contains('mc-runtime-test/build/classes/java/'.replace('/', File.separator)) + && !it.toString().contains('mc-runtime-test/build/resources/'.replace('/', File.separator)) + } + + classpath += files("${projectDir}/build/libs/mc-runtime-test-${version}-lexforge-dev.jar".replace('/', File.separator)) + } + + neoforgeRunClient { + dependsOn(neoforgeJar) + classpath = classpath.filter { + !it.toString().contains('mc-runtime-test/build/classes/java/'.replace('/', File.separator)) + && !it.toString().contains('mc-runtime-test/build/resources/'.replace('/', File.separator)) + } + + classpath += files("${projectDir}/build/libs/mc-runtime-test-${version}-neoforge-dev.jar".replace('/', File.separator)) + } +} + +tasks.withType(org.gradle.jvm.tasks.Jar).configureEach { + from("LICENSE") { + duplicatesStrategy = DuplicatesStrategy.INCLUDE + rename { "${it}_${project.archivesBaseName}" } + } + + manifest { + attributes( + 'Implementation-Title': 'MC-Runtime-Test', + 'MixinConfigs': "mc_runtime_test.mixins.json", + 'Implementation-Version': project.version, + ) + } +} + +afterEvaluate { + publishing { + publications { + "${name.toLowerCase()}"(MavenPublication) { + ((MavenPublication) it).groupId "${group}" + ((MavenPublication) it).artifactId "${archivesBaseName.toLowerCase()}" + ((MavenPublication) it).version "${version}" + from components.java + for (String platform: ['Fabric', 'Lexforge', 'Neoforge']) { + String platform_lower = platform.toLowerCase() + artifact tasks.named("${platform_lower}Jar").get() + artifact tasks.named("remap${platform}Jar").get() + artifact tasks.named("${platform_lower}ShadowJar").get() + } + } + } + + repositories { + if (System.getenv('DEPLOY_TO_GITHUB_PACKAGES_URL') == null) { + maven { + name = 'BuildDirMaven' + url = rootProject.projectDir.toPath().parent.resolve('build').resolve('maven') + } + } else { + maven { + name = 'GithubPagesMaven' + url = System.getenv('DEPLOY_TO_GITHUB_PACKAGES_URL') + credentials { + username = System.getenv('GITHUB_USER') + password = System.getenv('GITHUB_TOKEN') + } + } + } + } + } +} diff --git a/1_20/1_20_6/gradle.properties b/1_20/1_20_6/gradle.properties new file mode 100644 index 0000000..766c608 --- /dev/null +++ b/1_20/1_20_6/gradle.properties @@ -0,0 +1,9 @@ +org.gradle.jvmargs = -Xmx2G + +minecraft_version = 1.20.6 +mapping_version = 1 +neoforge_version = 119 +lexforge_version = 50.1.10 +fabric_version = 0.15.9 +# Whether to use the headlessmc lwjgl agent or not +hmc.lwjgl=false diff --git a/1_20/1_20_6/gradle/wrapper/gradle-wrapper.jar b/1_20/1_20_6/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7454180 Binary files /dev/null and b/1_20/1_20_6/gradle/wrapper/gradle-wrapper.jar differ diff --git a/1_20/1_20_6/gradle/wrapper/gradle-wrapper.properties b/1_20/1_20_6/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2bbac7d --- /dev/null +++ b/1_20/1_20_6/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/1_20/1_20_6/gradlew b/1_20/1_20_6/gradlew new file mode 100644 index 0000000..79a61d4 --- /dev/null +++ b/1_20/1_20_6/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/1_20/1_20_6/gradlew.bat b/1_20/1_20_6/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/1_20/1_20_6/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/1_20/1_20_6/settings.gradle b/1_20/1_20_6/settings.gradle new file mode 100644 index 0000000..cb8be26 --- /dev/null +++ b/1_20/1_20_6/settings.gradle @@ -0,0 +1,30 @@ +pluginManagement { + repositories { + mavenCentral() + maven { + url = "https://maven.neoforged.net/releases" + } + maven { + url = "https://maven.minecraftforge.net/" + } + maven { + url = "https://maven.fabricmc.net/" + } + maven { + url = "https://maven.wagyourtail.xyz/releases" + } + maven { + url = "https://maven.wagyourtail.xyz/snapshots" + } + gradlePluginPortal() { + content { + excludeGroup("org.apache.logging.log4j") + } + } + } +} + +include 'api' +project(':api').projectDir = file('../../api') + +rootProject.name = 'mc-runtime-test' \ No newline at end of file diff --git a/1_20/1_20_6/src/fabric/resources/fabric.mod.json b/1_20/1_20_6/src/fabric/resources/fabric.mod.json new file mode 100644 index 0000000..9ddd439 --- /dev/null +++ b/1_20/1_20_6/src/fabric/resources/fabric.mod.json @@ -0,0 +1,28 @@ +{ + "schemaVersion": 1, + "id": "mc_runtime_test", + "version": "${version}", + + "name": "MC-Runtime-Test", + "description": "Run tests on the Minecraft client at runtime", + "authors": [ + "3arthqu4ke" + ], + "contact": { + "homepage": "https://github.com/3arthqu4ke/mc-runtime-test", + "sources": "https://github.com/3arthqu4ke/mc-runtime-test" + }, + + "license": "MIT", + + "environment": "*", + "mixins": [ + "mc_runtime_test.mixins.json" + ], + + "depends": { + "fabricloader": ">=0.14.19", + "minecraft": "~1.20.5", + "java": ">=8" + } +} diff --git a/1_20/1_20_6/src/lexforge/java/me/earth/mc_runtime_test/forge/ForgeMod.java b/1_20/1_20_6/src/lexforge/java/me/earth/mc_runtime_test/forge/ForgeMod.java new file mode 100644 index 0000000..d21a353 --- /dev/null +++ b/1_20/1_20_6/src/lexforge/java/me/earth/mc_runtime_test/forge/ForgeMod.java @@ -0,0 +1,8 @@ +package me.earth.mc_runtime_test.forge; + +import net.minecraftforge.fml.common.Mod; + +@Mod("mc_runtime_test") +public class ForgeMod { + +} diff --git a/1_20/1_20_6/src/lexforge/resources/META-INF/mods.toml b/1_20/1_20_6/src/lexforge/resources/META-INF/mods.toml new file mode 100644 index 0000000..826c14d --- /dev/null +++ b/1_20/1_20_6/src/lexforge/resources/META-INF/mods.toml @@ -0,0 +1,20 @@ +modLoader = "javafml" +loaderVersion = "[1,)" +issueTrackerURL = "https://github.com/3arthqu4ke/mc-runtime-test" +license = "MIT" + +[[mods]] +modId = "mc_runtime_test" +version = "${version}" +displayName = "MC-Runtime-Test" +authors = "3arthqu4ke" +description = ''' + Run tests on the Minecraft client at runtime +''' + +[[dependencies.mc_runtime_test]] +modId = "minecraft" +mandatory = true +versionRange = "[1.20.5,1.20.6)" +ordering = "NONE" +side = "BOTH" diff --git a/1_20/1_20_6/src/lexforge/resources/pack.mcmeta b/1_20/1_20_6/src/lexforge/resources/pack.mcmeta new file mode 100644 index 0000000..d2b91b6 --- /dev/null +++ b/1_20/1_20_6/src/lexforge/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "mc_runtime_test resources", + "pack_format": 6 + } +} \ No newline at end of file diff --git a/1_20/1_20_6/src/main/java/me/earth/mc_runtime_test/McGameTestRunner.java b/1_20/1_20_6/src/main/java/me/earth/mc_runtime_test/McGameTestRunner.java new file mode 100644 index 0000000..1cce3fd --- /dev/null +++ b/1_20/1_20_6/src/main/java/me/earth/mc_runtime_test/McGameTestRunner.java @@ -0,0 +1,64 @@ +package me.earth.mc_runtime_test; + +import com.mojang.logging.LogUtils; +import net.minecraft.gametest.framework.*; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.player.Player; +import org.slf4j.Logger; + +import java.util.Collection; +import java.util.Objects; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +/** + * Similar to running the "/test runall" command. + */ +public class McGameTestRunner { + private static final Logger LOGGER = LogUtils.getLogger(); + + /** + * Basically what happens in {@link TestCommand} when "runall" is used. + * We just exit with an error code if a test fails. + * + * @param playerUUID the uuid of the player. + * @param server the server to run the tests on. + */ + public static MultipleTestTracker runGameTests(UUID playerUUID, MinecraftServer server) throws ExecutionException, InterruptedException, TimeoutException { + return server.submit(() -> { + Player player = Objects.requireNonNull(server.getPlayerList().getPlayer(playerUUID)); + ServerLevel level = (ServerLevel) player.level(); + GameTestRunner.clearMarkers(level); + Collection testFunctions = GameTestRegistry.getAllTestFunctions(); + LOGGER.info("TestFunctions: " + testFunctions); + if (testFunctions.size() < McRuntimeTest.MIN_GAME_TESTS_TO_FIND) { + LOGGER.error("Failed to find the minimum amount of gametests, expected " + McRuntimeTest.MIN_GAME_TESTS_TO_FIND + ", but found " + testFunctions.size()); + throw new IllegalStateException("Failed to find the minimum amount of gametests, expected " + McRuntimeTest.MIN_GAME_TESTS_TO_FIND + ", but found " + testFunctions.size()); + } + + GameTestRegistry.forgetFailedTests(); + + Collection batches = GameTestBatchFactory.fromTestFunction(testFunctions, level); + GameTestRunner gameTestRunner = GameTestRunner.Builder.fromBatches(batches, level).build(); + gameTestRunner.start(); + + MultipleTestTracker multipleTestTracker = new MultipleTestTracker(gameTestRunner.getTestInfos()); + multipleTestTracker.addFailureListener(gameTestInfo -> { + LOGGER.error("Test failed: " + gameTestInfo); + if (gameTestInfo.getError() != null) { + LOGGER.error(String.valueOf(gameTestInfo), gameTestInfo.getError()); + } + + if (!gameTestInfo.isOptional() || McRuntimeTest.GAME_TESTS_FAIL_ON_OPTIONAL) { + System.exit(-1); + } + }); + + return multipleTestTracker; + }).get(60, TimeUnit.SECONDS); + } + +} diff --git a/1_20/1_20_6/src/main/java/me/earth/mc_runtime_test/mixin/ICreateWorldScreen.java b/1_20/1_20_6/src/main/java/me/earth/mc_runtime_test/mixin/ICreateWorldScreen.java new file mode 100644 index 0000000..f350807 --- /dev/null +++ b/1_20/1_20_6/src/main/java/me/earth/mc_runtime_test/mixin/ICreateWorldScreen.java @@ -0,0 +1,12 @@ +package me.earth.mc_runtime_test.mixin; + +import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(CreateWorldScreen.class) +public interface ICreateWorldScreen { + @Invoker("onCreate") + void invokeOnCreate(); + +} diff --git a/1_20/1_20_6/src/main/java/me/earth/mc_runtime_test/mixin/MixinMinecraft.java b/1_20/1_20_6/src/main/java/me/earth/mc_runtime_test/mixin/MixinMinecraft.java new file mode 100644 index 0000000..e6e9389 --- /dev/null +++ b/1_20/1_20_6/src/main/java/me/earth/mc_runtime_test/mixin/MixinMinecraft.java @@ -0,0 +1,119 @@ +package me.earth.mc_runtime_test.mixin; + +import me.earth.mc_runtime_test.McGameTestRunner; +import me.earth.mc_runtime_test.McRuntimeTest; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.DeathScreen; +import net.minecraft.client.gui.screens.ErrorScreen; +import net.minecraft.client.gui.screens.Overlay; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen; +import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.server.IntegratedServer; +import net.minecraft.core.SectionPos; +import net.minecraft.gametest.framework.MultipleTestTracker; +import net.minecraft.world.level.GameType; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Objects; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +@Mixin(Minecraft.class) +public abstract class MixinMinecraft { + @Shadow @Final private static Logger LOGGER; + @Shadow @Nullable public LocalPlayer player; + @Shadow @Nullable public ClientLevel level; + @Shadow @Nullable public Screen screen; + @Shadow @Nullable private IntegratedServer singleplayerServer; + @Shadow private volatile boolean running; + + @Unique + private boolean mcRuntimeTest$startedLoadingSPWorld = false; + @Unique + private boolean mcRuntimeTest$worldCreationStarted = false; + @Unique + private MultipleTestTracker mcRuntimeTest$testTracker = null; + + @Shadow + public abstract @Nullable Overlay getOverlay(); + + @Inject(method = "setScreen", at = @At("HEAD")) + private void setScreenHook(Screen screen, CallbackInfo ci) { + if (!McRuntimeTest.screenHook()) { + return; + } + + if (screen instanceof ErrorScreen) { + running = false; + throw new RuntimeException("Error Screen " + screen); + } else if (screen instanceof DeathScreen && player != null) { + player.respawn(); + } + } + + @Inject(method = "tick", at = @At("HEAD")) + private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedException, TimeoutException { + if (!McRuntimeTest.tickHook()) { + return; + } + + if (getOverlay() == null) { + if (!mcRuntimeTest$startedLoadingSPWorld && getOverlay() == null) { + CreateWorldScreen.openFresh(Minecraft.class.cast(this), null); + mcRuntimeTest$startedLoadingSPWorld = true; + } else if (!mcRuntimeTest$worldCreationStarted && screen instanceof ICreateWorldScreen createWorldScreen) { + createWorldScreen.invokeOnCreate(); + mcRuntimeTest$worldCreationStarted = true; + } + } else { + LOGGER.info("Waiting for overlay to disappear..."); + } + + // TODO: detect SinglePlayerServer crash where game freezes? + if (player != null && level != null) { + if (screen == null) { + if (!level.getChunk(SectionPos.blockToSectionCoord(player.getBlockX()), SectionPos.blockToSectionCoord(player.getBlockZ())).isEmpty()) { + if (player.tickCount < 100) { + LOGGER.info("Waiting " + (100 - player.tickCount) + " ticks before testing..."); + } else if (mcRuntimeTest$testTracker == null) { + if (McRuntimeTest.RUN_GAME_TESTS) { + LOGGER.info("Running game tests..."); + mcRuntimeTest$testTracker = McGameTestRunner.runGameTests(player.getUUID(), Objects.requireNonNull(singleplayerServer)); + } else { + LOGGER.info("Successfully finished."); + running = false; + } + } else if (mcRuntimeTest$testTracker.isDone()) { + if (mcRuntimeTest$testTracker.getFailedRequiredCount() > 0 + || mcRuntimeTest$testTracker.getFailedOptionalCount() > 0 && McRuntimeTest.GAME_TESTS_FAIL_ON_OPTIONAL) { + System.exit(-1); + } + + running = false; + } else { + LOGGER.info("Waiting for GameTest: " + mcRuntimeTest$testTracker.getProgressBar()); + } + } else { + LOGGER.info("Players chunk not yet loaded, " + player + ": cores: " + Runtime.getRuntime().availableProcessors() + + ", server running: " + (singleplayerServer == null ? "null" : singleplayerServer.isRunning())); + } + } else { + LOGGER.info("Screen not yet null: " + screen); + } + } else { + LOGGER.info("Waiting for player to load..."); + } + } + +} diff --git a/1_20/1_20_6/src/main/resources/mc_runtime_test.mixins.json b/1_20/1_20_6/src/main/resources/mc_runtime_test.mixins.json new file mode 100644 index 0000000..3f834e1 --- /dev/null +++ b/1_20/1_20_6/src/main/resources/mc_runtime_test.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "me.earth.mc_runtime_test.mixin", + "compatibilityLevel": "JAVA_8", + "client": [ + "ICreateWorldScreen", + "MixinMinecraft" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/1_20/1_20_6/src/neoforge/java/me/earth/mc_runtime_test/neoforge/NeoForgeMod.java b/1_20/1_20_6/src/neoforge/java/me/earth/mc_runtime_test/neoforge/NeoForgeMod.java new file mode 100644 index 0000000..c8e767c --- /dev/null +++ b/1_20/1_20_6/src/neoforge/java/me/earth/mc_runtime_test/neoforge/NeoForgeMod.java @@ -0,0 +1,8 @@ +package me.earth.mc_runtime_test.neoforge; + +import net.neoforged.fml.common.Mod; + +@Mod("mc_runtime_test") +public class NeoForgeMod { + +} diff --git a/1_20/1_20_6/src/neoforge/resources/META-INF/neoforge.mods.toml b/1_20/1_20_6/src/neoforge/resources/META-INF/neoforge.mods.toml new file mode 100644 index 0000000..002ac50 --- /dev/null +++ b/1_20/1_20_6/src/neoforge/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,20 @@ +modLoader = "javafml" +loaderVersion = "[1,)" +issueTrackerURL = "https://github.com/3arthqu4ke/mc-runtime-test" +license = "MPL-2.0" + +[[mods]] +modId = "mc_runtime_test" +version = "${version}" +displayName = "MC-Runtime-Test" +authors = "3arthqu4ke" +description = ''' + Run tests on the Minecraft client at runtime +''' + +[[dependencies.mc_runtime_test]] +modId = "minecraft" +mandatory = true +versionRange = "[1.20.5,1.20.6)" +ordering = "NONE" +side = "BOTH" diff --git a/1_20/1_20_6/src/neoforge/resources/pack.mcmeta b/1_20/1_20_6/src/neoforge/resources/pack.mcmeta new file mode 100644 index 0000000..d2b91b6 --- /dev/null +++ b/1_20/1_20_6/src/neoforge/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "mc_runtime_test resources", + "pack_format": 6 + } +} \ No newline at end of file diff --git a/1_20/gradle/wrapper/gradle-wrapper.properties b/1_20/gradle/wrapper/gradle-wrapper.properties index 29d2731..2bbac7d 100644 --- a/1_20/gradle/wrapper/gradle-wrapper.properties +++ b/1_20/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file diff --git a/1_21/.gitignore b/1_21/.gitignore new file mode 100644 index 0000000..10db306 --- /dev/null +++ b/1_21/.gitignore @@ -0,0 +1,43 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr +/libs/ +/logs/ +/.architectury-transformer/ diff --git a/1_21/build.gradle b/1_21/build.gradle new file mode 100644 index 0000000..ca95d5b --- /dev/null +++ b/1_21/build.gradle @@ -0,0 +1,245 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + id 'com.github.johnrengelman.shadow' version '7.1.2' + id 'java' + id 'maven-publish' + id 'xyz.wagyourtail.unimined' version '1.3.3' +} + +group 'me.earth' +version "$minecraft_version-${project(':api').project_version}" + +base { + archivesName = 'mc-runtime-test' +} + +sourceSets { + fabric + neoforge + lexforge +} + +repositories { + mavenCentral() + maven { + url = "https://files.minecraftforge.net/maven" + } + maven { + name = "sponge" + url = "https://repo.spongepowered.org/maven" + } + maven { + url = "https://maven.wagyourtail.xyz/releases" + } + + maven { + name = '3arthMaven' + url = 'https://3arthqu4ke.github.io/maven' + } +} + +unimined.minecraft { + version project.minecraft_version + + mappings { + mojmap() + // intermediary() + // yarn(1) + + devFallbackNamespace "mojmap" + + /*stub.withMappings("intermediary", ["yarn"]) { + c("net/minecraft/class_1927", []) { + m("method_55109", "()Lnet/minecraft/class_243;", ["getPos"]) + } + }*/ + } + + defaultRemapJar = false +} + +unimined.minecraft(sourceSets.fabric) { + combineWith(sourceSets.main) + + fabric { + loader project.fabric_version + } + + defaultRemapJar = true +} + +unimined.minecraft(sourceSets.neoforge) { + combineWith(sourceSets.main) + + neoForged { + loader project.neoforge_version + mixinConfig 'mc_runtime_test.mixins.json' + } + + minecraftRemapper.config { + // neoforge adds 1 conflict, where 2 interfaces have a method with the same name on yarn/mojmap, + // but the method has different names in the intermediary mappings. + // this is a conflict because they have a class that extends both interfaces. + // this shouldn't be a problem as long as named mappings don't make the name of those 2 methods different. + ignoreConflicts(true) + } + + defaultRemapJar = true +} + +unimined.minecraft(sourceSets.lexforge) { + combineWith(sourceSets.main) + + minecraftForge { + loader project.lexforge_version + mixinConfig 'mc_runtime_test.mixins.json' + } + + minecraftRemapper.config { + ignoreConflicts(true) + } + + defaultRemapJar = true +} + +configurations { + mainImplementation + lwjglAgent.extendsFrom runtimeOnly + jarLibs + implementation.extendsFrom jarLibs +} + +for (String platform_capitalized : ['Fabric', 'Neoforge', 'Lexforge']) { + def platform = platform_capitalized.toLowerCase() + def remapJarTask = tasks.named("remap${platform_capitalized}Jar", AbstractArchiveTask).get() + def shadowTask = tasks.register("${platform}ShadowJar", ShadowJar) { + dependsOn(remapJarTask) + it.group = 'build' + it.archiveClassifier = "${platform}-release" + from remapJarTask.outputs + it.configurations += [ project.configurations.jarLibs ] + } + + tasks.named('build') { finalizedBy(shadowTask) } +} + +dependencies { + compileOnly 'org.spongepowered:mixin:0.8.5-SNAPSHOT' + compileOnly 'me.earth.headlessmc:headlessmc:1.8.1' + lwjglAgent 'me.earth.headlessmc:headlessmc-lwjgl:1.8.1' + // yes, I actually want this at runtime to use assertions! + jarLibs 'org.junit.jupiter:junit-jupiter-api:5.10.1' + jarLibs project(':api') +} + +afterEvaluate { + fabricRunClient { + standardInput = System.in + if (rootProject.property('hmc.lwjgl').toBoolean()) { + jvmArgs += ["-javaagent:${configurations.lwjglAgent.files.iterator().next()}"] + systemProperties['joml.nounsafe'] = 'true' + systemProperties['fabric.systemLibraries'] = "${configurations.lwjglAgent.files.iterator().next()}" + } + } +} + +processFabricResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +processNeoforgeResources { + inputs.property "version", project.version + + filesMatching("META-INF/mods.toml") { + expand "version": project.version + } +} + +processLexforgeResources { + inputs.property "version", project.version + + filesMatching("META-INF/mods.toml") { + expand "version": project.version + } +} + +// Forge Runs seem to have problems running from the build/classes folder +// So instead we just run from the built jar +afterEvaluate { + lexforgeRunClient { + dependsOn(lexforgeJar) + classpath = classpath.filter { + !it.toString().contains('mc-runtime-test/build/classes/java/'.replace('/', File.separator)) + && !it.toString().contains('mc-runtime-test/build/resources/'.replace('/', File.separator)) + } + + classpath += files("${projectDir}/build/libs/mc-runtime-test-${version}-lexforge-dev.jar".replace('/', File.separator)) + } + + neoforgeRunClient { + dependsOn(neoforgeJar) + classpath = classpath.filter { + !it.toString().contains('mc-runtime-test/build/classes/java/'.replace('/', File.separator)) + && !it.toString().contains('mc-runtime-test/build/resources/'.replace('/', File.separator)) + } + + classpath += files("${projectDir}/build/libs/mc-runtime-test-${version}-neoforge-dev.jar".replace('/', File.separator)) + } +} + +tasks.withType(org.gradle.jvm.tasks.Jar).configureEach { + from("LICENSE") { + duplicatesStrategy = DuplicatesStrategy.INCLUDE + rename { "${it}_${project.archivesBaseName}" } + } + + manifest { + attributes( + 'Implementation-Title': 'MC-Runtime-Test', + 'MixinConfigs': "mc_runtime_test.mixins.json", + 'Implementation-Version': project.version, + ) + } +} + +afterEvaluate { + publishing { + publications { + "${name.toLowerCase()}"(MavenPublication) { + ((MavenPublication) it).groupId "${group}" + ((MavenPublication) it).artifactId "${archivesBaseName.toLowerCase()}" + ((MavenPublication) it).version "${version}" + from components.java + for (String platform: ['Fabric', 'Lexforge', 'Neoforge']) { + String platform_lower = platform.toLowerCase() + artifact tasks.named("${platform_lower}Jar").get() + artifact tasks.named("remap${platform}Jar").get() + artifact tasks.named("${platform_lower}ShadowJar").get() + } + } + } + + repositories { + if (System.getenv('DEPLOY_TO_GITHUB_PACKAGES_URL') == null) { + maven { + name = 'BuildDirMaven' + url = rootProject.projectDir.toPath().parent.resolve('build').resolve('maven') + } + } else { + maven { + name = 'GithubPagesMaven' + url = System.getenv('DEPLOY_TO_GITHUB_PACKAGES_URL') + credentials { + username = System.getenv('GITHUB_USER') + password = System.getenv('GITHUB_TOKEN') + } + } + } + } + } +} diff --git a/1_21/gradle.properties b/1_21/gradle.properties new file mode 100644 index 0000000..9a442d6 --- /dev/null +++ b/1_21/gradle.properties @@ -0,0 +1,10 @@ +org.gradle.jvmargs = -Xmx2G + +minecraft_version = 1.21 +# TODO: can this be removed? +mapping_version = 1 +neoforge_version = 96-beta +lexforge_version = 51.0.24 +fabric_version = 0.15.9 +# Whether to use the headlessmc lwjgl agent or not +hmc.lwjgl=false diff --git a/1_21/gradle/wrapper/gradle-wrapper.jar b/1_21/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7454180 Binary files /dev/null and b/1_21/gradle/wrapper/gradle-wrapper.jar differ diff --git a/1_21/gradle/wrapper/gradle-wrapper.properties b/1_21/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..a8382d7 --- /dev/null +++ b/1_21/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/1_21/gradlew b/1_21/gradlew new file mode 100644 index 0000000..79a61d4 --- /dev/null +++ b/1_21/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/1_21/gradlew.bat b/1_21/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/1_21/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/1_21/settings.gradle b/1_21/settings.gradle new file mode 100644 index 0000000..6b9922d --- /dev/null +++ b/1_21/settings.gradle @@ -0,0 +1,30 @@ +pluginManagement { + repositories { + mavenCentral() + maven { + url = "https://maven.neoforged.net/releases" + } + maven { + url = "https://maven.minecraftforge.net/" + } + maven { + url = "https://maven.fabricmc.net/" + } + maven { + url = "https://maven.wagyourtail.xyz/releases" + } + maven { + url = "https://maven.wagyourtail.xyz/snapshots" + } + gradlePluginPortal() { + content { + excludeGroup("org.apache.logging.log4j") + } + } + } +} + +include 'api' +project(':api').projectDir = file('../api') + +rootProject.name = 'mc-runtime-test' \ No newline at end of file diff --git a/1_21/src/fabric/resources/fabric.mod.json b/1_21/src/fabric/resources/fabric.mod.json new file mode 100644 index 0000000..e0a70c9 --- /dev/null +++ b/1_21/src/fabric/resources/fabric.mod.json @@ -0,0 +1,28 @@ +{ + "schemaVersion": 1, + "id": "mc_runtime_test", + "version": "${version}", + + "name": "MC-Runtime-Test", + "description": "Run tests on the Minecraft client at runtime", + "authors": [ + "3arthqu4ke" + ], + "contact": { + "homepage": "https://github.com/3arthqu4ke/mc-runtime-test", + "sources": "https://github.com/3arthqu4ke/mc-runtime-test" + }, + + "license": "MIT", + + "environment": "*", + "mixins": [ + "mc_runtime_test.mixins.json" + ], + + "depends": { + "fabricloader": ">=0.14.19", + "minecraft": "~1.21.0", + "java": ">=8" + } +} diff --git a/1_21/src/lexforge/java/me/earth/mc_runtime_test/forge/ForgeMod.java b/1_21/src/lexforge/java/me/earth/mc_runtime_test/forge/ForgeMod.java new file mode 100644 index 0000000..d21a353 --- /dev/null +++ b/1_21/src/lexforge/java/me/earth/mc_runtime_test/forge/ForgeMod.java @@ -0,0 +1,8 @@ +package me.earth.mc_runtime_test.forge; + +import net.minecraftforge.fml.common.Mod; + +@Mod("mc_runtime_test") +public class ForgeMod { + +} diff --git a/1_21/src/lexforge/resources/META-INF/mods.toml b/1_21/src/lexforge/resources/META-INF/mods.toml new file mode 100644 index 0000000..9fdddd7 --- /dev/null +++ b/1_21/src/lexforge/resources/META-INF/mods.toml @@ -0,0 +1,20 @@ +modLoader = "javafml" +loaderVersion = "[1,)" +issueTrackerURL = "https://github.com/3arthqu4ke/mc-runtime-test" +license = "MIT" + +[[mods]] +modId = "mc_runtime_test" +version = "${version}" +displayName = "MC-Runtime-Test" +authors = "3arthqu4ke" +description = ''' + Run tests on the Minecraft client at runtime +''' + +[[dependencies.mc_runtime_test]] +modId = "minecraft" +mandatory = true +versionRange = "[1.21)" +ordering = "NONE" +side = "BOTH" diff --git a/1_21/src/lexforge/resources/pack.mcmeta b/1_21/src/lexforge/resources/pack.mcmeta new file mode 100644 index 0000000..d2b91b6 --- /dev/null +++ b/1_21/src/lexforge/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "mc_runtime_test resources", + "pack_format": 6 + } +} \ No newline at end of file diff --git a/1_21/src/main/java/me/earth/mc_runtime_test/McGameTestRunner.java b/1_21/src/main/java/me/earth/mc_runtime_test/McGameTestRunner.java new file mode 100644 index 0000000..1cce3fd --- /dev/null +++ b/1_21/src/main/java/me/earth/mc_runtime_test/McGameTestRunner.java @@ -0,0 +1,64 @@ +package me.earth.mc_runtime_test; + +import com.mojang.logging.LogUtils; +import net.minecraft.gametest.framework.*; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.player.Player; +import org.slf4j.Logger; + +import java.util.Collection; +import java.util.Objects; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +/** + * Similar to running the "/test runall" command. + */ +public class McGameTestRunner { + private static final Logger LOGGER = LogUtils.getLogger(); + + /** + * Basically what happens in {@link TestCommand} when "runall" is used. + * We just exit with an error code if a test fails. + * + * @param playerUUID the uuid of the player. + * @param server the server to run the tests on. + */ + public static MultipleTestTracker runGameTests(UUID playerUUID, MinecraftServer server) throws ExecutionException, InterruptedException, TimeoutException { + return server.submit(() -> { + Player player = Objects.requireNonNull(server.getPlayerList().getPlayer(playerUUID)); + ServerLevel level = (ServerLevel) player.level(); + GameTestRunner.clearMarkers(level); + Collection testFunctions = GameTestRegistry.getAllTestFunctions(); + LOGGER.info("TestFunctions: " + testFunctions); + if (testFunctions.size() < McRuntimeTest.MIN_GAME_TESTS_TO_FIND) { + LOGGER.error("Failed to find the minimum amount of gametests, expected " + McRuntimeTest.MIN_GAME_TESTS_TO_FIND + ", but found " + testFunctions.size()); + throw new IllegalStateException("Failed to find the minimum amount of gametests, expected " + McRuntimeTest.MIN_GAME_TESTS_TO_FIND + ", but found " + testFunctions.size()); + } + + GameTestRegistry.forgetFailedTests(); + + Collection batches = GameTestBatchFactory.fromTestFunction(testFunctions, level); + GameTestRunner gameTestRunner = GameTestRunner.Builder.fromBatches(batches, level).build(); + gameTestRunner.start(); + + MultipleTestTracker multipleTestTracker = new MultipleTestTracker(gameTestRunner.getTestInfos()); + multipleTestTracker.addFailureListener(gameTestInfo -> { + LOGGER.error("Test failed: " + gameTestInfo); + if (gameTestInfo.getError() != null) { + LOGGER.error(String.valueOf(gameTestInfo), gameTestInfo.getError()); + } + + if (!gameTestInfo.isOptional() || McRuntimeTest.GAME_TESTS_FAIL_ON_OPTIONAL) { + System.exit(-1); + } + }); + + return multipleTestTracker; + }).get(60, TimeUnit.SECONDS); + } + +} diff --git a/1_21/src/main/java/me/earth/mc_runtime_test/mixin/ICreateWorldScreen.java b/1_21/src/main/java/me/earth/mc_runtime_test/mixin/ICreateWorldScreen.java new file mode 100644 index 0000000..f350807 --- /dev/null +++ b/1_21/src/main/java/me/earth/mc_runtime_test/mixin/ICreateWorldScreen.java @@ -0,0 +1,12 @@ +package me.earth.mc_runtime_test.mixin; + +import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(CreateWorldScreen.class) +public interface ICreateWorldScreen { + @Invoker("onCreate") + void invokeOnCreate(); + +} diff --git a/1_21/src/main/java/me/earth/mc_runtime_test/mixin/MixinMinecraft.java b/1_21/src/main/java/me/earth/mc_runtime_test/mixin/MixinMinecraft.java new file mode 100644 index 0000000..44e5c16 --- /dev/null +++ b/1_21/src/main/java/me/earth/mc_runtime_test/mixin/MixinMinecraft.java @@ -0,0 +1,117 @@ +package me.earth.mc_runtime_test.mixin; + +import me.earth.mc_runtime_test.McGameTestRunner; +import me.earth.mc_runtime_test.McRuntimeTest; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.DeathScreen; +import net.minecraft.client.gui.screens.ErrorScreen; +import net.minecraft.client.gui.screens.Overlay; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.server.IntegratedServer; +import net.minecraft.core.SectionPos; +import net.minecraft.gametest.framework.MultipleTestTracker; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.Objects; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +@Mixin(Minecraft.class) +public abstract class MixinMinecraft { + @Shadow @Final private static Logger LOGGER; + @Shadow @Nullable public LocalPlayer player; + @Shadow @Nullable public ClientLevel level; + @Shadow @Nullable public Screen screen; + @Shadow @Nullable private IntegratedServer singleplayerServer; + @Shadow private volatile boolean running; + + @Unique + private boolean mcRuntimeTest$startedLoadingSPWorld = false; + @Unique + private boolean mcRuntimeTest$worldCreationStarted = false; + @Unique + private MultipleTestTracker mcRuntimeTest$testTracker = null; + + @Shadow + public abstract @Nullable Overlay getOverlay(); + + @Inject(method = "setScreen", at = @At("HEAD")) + private void setScreenHook(Screen screen, CallbackInfo ci) { + if (!McRuntimeTest.screenHook()) { + return; + } + + if (screen instanceof ErrorScreen) { + running = false; + throw new RuntimeException("Error Screen " + screen); + } else if (screen instanceof DeathScreen && player != null) { + player.respawn(); + } + } + + @Inject(method = "tick", at = @At("HEAD")) + private void tickHook(CallbackInfo ci) throws ExecutionException, InterruptedException, TimeoutException { + if (!McRuntimeTest.tickHook()) { + return; + } + + if (getOverlay() == null) { + if (!mcRuntimeTest$startedLoadingSPWorld && getOverlay() == null) { + CreateWorldScreen.openFresh(Minecraft.class.cast(this), null); + mcRuntimeTest$startedLoadingSPWorld = true; + } else if (!mcRuntimeTest$worldCreationStarted && screen instanceof ICreateWorldScreen createWorldScreen) { + createWorldScreen.invokeOnCreate(); + mcRuntimeTest$worldCreationStarted = true; + } + } else { + LOGGER.info("Waiting for overlay to disappear..."); + } + + // TODO: detect SinglePlayerServer crash where game freezes? + if (player != null && level != null) { + if (screen == null) { + if (!level.getChunk(SectionPos.blockToSectionCoord(player.getBlockX()), SectionPos.blockToSectionCoord(player.getBlockZ())).isEmpty()) { + if (player.tickCount < 100) { + LOGGER.info("Waiting " + (100 - player.tickCount) + " ticks before testing..."); + } else if (mcRuntimeTest$testTracker == null) { + if (McRuntimeTest.RUN_GAME_TESTS) { + LOGGER.info("Running game tests..."); + mcRuntimeTest$testTracker = McGameTestRunner.runGameTests(player.getUUID(), Objects.requireNonNull(singleplayerServer)); + } else { + LOGGER.info("Successfully finished."); + running = false; + } + } else if (mcRuntimeTest$testTracker.isDone()) { + if (mcRuntimeTest$testTracker.getFailedRequiredCount() > 0 + || mcRuntimeTest$testTracker.getFailedOptionalCount() > 0 && McRuntimeTest.GAME_TESTS_FAIL_ON_OPTIONAL) { + System.exit(-1); + } + + running = false; + } else { + LOGGER.info("Waiting for GameTest: " + mcRuntimeTest$testTracker.getProgressBar()); + } + } else { + LOGGER.info("Players chunk not yet loaded, " + player + ": cores: " + Runtime.getRuntime().availableProcessors() + + ", server running: " + (singleplayerServer == null ? "null" : singleplayerServer.isRunning())); + } + } else { + LOGGER.info("Screen not yet null: " + screen); + } + } else { + LOGGER.info("Waiting for player to load..."); + } + } + +} diff --git a/1_21/src/main/resources/mc_runtime_test.mixins.json b/1_21/src/main/resources/mc_runtime_test.mixins.json new file mode 100644 index 0000000..3f834e1 --- /dev/null +++ b/1_21/src/main/resources/mc_runtime_test.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "me.earth.mc_runtime_test.mixin", + "compatibilityLevel": "JAVA_8", + "client": [ + "ICreateWorldScreen", + "MixinMinecraft" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/1_21/src/neoforge/java/me/earth/mc_runtime_test/neoforge/NeoForgeMod.java b/1_21/src/neoforge/java/me/earth/mc_runtime_test/neoforge/NeoForgeMod.java new file mode 100644 index 0000000..c8e767c --- /dev/null +++ b/1_21/src/neoforge/java/me/earth/mc_runtime_test/neoforge/NeoForgeMod.java @@ -0,0 +1,8 @@ +package me.earth.mc_runtime_test.neoforge; + +import net.neoforged.fml.common.Mod; + +@Mod("mc_runtime_test") +public class NeoForgeMod { + +} diff --git a/1_21/src/neoforge/resources/META-INF/neoforge.mods.toml b/1_21/src/neoforge/resources/META-INF/neoforge.mods.toml new file mode 100644 index 0000000..846829b --- /dev/null +++ b/1_21/src/neoforge/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,20 @@ +modLoader = "javafml" +loaderVersion = "[1,)" +issueTrackerURL = "https://github.com/3arthqu4ke/mc-runtime-test" +license = "MPL-2.0" + +[[mods]] +modId = "mc_runtime_test" +version = "${version}" +displayName = "MC-Runtime-Test" +authors = "3arthqu4ke" +description = ''' + Run tests on the Minecraft client at runtime +''' + +[[dependencies.mc_runtime_test]] +modId = "minecraft" +mandatory = true +versionRange = "[1.21)" +ordering = "NONE" +side = "BOTH" diff --git a/1_21/src/neoforge/resources/pack.mcmeta b/1_21/src/neoforge/resources/pack.mcmeta new file mode 100644 index 0000000..d2b91b6 --- /dev/null +++ b/1_21/src/neoforge/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "mc_runtime_test resources", + "pack_format": 6 + } +} \ No newline at end of file diff --git a/README.md b/README.md index 96b65bc..c221591 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ Additionally, many (e.g. mapping or mixin related) bugs only occur when running This action runs the Minecraft client using the [HeadlessMC](https://github.com/3arthqu4ke/headlessmc) launcher. It uses Xvfb as a virtual framebuffer that allows us to run the game headlessly. HeadlessMC can also be used to patch the lwjgl library. -It also provides mods for several versions, which all do one thing: join a single-player world, wait for chunks to load, + +This project also provides mods for several versions, which all do one thing: join a single-player world, wait for chunks to load, and then quit the game after a few seconds. This way you can already run simple boot tests, checking whether the game will boot with your mod. Mods for newer versions also execute all [gametests](https://www.minecraft.net/en-us/creator/article/get-started-gametest-framework) @@ -21,7 +22,8 @@ Mc-Runtime-Test currently supports the following Minecraft versions and modloade You can configure it to use any other version, but in that case you need to set `mc-runtime-test` to `none` and provide another way for the game to exit, or the workflow will run indefinitely. | Version | Forge | Fabric | NeoForge | | :-: | :-: | :-: | :-: | -| 1.20.2 - 1.20.4 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 1.21 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| 1.20.2 - 1.20.6 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | 1.20.1 | :white_check_mark: | :white_check_mark: | :warning: | | 1.19 - 1.19.4 | :white_check_mark: | :white_check_mark: | - | | 1.18.2 | :white_check_mark: | :white_check_mark: | - | @@ -49,11 +51,12 @@ jobs: run: mkdir -p run/mods && cp build/libs/.jar run/mods # Call this Action to run the client - name: Run the MC client - uses: 3arthqu4ke/mc-runtime-test@2.0.0 + uses: 3arthqu4ke/mc-runtime-test@2.1.0 with: mc: 1.20.4 modloader: fabric regex: .*fabric.* + mc-runtime-test: fabric java: 17 ``` An example workflow in action can be found [here](https://github.com/3arthqu4ke/hmc-optimizations/blob/1.20.4/.github/workflows/run-fabric.yml). @@ -70,6 +73,8 @@ An example workflow in action can be found [here](https://github.com/3arthqu4ke/ - `headlessmc-command`: Allows you to customize the arguments of the headlessmc command. - `fabric-api`: Downloads the fabric-api. (Default is none, an example value would be 0.97.0, to download 0.97.0+\) - `fabric-gametest-api`: Downloads the fabric-gametest-api to run gametests. (Default is none, an example value would be 1.3.5+85d85a934f). +- `download-hmc`: Whether to download headlessmc or not, if not you need to supply a headlessmc-launcher.jar. Default is `true`. +- `hmc-version`: The [headlessmc version](https://github.com/3arthqu4ke/headlessmc/releases) to download. # Running your own tests MC-Runtime-Test does not provide a framework for full integration tests. diff --git a/action.yml b/action.yml index 4a26d8f..0f2bb3f 100644 --- a/action.yml +++ b/action.yml @@ -106,7 +106,7 @@ runs: shell: bash - name: Download mc-runtime-test jar ${{ inputs.mc-runtime-test }} if: ${{ inputs.mc-runtime-test != 'none' }} - run: wget -O run/mods/mc-runtime-test-${{ inputs.mc }}-2.0.0-${{ inputs.mc-runtime-test }}-release.jar https://github.com/3arthqu4ke/mc-runtime-test/releases/download/2.0.0/mc-runtime-test-${{ inputs.mc }}-2.0.0-${{ inputs.mc-runtime-test }}-release.jar + run: wget -O run/mods/mc-runtime-test-${{ inputs.mc }}-2.1.0-${{ inputs.mc-runtime-test }}-release.jar https://github.com/3arthqu4ke/mc-runtime-test/releases/download/2.1.0/mc-runtime-test-${{ inputs.mc }}-2.1.0-${{ inputs.mc-runtime-test }}-release.jar shell: bash - name: Download fabric-api jar ${{ inputs.fabric-api }} if: ${{ inputs.fabric-api != 'none' }} diff --git a/api/gradle.properties b/api/gradle.properties index ca7a34f..3497e47 100644 --- a/api/gradle.properties +++ b/api/gradle.properties @@ -1 +1 @@ -project_version = 2.0.0 +project_version = 2.1.0 diff --git a/gametest/src/lexforge/resources/META-INF/mods.toml b/gametest/src/lexforge/resources/META-INF/mods.toml index 4f7fab9..ec9ebce 100644 --- a/gametest/src/lexforge/resources/META-INF/mods.toml +++ b/gametest/src/lexforge/resources/META-INF/mods.toml @@ -15,6 +15,6 @@ description = ''' [[dependencies.clientgametest]] modId = "minecraft" mandatory = true -versionRange = "[1.20.2,1.20.4]" +versionRange = "[1.20.2,1.20.6]" ordering = "NONE" side = "BOTH" diff --git a/gametest/src/neoforge/resources/META-INF/mods.toml b/gametest/src/neoforge/resources/META-INF/mods.toml index ac41c73..96beab5 100644 --- a/gametest/src/neoforge/resources/META-INF/mods.toml +++ b/gametest/src/neoforge/resources/META-INF/mods.toml @@ -15,6 +15,6 @@ description = ''' [[dependencies.clientgametest]] modId = "minecraft" mandatory = true -versionRange = "[1.20.2,1.20.4]" +versionRange = "[1.20.2,1.20.6]" ordering = "NONE" side = "BOTH"