From bc9cdd3528466eb355dec70af12fa4b5d8422ee8 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Tue, 17 Sep 2024 08:37:46 +0200 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=F0=9F=94=A7=20Add=20auto=20cursef?= =?UTF-8?q?orge=20upload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 30 +++++++--- build.gradle | 108 +++++++++++++++++++++++++++++++++++ gradle.properties | 7 ++- 3 files changed, 135 insertions(+), 10 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 70773e8b..e18ef767 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,6 +1,6 @@ name: Mod Build -on: [ push ] +on: [ workflow_dispatch, push ] jobs: build: @@ -8,9 +8,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 + with: + fetch-depth: 200 - name: Set up JDK 21 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: 21 distribution: zulu @@ -19,7 +21,7 @@ jobs: env: USERNAME: ${{ secrets.USERNAME }} READ_PACKAGES_TOKEN: ${{ secrets.READ_PACKAGES_TOKEN }} - uses: nick-invision/retry@v2 + uses: nick-invision/retry@v3 with: timeout_minutes: 10 max_attempts: 3 @@ -29,10 +31,22 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./gradlew build publish - name: Cleanup old artifacts - uses: actions/delete-package-versions@v3 + uses: actions/delete-package-versions@v5 with: package-name: 'sophisticatedbackpacks.sophisticatedbackpacks' + package-type: 'maven' min-versions-to-keep: 10 + - name: Publish to CurseForge + env: + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + run: | + BRANCH_NAME=${GITHUB_REF##*/} + if [[ "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+\.([0-9]+|x)$ ]]; then + ./gradlew curseforge + else + echo "Branch name does not match the pattern: $BRANCH_NAME. Skipping CurseForge upload." + exit 0 + fi - name: Code Quality env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -43,7 +57,7 @@ jobs: echo "VERSION_NAME=$(${{github.workspace}}/gradlew -q printVersionName | awk -F "version:" '{printf $2}')" >> $GITHUB_OUTPUT id: version - name : Compile version message - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const gh = ${{ toJSON(github) }}; @@ -64,11 +78,9 @@ jobs: core.setOutput('EMBED_DESCRIPTION', description); id: embed - name: Send Discord Notification - uses: tsickert/discord-webhook@v5.3.0 + uses: tsickert/discord-webhook@v6.0.0 with: webhook-url: ${{ secrets.DISCORD_WEBHOOK }} - embeds: ${{steps.embed.outputs.EMBEDS}} - content: null embed-title: "${{steps.embed.outputs.EMBED_TITLE}}" embed-url: "${{steps.embed.outputs.EMBED_URL}}" embed-description: "${{steps.embed.outputs.EMBED_DESCRIPTION}}" diff --git a/build.gradle b/build.gradle index 35e9ee81..61459596 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ plugins { id 'maven-publish' id 'net.neoforged.moddev' version '1.0.14' id "org.sonarqube" version "5.0.0.4638" + id "net.darkhax.curseforgegradle" version "1.1.15" } idea { @@ -230,6 +231,113 @@ sonarqube { } } +task generateChangelog { + doLast { + def changelog = new StringBuilder() + + // Function to remove characters with Unicode code points 129 or higher + def removeHighUnicodeChars = { text -> + text.codePoints() + .filter { codePoint -> codePoint <= 0x007F } // Keep only ASCII characters (U+0000 to U+007F) + .collect { codePoint -> new String(Character.toChars(codePoint)) } + .join('') + } + + // Function to format commit messages with nesting + def formatMultilineMessage = { message -> + // Split message by lines, trim whitespace, and create formatted list + def lines = message.split('\n') + def formattedMessage = lines[0].trim() // First line as top-level list item + if (lines.size() > 1) { + formattedMessage += "\n" + lines[1..-1].collect { line -> + // Trim the line and remove leading dash if present + def trimmedLine = line.trim() + if (trimmedLine.startsWith('-')) { + trimmedLine = trimmedLine.substring(1).trim() + } + " - ${trimmedLine}" // Nested list for additional lines + }.join('\n') + } + return formattedMessage + } + + // Function to remove [DEV] section from commit message + def removeDevSection = { message -> + def devIndex = message.indexOf('[DEV]') + if (devIndex != -1) { + return message.substring(0, devIndex).trim() + } + return message + } + + // Get the latest commit hash + def latestCommitHash = "git rev-parse HEAD".execute().text.trim() + + // Check if the latest commit is a merge commit + def parentCommits = "git rev-list --parents -n 1 ${latestCommitHash}".execute().text.split() + logger.info("Parent commits: ${parentCommits}") + + def commitMessages = [] + if (parentCommits.size() > 2) { // Merge commit has more than 2 parents + def firstParent = parentCommits[1] + def secondParent = parentCommits[2] + def gitLogCommand = [ + "bash", "-c", "git log --pretty=format:%B ${firstParent}..${secondParent}" + ] + commitMessages = gitLogCommand.execute().text.split('\n\n') // Split by two newlines for each commit + logger.info("Merge commit, ran git log command: ${gitLogCommand.join(' ')} and got ${commitMessages}") + } else { + // Single commit log + commitMessages = "git log -1 --pretty=%B".execute().text.split('\n\n') + // Split by two newlines for each commit + logger.info("Single commit, ran git log command: git log -1 --pretty=%B and got ${commitMessages}"); + } + + def features = [] + def fixes = [] + commitMessages.each { commitMessage -> + commitMessage = removeHighUnicodeChars(commitMessage) // Remove high Unicode characters + commitMessage = removeDevSection(commitMessage) // Remove [DEV] section + + if (commitMessage.startsWith('feat: ')) { + features.add(commitMessage.replaceFirst('feat: ', '').trim()) + } else if (commitMessage.startsWith('fix: ')) { + fixes.add(commitMessage.replaceFirst('fix: ', '').trim()) + } + } + + if (features) { + changelog.append("### Features\n") + features.each { feature -> changelog.append("- ${formatMultilineMessage(feature)}\n") } + } + + if (fixes) { + changelog.append("### Fixes\n") + fixes.each { fix -> changelog.append("- ${formatMultilineMessage(fix)}\n") } + } + + // Store the changelog in a project property or an environment variable + logger.info("Compiled changelog: " + changelog.toString()) + project.ext.changelog = changelog.toString() + } + project.ext.changelog = "" +} + +task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { + dependsOn 'generateChangelog' + + apiToken = System.getenv("CURSEFORGE_TOKEN") + def mainFile = upload(project.curseforge_id, file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) + mainFile.changelogType = 'markdown' + mainFile.changelog = {project.ext.changelog} + mainFile.addModLoader('NeoForge') + mainFile.releaseType = "${release_type}" + "${release_versions}".split(',').each { + mainFile.addGameVersion("${it}") + } + onlyIf { !project.ext.changelog.isEmpty() } +} + task printVersionName { println "version:" + project.version } diff --git a/gradle.properties b/gradle.properties index 18220254..27603428 100644 --- a/gradle.properties +++ b/gradle.properties @@ -34,4 +34,9 @@ chipped_cf_file_id=5506938 resourcefullib_cf_file_id=5483169 athena_cf_file_id=5431579 curios_cf_file_id=5546342 -sc_version=[1.21,1.22) \ No newline at end of file +sc_version=[1.21,1.22) + +#publish +curseforge_id=422301 +release_type=release +release_versions=1.21,1.21.1 \ No newline at end of file From a60c6c98fb5fd93ca6bffe864a39b5dd4d4b9404 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Tue, 17 Sep 2024 16:45:58 +0200 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fixed=20z-fighting=20?= =?UTF-8?q?on=20backpack=20tanks=20when=20player=20crouches=20or=20swims?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../client/render/BackpackModel.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 27603428..380acfa3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ loader_version_range=[4,) mod_id=sophisticatedbackpacks mod_name=Sophisticated Backpacks mod_license=GNU General Public License v3.0 -mod_version=3.20.9 +mod_version=3.20.10 mod_group_id=sophisticatedbackpacks mod_authors=P3pp3rF1y, Ridanisaurus mod_description=Fancy and functional backpacks. diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackModel.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackModel.java index 5f7d501b..32e1cae0 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackModel.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackModel.java @@ -162,15 +162,15 @@ private ModelPart getGlassModelPart() { MeshDefinition meshdefinition = new MeshDefinition(); PartDefinition partDefinition = meshdefinition.getRoot(); partDefinition.addOrReplaceChild(LEFT_TANK_GLASS_PART, CubeListBuilder.create() - .texOffs(18, 5).addBox(-15F, 3.5F, -2.5F, 4.0F, 10.0F, 0.0F) - .texOffs(0, 0).addBox(-15F, 3.5F, -2.5F, 0.0F, 10.0F, 5.0F) - .texOffs(10, 5).addBox(-15F, 3.5F, 2.5F, 4.0F, 10.0F, 0.0F) + .texOffs(18, 5).addBox(-15F, 3.5F, -2.5F, 4.0F, 10.0F, 0.01F) + .texOffs(0, 0).addBox(-15F, 3.5F, -2.5F, 0.01F, 10.0F, 5.0F) + .texOffs(10, 5).addBox(-15F, 3.5F, 2.5F, 4.0F, 10.0F, 0.01F) , PartPose.offset(0.0F, 24.0F, 0.0F) ); partDefinition.addOrReplaceChild(RIGHT_TANK_GLASS_PART, CubeListBuilder.create() - .texOffs(18, 5).addBox(11F, 3.5F, -2.5F, 4.0F, 10.0F, 0.0F, true) - .texOffs(0, 0).addBox(15F, 3.5F, -2.5F, 0.0F, 10.0F, 5.0F, true) - .texOffs(10, 5).addBox(11F, 3.5F, 2.5F, 4.0F, 10.0F, 0.0F, true) + .texOffs(18, 5).addBox(11F, 3.5F, -2.5F, 4.0F, 10.0F, 0.01F, true) + .texOffs(0, 0).addBox(15F, 3.5F, -2.5F, 0.01F, 10.0F, 5.0F, true) + .texOffs(10, 5).addBox(11F, 3.5F, 2.5F, 4.0F, 10.0F, 0.01F, true) , PartPose.offset(0.0F, 24.0F, 0.0F) ); return partDefinition.bake(32, 32); From 69823f0f2af0bc4e2ea18e3a0508a81f08d19eb4 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Tue, 17 Sep 2024 19:11:41 +0200 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fixed=20anvil=20upgra?= =?UTF-8?q?de=20to=20not=20close=20when=20backpack's=20keybind=20key=20is?= =?UTF-8?q?=20pressed=20while=20item=20name=20is=20focused=20(usually=20wh?= =?UTF-8?q?en=20typing=20default=20B=20or=20any=20other=20common=20charact?= =?UTF-8?q?er=20in=20the=20input)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../sophisticatedbackpacks/client/gui/BackpackScreen.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 380acfa3..52340933 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ loader_version_range=[4,) mod_id=sophisticatedbackpacks mod_name=Sophisticated Backpacks mod_license=GNU General Public License v3.0 -mod_version=3.20.10 +mod_version=3.20.11 mod_group_id=sophisticatedbackpacks mod_authors=P3pp3rF1y, Ridanisaurus mod_description=Fancy and functional backpacks. diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java index 1d55bccf..99507845 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/gui/BackpackScreen.java @@ -23,6 +23,9 @@ public BackpackScreen(BackpackContainer screenContainer, Inventory inv, Componen @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (getFocused() != null) { + return super.keyPressed(keyCode, scanCode, modifiers); + } if (keyCode == 256 || KeybindHandler.BACKPACK_OPEN_KEYBIND.isActiveAndMatches(InputConstants.getKey(keyCode, scanCode))) { if (getMenu().isFirstLevelStorage() && (keyCode == 256 || mouseNotOverBackpack())) { if (getMenu().getBackpackContext().wasOpenFromInventory()) {