diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000000..593c7bb0bf --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,29 @@ +name: Build and Pre-release + +on: + pull_request: + types: + - opened + - edited + - synchronize + - labeled + - unlabeled + workflow_dispatch: + +permissions: + contents: read + statuses: write + packages: write + +jobs: + build: + uses: ldtteam/operapublicacreator/.github/workflows/gradle.build.yaml@main + with: + java: 17 + secrets: inherit + pre-release: + uses: ldtteam/operapublicacreator/.github/workflows/gradle.prerelease.yaml@main + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && contains( github.event.pull_request.labels.*.name, 'Pre-release') + with: + java: 17 + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..030b3ef933 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,21 @@ +name: Release + +on: + push: + branches: + - "version/*" + - "release/*" + - "testing/*" + workflow_dispatch: + +permissions: + contents: write + statuses: write + +jobs: + release: + uses: ldtteam/operapublicacreator/.github/workflows/gradle.publish.yaml@main + with: + java: 17 + curse_release_type: ${{ contains(github.ref, 'release') && 'release' || 'beta' }} + secrets: inherit diff --git a/.teamcity/patches/buildTypes/Beta_Release.kts b/.teamcity/patches/buildTypes/Beta_Release.kts deleted file mode 100644 index 6812b67962..0000000000 --- a/.teamcity/patches/buildTypes/Beta_Release.kts +++ /dev/null @@ -1,58 +0,0 @@ -package patches.buildTypes - -import jetbrains.buildServer.configs.kotlin.v2019_2.* -import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.gradle -import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.ScheduleTrigger -import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule -import jetbrains.buildServer.configs.kotlin.v2019_2.ui.* - -/* -This patch script was generated by TeamCity on settings change in UI. -To apply the patch, change the buildType with id = 'Beta_Release' -accordingly, and delete the patch script. -*/ -changeBuildType(RelativeId("Beta_Release")) { - vcs { - - check(branchFilter == "+:*") { - "Unexpected option value: branchFilter = $branchFilter" - } - branchFilter = "+:*" - } - - expectSteps { - gradle { - name = "Compile" - id = "RUNNER_9" - tasks = "build createChangelog curseforge publish" - buildFile = "build.gradle" - enableStacktrace = true - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseText", "%Project.Type%") - param("org.jfrog.artifactory.selectedDeployableServer.publishBuildInfo", "true") - param("org.jfrog.artifactory.selectedDeployableServer.defaultModuleVersionConfiguration", "GLOBAL") - param("org.jfrog.artifactory.selectedDeployableServer.urlId", "2") - param("org.jfrog.artifactory.selectedDeployableServer.envVarsExcludePatterns", "*password*,*secret*") - param("org.jfrog.artifactory.selectedDeployableServer.resolvingRepo", "modding") - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseFlag", "true") - param("org.jfrog.artifactory.selectedDeployableServer.targetRepo", "libraries") - } - } - steps { - check(stepsOrder == arrayListOf("RUNNER_85", "RUNNER_9")) { - "Unexpected build steps order: $stepsOrder" - } - stepsOrder = arrayListOf("RUNNER_9") - } - - triggers { - add { - schedule { - id = "TRIGGER_14" - schedulingPolicy = weekly { - dayOfWeek = ScheduleTrigger.DAY.Saturday - } - triggerBuild = always() - } - } - } -} diff --git a/.teamcity/pom.xml b/.teamcity/pom.xml deleted file mode 100644 index 8d8963874f..0000000000 --- a/.teamcity/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - 4.0.0 - LetSDevTogether_Structurize Config DSL Script - LetSDevTogether_Structurize - LetSDevTogether_Structurize_dsl - 1.0-SNAPSHOT - - - org.jetbrains.teamcity - configs-dsl-kotlin-parent - 1.0-SNAPSHOT - - - - - jetbrains-all - https://download.jetbrains.com/teamcity-repository - - true - - - - teamcity-server - https://buildsystem.ldtteam.com/app/dsl-plugins-repository - - true - - - - - - - JetBrains - https://download.jetbrains.com/teamcity-repository - - - - - ${basedir} - - - kotlin-maven-plugin - org.jetbrains.kotlin - ${kotlin.version} - - - - - compile - process-sources - - compile - - - - test-compile - process-test-sources - - test-compile - - - - - - org.jetbrains.teamcity - teamcity-configs-maven-plugin - ${teamcity.dsl.version} - - kotlin - target/generated-configs - - - - - - - - org.jetbrains.teamcity - configs-dsl-kotlin - ${teamcity.dsl.version} - compile - - - org.jetbrains.teamcity - configs-dsl-kotlin-plugins - 1.0-SNAPSHOT - pom - compile - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - compile - - - org.jetbrains.kotlin - kotlin-script-runtime - ${kotlin.version} - compile - - - \ No newline at end of file diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts deleted file mode 100644 index 078b55ce57..0000000000 --- a/.teamcity/settings.kts +++ /dev/null @@ -1,379 +0,0 @@ -import jetbrains.buildServer.configs.kotlin.v2019_2.* -import jetbrains.buildServer.configs.kotlin.v2019_2.buildFeatures.commitStatusPublisher -import jetbrains.buildServer.configs.kotlin.v2019_2.buildFeatures.vcsLabeling -import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.GradleBuildStep -import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.gradle -import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.githubIssues -import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule -import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.vcs - -/* -The settings script is an entry point for defining a TeamCity -project hierarchy. The script should contain a single call to the -project() function with a Project instance or an init function as -an argument. - -VcsRoots, BuildTypes, Templates, and subprojects can be -registered inside the project using the vcsRoot(), buildType(), -template(), and subProject() methods respectively. - -To debug settings scripts in command-line, run the - - mvnDebug org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate - -command and attach your debugger to the port 8000. - -To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View --> Tool Windows -> Maven Projects), find the generate task node -(Plugins -> teamcity-configs -> teamcity-configs:generate), the -'Debug' option is available in the context menu for the task. -*/ - -version = "2021.2" - -project { - description = "The Structurize Minecraft Mod" - - params { - param("env.JDK_VERSION", "jdk17") - param("Project.Type", "mods") - param("env.Version.Patch", "0") - param("env.Version.Suffix", "") - param("env.Version.Major", "1") - text("env.Version", "%env.Version.Major%.%env.Version.Minor%.%env.Version.Patch%%env.Version.Suffix%", label = "Version", description = "The version of the project.", display = ParameterDisplay.HIDDEN, allowEmpty = true) - param("Current Minecraft Version", "main") - text("Repository", "ldtteam/structurize", label = "Repository", description = "The repository for structurize.", readOnly = true, allowEmpty = true) - param("env.Version.Minor", "0") - param("Upsource.Project.Id", "structurize") - param("Default.Branch", "version/main") - param("env.GRADLE_VERSION", "7.3") - param("filename.prefix", "structurize") - } - - features { - githubIssues { - id = "PROJECT_EXT_22" - displayName = "ldtteam/structurize" - repositoryURL = "https://github.com/ldtteam/structurize" - authType = accessToken { - accessToken = "credentialsJSON:47381468-aceb-4992-93c9-1ccd4d7aa67f" - } - } - } - subProjectsOrder = arrayListOf(RelativeId("Release"), RelativeId("UpgradeBetaRelease"), RelativeId("Beta"), RelativeId("OfficialPublications"), RelativeId("Branches"), RelativeId("PullRequests_2")) - - subProject(Release) - subProject(UpgradeBetaRelease) - subProject(Beta) - subProject(OfficialPublications) - subProject(Branches) - subProject(PullRequests_2) -} - -object Beta : Project({ - name = "Beta" - description = "Beta version builds of structurize" - - buildType(Beta_Release) - - params { - text("env.crowdinKey", "credentialsJSON:57fbe4f4-13dd-4c72-b6b3-3cc1e3a8240e", label = "Crowdin key", description = "The API key for crowdin to pull translations", allowEmpty = true) - param("Current Minecraft Version", "main") - param("env.GRADLE_VERSION", "7.3") - param("Default.Branch", "version/%Current Minecraft Version%") - param("VCS.Branches", "+:refs/heads/version/(*)") - param("env.CURSERELEASETYPE", "beta") - param("env.Version.Suffix", "-BETA") - } -}) - -object Beta_Release : BuildType({ - templates(AbsoluteId("LetSDevTogether_BuildWithRelease")) - name = "Release" - description = "Releases the mod as Beta to CurseForge" - - allowExternalStatus = true - - params { - param("env.Version.Patch", "${OfficialPublications_CommonB.depParamRefs.buildNumber}") - } - - steps { - gradle { - name = "Compile" - id = "RUNNER_9" - tasks = "build createChangelog curseforge publish" - buildFile = "build.gradle" - enableStacktrace = true - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseText", "%Project.Type%") - param("org.jfrog.artifactory.selectedDeployableServer.publishBuildInfo", "true") - param("org.jfrog.artifactory.selectedDeployableServer.defaultModuleVersionConfiguration", "GLOBAL") - param("org.jfrog.artifactory.selectedDeployableServer.urlId", "2") - param("org.jfrog.artifactory.selectedDeployableServer.envVarsExcludePatterns", "*password*,*secret*") - param("org.jfrog.artifactory.selectedDeployableServer.resolvingRepo", "modding") - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseFlag", "true") - param("org.jfrog.artifactory.selectedDeployableServer.targetRepo", "libraries") - } - stepsOrder = arrayListOf("RUNNER_85", "RUNNER_9") - } - - features { - vcsLabeling { - id = "BUILD_EXT_11" - vcsRootId = "${DslContext.settingsRoot.id}" - labelingPattern = "%env.Version%" - successfulOnly = true - branchFilter = "" - } - commitStatusPublisher { - id = "BUILD_EXT_15" - enabled = false - vcsRootExtId = "${DslContext.settingsRoot.id}" - publisher = upsource { - serverUrl = "https://code-analysis.ldtteam.com" - projectId = "%Upsource.Project.Id%" - userName = "upsource" - password = "credentialsJSON:f19631a7-1bc1-4a66-88a0-dc2b9cd36734" - } - } - } - - dependencies { - snapshot(OfficialPublications_CommonB) { - reuseBuilds = ReuseBuilds.NO - onDependencyFailure = FailureAction.FAIL_TO_START - } - } -}) - -object Release : Project({ - name = "Release" - description = "Release version builds of structurize" - - buildType(Release_Release) - - params { - text("env.crowdinKey", "credentialsJSON:57fbe4f4-13dd-4c72-b6b3-3cc1e3a8240e", label = "Crowdin key", description = "The API key for crowdin to pull translations", allowEmpty = true) - param("Default.Branch", "version/%Current Minecraft Version%") - param("VCS.Branches", "+:refs/heads/release/(*)") - param("env.CURSERELEASETYPE", "release") - param("env.Version.Suffix", "-RELEASE") - } -}) - -object Release_Release : BuildType({ - templates(AbsoluteId("LetSDevTogether_BuildWithRelease")) - name = "Release" - description = "Releases the mod as Release to CurseForge" - - allowExternalStatus = true - - params { - param("env.Version.Patch", "${OfficialPublications_CommonB.depParamRefs.buildNumber}") - } - - steps { - gradle { - name = "Compile" - id = "RUNNER_9" - tasks = "build createChangelog curseforge publish" - buildFile = "build.gradle" - enableStacktrace = true - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseText", "%Project.Type%") - param("org.jfrog.artifactory.selectedDeployableServer.publishBuildInfo", "true") - param("org.jfrog.artifactory.selectedDeployableServer.defaultModuleVersionConfiguration", "GLOBAL") - param("org.jfrog.artifactory.selectedDeployableServer.urlId", "2") - param("org.jfrog.artifactory.selectedDeployableServer.envVarsExcludePatterns", "*password*,*secret*") - param("org.jfrog.artifactory.selectedDeployableServer.resolvingRepo", "modding") - param("org.jfrog.artifactory.selectedDeployableServer.deployReleaseFlag", "true") - param("org.jfrog.artifactory.selectedDeployableServer.targetRepo", "libraries") - } - stepsOrder = arrayListOf("RUNNER_85", "RUNNER_9") - } - - features { - vcsLabeling { - id = "BUILD_EXT_11" - vcsRootId = "${DslContext.settingsRoot.id}" - labelingPattern = "%env.Version%" - successfulOnly = true - branchFilter = "" - } - commitStatusPublisher { - id = "BUILD_EXT_15" - enabled = false - vcsRootExtId = "${DslContext.settingsRoot.id}" - publisher = upsource { - serverUrl = "https://code-analysis.ldtteam.com" - projectId = "%Upsource.Project.Id%" - userName = "upsource" - password = "credentialsJSON:f19631a7-1bc1-4a66-88a0-dc2b9cd36734" - } - } - } - - dependencies { - snapshot(OfficialPublications_CommonB) { - reuseBuilds = ReuseBuilds.NO - onDependencyFailure = FailureAction.FAIL_TO_START - } - } -}) - -object Branches : Project({ - name = "Branches" - description = "All none release branches." - - buildType(Branches_Common) - buildType(Branches_Build) - - params { - text("Default.Branch", "version/%Current Minecraft Version%", label = "Default branch", description = "The default branch for branch builds", allowEmpty = true) - param("VCS.Branches", """ - +:refs/heads/(*) - -:refs/heads/version/* - -:refs/heads/release/* - -:refs/pull/*/head - -:refs/heads/CI/* - """.trimIndent()) - param("env.Version.Suffix", "-PERSONAL") - } - - cleanup { - baseRule { - all(days = 60) - } - } -}) - -object Branches_Build : BuildType({ - templates(AbsoluteId("LetSDevTogether_Build")) - name = "Build" - description = "Builds the branch without testing." - - params { - param("Project.Type", "mods") - param("env.Version.Patch", "${Branches_Common.depParamRefs.buildNumber}") - } - - triggers { - vcs { - id = "vcsTrigger" - } - } - - dependencies { - snapshot(Branches_Common) { - reuseBuilds = ReuseBuilds.NO - onDependencyFailure = FailureAction.FAIL_TO_START - } - } - - disableSettings("BUILD_EXT_14") -}) - -object Branches_Common : BuildType({ - templates(AbsoluteId("LetSDevTogether_CommonBuildCounter")) - name = "Common Build Counter" - description = "Tracks the amount of builds run for branches" -}) - - -object OfficialPublications : Project({ - name = "Official Publications" - description = "Holds projects and builds related to official publications" - - buildType(OfficialPublications_CommonB) -}) - -object OfficialPublications_CommonB : BuildType({ - templates(AbsoluteId("LetSDevTogether_CommonBuildCounter")) - name = "Common Build Counter" - description = "Represents the version counter within Structurize for official releases." -}) - - -object PullRequests_2 : Project({ - name = "Pull Requests" - description = "All open pull requests" - - buildType(PullRequests_2_BuildAndTest) - buildType(PullRequests_2_CommonBuildCounter) - - params { - text("Default.Branch", "version/%Current Minecraft Version%", label = "Default branch", description = "The default branch for pull requests.", allowEmpty = false) - param("VCS.Branches", """ - -:refs/heads/* - +:refs/pull/(*)/head - -:refs/heads/(CI/*) - """.trimIndent()) - param("env.Version", "%env.Version.Major%.%env.Version.Minor%.%build.counter%-PR") - } - - cleanup { - baseRule { - all(days = 60) - } - } -}) - -object PullRequests_2_BuildAndTest : BuildType({ - templates(AbsoluteId("LetSDevTogether_BuildWithTesting")) - name = "Build and Test" - description = "Builds and Tests the pull request." - - artifactRules = """ - +:build\libs\*.jar => build\libs - +:build\distributions\mods-*.zip => build\distributions - """.trimIndent() - - params { - param("env.Version.Patch", "${PullRequests_2_CommonBuildCounter.depParamRefs.buildNumber}") - param("env.Version.Suffix", "-PR") - } - - features { - feature { - id = "com.ldtteam.teamcity.github.commenting.GithubCommentingBuildFeature" - type = "com.ldtteam.teamcity.github.commenting.GithubCommentingBuildFeature" - param("privateKey", "-----") - param("appId", "154983") - param("branch", "%teamcity.build.branch%") - } - } - - dependencies { - snapshot(PullRequests_2_CommonBuildCounter) { - onDependencyFailure = FailureAction.FAIL_TO_START - } - } - - disableSettings("BUILD_EXT_15") -}) - -object PullRequests_2_CommonBuildCounter : BuildType({ - templates(AbsoluteId("LetSDevTogether_CommonBuildCounter")) - name = "Common Build Counter" - description = "Defines version numbers uniquely over all Pull Request builds" -}) - -object UpgradeBetaRelease : Project({ - name = "Upgrade Beta -> Release" - description = "Upgrades the current Beta to Release" - - buildType(UpgradeBetaRelease_UpgradeBetaRelease) -}) - -object UpgradeBetaRelease_UpgradeBetaRelease : BuildType({ - templates(AbsoluteId("LetSDevTogether_Upgrade")) - name = "Upgrade Beta -> Release" - description = "Upgrades the current Beta to Release." - - params { - param("Source.Branch", "version") - param("Default.Branch", "release/%Current Minecraft Version%") - param("VCS.Branches", "+:refs/heads/release/(*)") - param("Target.Branch", "release") - param("env.Version", "%env.Version.Major%.%env.Version.Minor%.%build.counter%-RELEASE") - } -}) diff --git a/README.md b/README.md index 69ec0b814f..aee0f8bf86 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ +[![Structurize CurseForge](https://img.shields.io/curseforge/dt/298744?logo=curseforge&color=F16436&label=Structurize)](https://www.curseforge.com/minecraft/mc-mods/structurize) +[![Release 1.20.1](https://img.shields.io/github/actions/workflow/status/ldtteam/minecolonies/release.yml?branch=version%2Fmain&label=Build%201.20.1&event=push)](https://github.com/ldtteam/Structurize/actions/workflows/release.yml?query=branch%3Aversion%2Fmain+event%3Apush) +[![Release 1.21.1](https://img.shields.io/github/actions/workflow/status/ldtteam/minecolonies/release.yml?branch=version%2F1.21&label=Build%201.21.1&event=push)](https://github.com/ldtteam/Structurize/actions/workflows/release.yml?query=branch%3Aversion%2F1.21+event%3Apush) [![CLA assistant](https://cla-assistant.io/readme/badge/ldtteam/structurize)](https://cla-assistant.io/ldtteam/structurize) -[![Build Status](https://buildsystem.ldtteam.com/app/rest/builds/buildType:LetSDevTogether_Structurize_Alpha_Release/statusIcon)](http://buildsystem.ldtteam.com/) [![Crowdin](https://badges.crowdin.net/structurize/localized.svg)](https://crowdin.com/project/structurize) ![structurize logo](structurize.png) diff --git a/build.gradle b/build.gradle index 9f6103d493..265b102c01 100644 --- a/build.gradle +++ b/build.gradle @@ -1,29 +1 @@ -buildscript { - repositories { - maven { url = 'https://files.minecraftforge.net/maven' } - mavenLocal() - mavenCentral() - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.0+', changing: true - classpath "gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0" - classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.4.0" - classpath 'de.undercouch:gradle-download-task:4.1.2' - } -} - apply from: 'https://raw.githubusercontent.com/ldtteam/OperaPublicaCreator/main/gradle/mod.gradle' - -configurations { - library - implementation.extendsFrom library -} - -minecraft.runs.all { - lazyToken('minecraft_classpath') { - configurations.library.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) - } -} diff --git a/gradle.properties b/gradle.properties index 203b063574..98ac429c6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,10 +27,10 @@ additionalMinecraftVersions= mappingsChannel=official mappingsVersion=1.20.1 -blockUiVersion=1.20.1-0.0.98-ALPHA +blockUiVersion=1.20.1-1.0.156-RELEASE blockUiRange=[1.20.1-0.0.98-ALPHA,) -domumOrnamentumVersion=1.20-1.0.159-BETA +domumOrnamentumVersion=1.20.1-1.0.199-BETA domumOrnamentumRange=[1.20-1.0.93-ALPHA,) githubUrl=https://github.com/ldtteam/Structurize diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 49a196baa1..02d71ca160 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -1,12 +1,3 @@ -repositories { - maven { url = 'https://files.minecraftforge.net/maven' } - mavenLocal() - mavenCentral() - maven { - url "https://plugins.gradle.org/m2/" - } -} - dependencies { apiImplementation fg.deobf("com.ldtteam:blockui:${project.blockUiVersion}") implementation fg.deobf("com.ldtteam:blockui:${project.blockUiVersion}") diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa7..2c3521197d 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 37aef8d3f0..09523c0e54 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cbb43..f5feea6d6b 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # 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 +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -83,7 +85,9 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +134,13 @@ 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. + if ! command -v java >/dev/null 2>&1 + then + 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 fi # Increase the maximum file descriptors if we can. @@ -141,7 +148,7 @@ 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 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +205,11 @@ fi # 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"' -# 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. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f13..9d21a21834 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ 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. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/src/main/java/com/ldtteam/structurize/client/BlueprintHandler.java b/src/main/java/com/ldtteam/structurize/client/BlueprintHandler.java index fdfc692562..0b7787072c 100644 --- a/src/main/java/com/ldtteam/structurize/client/BlueprintHandler.java +++ b/src/main/java/com/ldtteam/structurize/client/BlueprintHandler.java @@ -7,6 +7,7 @@ import com.ldtteam.structurize.storage.rendering.types.BlueprintPreviewData; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.client.event.RenderLevelStageEvent; import java.util.List; @@ -70,6 +71,20 @@ public static BlueprintHandler getInstance() * @param ctx rendering event */ public void draw(final BlueprintPreviewData previewData, final BlockPos pos, final RenderLevelStageEvent ctx) + { + final Vec3 viewPosition = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); + ctx.getPoseStack().pushPose(); + ctx.getPoseStack().translate(viewPosition.x(), viewPosition.y(), viewPosition.z()); + + internalBackportDraw(previewData, pos, ctx); + + ctx.getPoseStack().popPose(); + } + + /** + * DO NOT USE IN MCOL + */ + public void internalBackportDraw(final BlueprintPreviewData previewData, final BlockPos pos, final RenderLevelStageEvent ctx) { if (previewData == null || previewData.getBlueprint() == null) { @@ -119,10 +134,14 @@ public void drawAtListOfPositions(final BlueprintPreviewData previewData, final BlueprintRenderer renderer = rendererCache.getUnchecked(previewData.getRenderKey()); + final Vec3 viewPosition = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); + ctx.getPoseStack().pushPose(); + ctx.getPoseStack().translate(viewPosition.x(), viewPosition.y(), viewPosition.z()); for (final BlockPos coord : points) { renderer.draw(previewData, coord, ctx); } + ctx.getPoseStack().popPose(); Minecraft.getInstance().getProfiler().pop(); } diff --git a/src/main/java/com/ldtteam/structurize/client/BlueprintRenderer.java b/src/main/java/com/ldtteam/structurize/client/BlueprintRenderer.java index b896fa55f8..42d8c13267 100644 --- a/src/main/java/com/ldtteam/structurize/client/BlueprintRenderer.java +++ b/src/main/java/com/ldtteam/structurize/client/BlueprintRenderer.java @@ -304,6 +304,8 @@ public Map drawUnsafe(final BlueprintPreviewData previewData, final long gameTime = mc.level.getGameTime(); final PoseStack matrixStack = ctx.getPoseStack(); final float partialTicks = ctx.getPartialTick(); + final Matrix4f mvMatrix = matrixStack.last().pose(); + final Matrix4f pMatrix = ctx.getProjectionMatrix(); mc.getProfiler().push("struct_render_init"); @@ -345,12 +347,7 @@ public Map drawUnsafe(final BlueprintPreviewData previewData, // missing chunk system! else done? - matrixStack.pushPose(); - // move back to camera, everything must go into offsets cuz fog - matrixStack.translate(viewPosition.x(), viewPosition.y(), viewPosition.z()); - final Matrix4f mvMatrix = matrixStack.last().pose(); Lighting.setupLevel(mvMatrix); - final int lightTexture = LightTexture.pack(RenderingCache.getOurLightLevel(), RenderingCache.getOurLightLevel()); // Render blocks @@ -365,12 +362,12 @@ public Map drawUnsafe(final BlueprintPreviewData previewData, } mc.getProfiler().popPush("struct_render_blocks"); - renderBlockLayer(RenderType.solid(), mvMatrix, realRenderRootVecf, previewData); + renderBlockLayer(RenderType.solid(), mvMatrix, pMatrix, realRenderRootVecf, previewData); // FORGE: fix flickering leaves when mods mess up the blurMipmap settings mc.getModelManager().getAtlas(InventoryMenu.BLOCK_ATLAS).setBlurMipmap(false, mc.options.mipmapLevels().get() > 0); - renderBlockLayer(RenderType.cutoutMipped(), mvMatrix, realRenderRootVecf, previewData); + renderBlockLayer(RenderType.cutoutMipped(), mvMatrix, pMatrix, realRenderRootVecf, previewData); mc.getModelManager().getAtlas(InventoryMenu.BLOCK_ATLAS).restoreLastBlurMipmap(); - renderBlockLayer(RenderType.cutout(), mvMatrix, realRenderRootVecf, previewData); + renderBlockLayer(RenderType.cutout(), mvMatrix, pMatrix, realRenderRootVecf, previewData); mc.getProfiler().popPush("struct_render_entities"); final MultiBufferSource.BufferSource renderBufferSource = renderBuffers.bufferSource(); @@ -416,7 +413,7 @@ public Map drawUnsafe(final BlueprintPreviewData previewData, partialTicks, matrixStack, renderBufferSource, - lightTexture); + mc.getEntityRenderDispatcher().getPackedLightCoords(entity, partialTicks)); } catch (final ClassCastException e) { @@ -525,13 +522,11 @@ else if (tileEntity instanceof final BeaconBlockEntity beacon) renderBuffers.crumblingBufferSource().endBatch(); // not used now mc.getProfiler().popPush("struct_render_blocks2"); - renderBlockLayer(RenderType.translucent(), mvMatrix, realRenderRootVecf, previewData); + renderBlockLayer(RenderType.translucent(), mvMatrix, pMatrix, realRenderRootVecf, previewData); renderBufferSource.endBatch(RenderType.lines()); renderBufferSource.endBatch(); - renderBlockLayer(RenderType.tripwire(), mvMatrix, realRenderRootVecf, previewData); - - matrixStack.popPose(); + renderBlockLayer(RenderType.tripwire(), mvMatrix, pMatrix, realRenderRootVecf, previewData); RenderSystem.applyModelViewMatrix(); // ensure no polution Lighting.setupLevel(matrixStack.last().pose()); @@ -568,7 +563,7 @@ public void close() clearVertexBuffers(); } - private void renderBlockLayer(final RenderType layerRenderType, final Matrix4f mvMatrix, final Vector3f realRenderRootPos, final BlueprintPreviewData previewData) + private void renderBlockLayer(final RenderType layerRenderType, final Matrix4f mvMatrix, final Matrix4f pMatrix, final Vector3f realRenderRootPos, final BlueprintPreviewData previewData) { final VertexBuffer vertexBuffer = vertexBuffers.get(layerRenderType); if (vertexBuffer == null) @@ -592,7 +587,7 @@ private void renderBlockLayer(final RenderType layerRenderType, final Matrix4f m if (shaderinstance.PROJECTION_MATRIX != null) { - shaderinstance.PROJECTION_MATRIX.set(RenderSystem.getProjectionMatrix()); + shaderinstance.PROJECTION_MATRIX.set(pMatrix); } if (shaderinstance.COLOR_MODULATOR != null) diff --git a/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevel.java b/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevel.java index c76a2bdb3d..61e967c875 100644 --- a/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevel.java +++ b/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevel.java @@ -90,6 +90,7 @@ public class FakeLevel extends Level protected final boolean overrideBeLevel; protected final FakeChunkSource chunkSource; + protected final FakeLevelLightEngine lightEngine; protected FakeLevelEntityGetterAdapter levelEntityGetter = FakeLevelEntityGetterAdapter.EMPTY; // TODO: this is currently manually filled by class user - ideally if not filled yet this should get constructed from levelSource manually protected Map blockEntities = Collections.emptyMap(); @@ -124,6 +125,7 @@ public FakeLevel(final IFakeLevelBlockGetter levelSource, final IFakeLevelLightP this.scoreboard = scoreboard == null ? clientLevel().getScoreboard() : scoreboard; this.overrideBeLevel = overrideBeLevel; this.chunkSource = new FakeChunkSource(this); + this.lightEngine = new FakeLevelLightEngine(this); } // ======================================== @@ -345,6 +347,12 @@ public ChunkSource getChunkSource() return chunkSource; } + @Override + public LevelLightEngine getLightEngine() + { + return lightEngine; + } + @Override public String gatherChunkSourceStats() { @@ -403,13 +411,6 @@ public Holder getNoiseBiome(int x, int y, int z) // ======= NOOP UNSAFE NULL METHODS ======= // ======================================== - @Override - public LevelLightEngine getLightEngine() - { - // TODO: noop - throw new UnsupportedOperationException("Structurize fake level - if you really need light engine please make issue on our GitHub"); - } - @Override public Explosion explode(@javax.annotation.Nullable Entity p_256233_, @javax.annotation.Nullable DamageSource p_255861_, diff --git a/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevelLightEngine.java b/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevelLightEngine.java new file mode 100644 index 0000000000..3fa7ec330c --- /dev/null +++ b/src/main/java/com/ldtteam/structurize/client/fakelevel/FakeLevelLightEngine.java @@ -0,0 +1,233 @@ +package com.ldtteam.structurize.client.fakelevel; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.chunk.DataLayer; +import net.minecraft.world.level.chunk.LightChunk; +import net.minecraft.world.level.chunk.LightChunkGetter; +import net.minecraft.world.level.lighting.LayerLightEventListener; +import net.minecraft.world.level.lighting.LayerLightSectionStorage.SectionType; +import net.minecraft.world.level.lighting.LevelLightEngine; +import javax.annotation.Nullable; + +/** + * Porting: class is relatively small, just check super class manually (all of missing methods are/were just aliases) + */ +public class FakeLevelLightEngine extends LevelLightEngine +{ + private final FakeLevel fakeLevel; + private FakeLevelLayerLightEventListener blockLightLayer = null; + private FakeLevelLayerLightEventListener skyLightLayer = null; + + public FakeLevelLightEngine(final FakeLevel level) + { + super(new LightChunkGetter() + { + @Override + public LightChunk getChunkForLighting(final int p_63023_, final int p_63024_) + { + throw new UnsupportedOperationException("Should never happen - FakeLevel light engine ctor"); + } + + @Override + public BlockGetter getLevel() + { + return level; + } + }, false, false); + + this.fakeLevel = level; + } + + @Override + public int getRawBrightness(final BlockPos p_75832_, final int p_75833_) + { + return fakeLevel.getRawBrightness(p_75832_, p_75833_); + } + + @Override + public String getDebugData(final LightLayer p_75817_, final SectionPos p_75818_) + { + return "FakeLevel light engine redirect - " + p_75817_; + } + + @Override + public LayerLightEventListener getLayerListener(final LightLayer p_75815_) + { + return switch (p_75815_) + { + case BLOCK -> { + if (blockLightLayer == null) + { + blockLightLayer = new FakeLevelLayerLightEventListener(p_75815_); + } + yield blockLightLayer; + } + case SKY -> { + if (skyLightLayer == null) + { + skyLightLayer = new FakeLevelLayerLightEventListener(p_75815_); + } + yield skyLightLayer; + } + }; + } + + @Override + public SectionType getDebugSectionType(final LightLayer p_285008_, final SectionPos p_285336_) + { + // Noop, only debug rendering ? + return SectionType.EMPTY; + } + + @Override + public boolean lightOnInSection(final SectionPos p_285319_) + { + // Noop, used only in chunk compiling? + return false; + } + + @Override + public void checkBlock(final BlockPos p_75823_) + { + // Noop + } + + @Override + public boolean hasLightWork() + { + // Noop + return false; + } + + @Override + public void propagateLightSources(final ChunkPos p_284998_) + { + // Noop + } + + @Override + public void queueSectionData(final LightLayer p_285328_, final SectionPos p_284962_, final DataLayer p_285035_) + { + // Noop + } + + @Override + public void retainData(final ChunkPos p_75829_, final boolean p_75830_) + { + // Noop + } + + @Override + public int runLightUpdates() + { + // Noop + return 0; + } + + @Override + public void setLightEnabled(final ChunkPos p_285439_, final boolean p_285012_) + { + // Noop + } + + @Override + public void updateSectionStatus(final SectionPos p_75827_, final boolean p_75828_) + { + // Noop + } + + @Override + public void updateSectionStatus(final BlockPos p_75835_, final boolean p_75836_) + { + // Noop + } + + /* + @Override + public int getLightSectionCount() + { + // super is fine + return super.getLightSectionCount(); + } + + @Override + public int getMaxLightSection() + { + // super is fine + return super.getMaxLightSection(); + } + + @Override + public int getMinLightSection() + { + // super is fine + return super.getMinLightSection(); + } + */ + + private class FakeLevelLayerLightEventListener implements LayerLightEventListener + { + private final LightLayer lightLayer; + + private FakeLevelLayerLightEventListener(final LightLayer lightLayer) + { + this.lightLayer = lightLayer; + } + + @Override + public void checkBlock(final BlockPos p_164454_) + { + // Noop + } + + @Override + public boolean hasLightWork() + { + // Noop + return false; + } + + @Override + public int runLightUpdates() + { + // Noop + return 0; + } + + @Override + public void updateSectionStatus(final SectionPos p_75837_, final boolean p_75838_) + { + // Noop + } + + @Override + public void setLightEnabled(final ChunkPos p_164452_, final boolean p_164453_) + { + // Noop + } + + @Override + public void propagateLightSources(final ChunkPos p_285263_) + { + // Noop + } + + @Override + @Nullable + public DataLayer getDataLayerData(final SectionPos p_75709_) + { + // Noop + return null; + } + + @Override + public int getLightValue(final BlockPos p_75710_) + { + return fakeLevel.getBrightness(lightLayer, p_75710_); + } + } +} diff --git a/src/main/java/com/ldtteam/structurize/event/ClientEventSubscriber.java b/src/main/java/com/ldtteam/structurize/event/ClientEventSubscriber.java index a7fd7a99d5..c1bcbf97e0 100644 --- a/src/main/java/com/ldtteam/structurize/event/ClientEventSubscriber.java +++ b/src/main/java/com/ldtteam/structurize/event/ClientEventSubscriber.java @@ -68,22 +68,37 @@ public static void renderWorldLastEvent(final RenderGuiOverlayEvent.Pre event) @SubscribeEvent public static void renderWorldLastEvent(final RenderLevelStageEvent event) { - final Stage when = Structurize.getConfig().getClient().rendererTransparency.get() > TransparencyHack.THRESHOLD ? - Stage.AFTER_CUTOUT_MIPPED_BLOCKS_BLOCKS : - Stage.AFTER_TRANSLUCENT_BLOCKS; // otherwise even worse sorting issues arise - if (event.getStage() != when) - { - return; - } + final double alpha = Structurize.getConfig().getClient().rendererTransparency.get(); + final boolean isAlphaApplied = alpha > 0 && alpha < TransparencyHack.THRESHOLD; final PoseStack matrixStack = event.getPoseStack(); final MultiBufferSource.BufferSource bufferSource = WorldRenderMacros.getBufferSource(); final Minecraft mc = Minecraft.getInstance(); final Vec3 viewPosition = mc.gameRenderer.getMainCamera().getPosition(); - matrixStack.pushPose(); - matrixStack.translate(-viewPosition.x(), -viewPosition.y(), -viewPosition.z()); + final Stage when = isAlphaApplied ? Stage.AFTER_TRANSLUCENT_BLOCKS : Stage.AFTER_BLOCK_ENTITIES; + // otherwise even worse sorting issues arise + if (event.getStage() == when) + { + renderBlueprints(event, mc, matrixStack, bufferSource, viewPosition); + } + + if (event.getStage() == Stage.AFTER_BLOCK_ENTITIES) + { + renderBoxes(mc, matrixStack, bufferSource, viewPosition); + renderTagTool(mc, matrixStack, bufferSource, viewPosition); + } + + bufferSource.endBatch(); + } + + private static void renderBlueprints(final RenderLevelStageEvent event, + final Minecraft mc, + final PoseStack matrixStack, + final MultiBufferSource.BufferSource bufferSource, + final Vec3 viewPosition) + { for (final BlueprintPreviewData previewData : RenderingCache.getBlueprintsToRender()) { final Blueprint blueprint = previewData.getBlueprint(); @@ -93,32 +108,61 @@ public static void renderWorldLastEvent(final RenderLevelStageEvent event) mc.getProfiler().push("struct_render"); final BlockPos pos = previewData.getPos(); - final BlockPos posMinusOffset = pos.subtract(blueprint.getPrimaryBlockOffset()); + final Vec3 realRenderRootVecd = Vec3.atLowerCornerOf(pos.subtract(blueprint.getPrimaryBlockOffset())).subtract(viewPosition); + + BlueprintHandler.getInstance().internalBackportDraw(previewData, pos, event); + + matrixStack.pushPose(); + matrixStack.translate(realRenderRootVecd.x(), realRenderRootVecd.y(), realRenderRootVecd.z()); - BlueprintHandler.getInstance().draw(previewData, pos, event); WorldRenderMacros.renderWhiteLineBox(bufferSource, - matrixStack, - posMinusOffset, - posMinusOffset.offset(blueprint.getSizeX() - 1, blueprint.getSizeY() - 1, blueprint.getSizeZ() - 1), - 0.02f); - WorldRenderMacros.renderRedGlintLineBox(bufferSource, matrixStack, pos, pos, 0.02f); + matrixStack, + BlockPos.ZERO, + new BlockPos(blueprint.getSizeX() - 1, blueprint.getSizeY() - 1, blueprint.getSizeZ() - 1), + 0.025f); + WorldRenderMacros.renderRedGlintLineBox(bufferSource, + matrixStack, + blueprint.getPrimaryBlockOffset(), + blueprint.getPrimaryBlockOffset(), + 0.025f); + + matrixStack.popPose(); mc.getProfiler().pop(); } } + } + private static void renderBoxes(final Minecraft mc, + final PoseStack matrixStack, + final MultiBufferSource.BufferSource bufferSource, + final Vec3 viewPosition) + { for (final BoxPreviewData previewData : RenderingCache.getBoxesToRender()) { mc.getProfiler().push("struct_box"); + final BlockPos root = previewData.getPos1(); + final Vec3 realRenderRootVecd = Vec3.atLowerCornerOf(root).subtract(viewPosition); + + matrixStack.pushPose(); + matrixStack.translate(realRenderRootVecd.x(), realRenderRootVecd.y(), realRenderRootVecd.z()); + // Used to render a red box around a scan's Primary offset (primary block) - WorldRenderMacros.renderWhiteLineBox(bufferSource, matrixStack, previewData.getPos1(), previewData.getPos2(), 0.02f); - previewData.getAnchor().ifPresent(pos -> WorldRenderMacros.renderRedGlintLineBox(bufferSource, matrixStack, pos, pos, 0.02f)); + WorldRenderMacros.renderWhiteLineBox(bufferSource, matrixStack, BlockPos.ZERO, previewData.getPos2().subtract(root), 0.025f); + previewData.getAnchor().map(pos -> pos.subtract(root)).ifPresent(pos -> WorldRenderMacros.renderRedGlintLineBox(bufferSource, matrixStack, pos, pos, 0.025f)); + + matrixStack.popPose(); mc.getProfiler().pop(); } + } - + private static void renderTagTool(final Minecraft mc, + final PoseStack matrixStack, + final MultiBufferSource.BufferSource bufferSource, + final Vec3 viewPosition) + { final Player player = mc.player; final ItemStack itemStack = player.getItemInHand(InteractionHand.MAIN_HAND); if (itemStack.getItem() == ModItems.tagTool.get() && itemStack.getOrCreateTag().contains(ItemTagTool.TAG_ANCHOR_POS)) @@ -126,25 +170,29 @@ public static void renderWorldLastEvent(final RenderLevelStageEvent event) mc.getProfiler().push("struct_tags"); final BlockPos tagAnchor = BlockPosUtil.readFromNBT(itemStack.getTag(), ItemTagTool.TAG_ANCHOR_POS); + final Vec3 realRenderRootVecd = Vec3.atLowerCornerOf(tagAnchor).subtract(viewPosition); final BlockEntity te = player.level().getBlockEntity(tagAnchor); - if (te instanceof IBlueprintDataProviderBE) + matrixStack.pushPose(); + matrixStack.translate(realRenderRootVecd.x(), realRenderRootVecd.y(), realRenderRootVecd.z()); + + if (te instanceof final IBlueprintDataProviderBE blueprintProvider) { - final Map> tagPosList = ((IBlueprintDataProviderBE) te).getWorldTagPosMap(); + final Map> tagPosList = blueprintProvider.getWorldTagPosMap(); for (final Map.Entry> entry : tagPosList.entrySet()) { - WorldRenderMacros.renderWhiteLineBox(bufferSource, matrixStack, entry.getKey(), entry.getKey(), 0.02f); - WorldRenderMacros.renderDebugText(entry.getKey(), entry.getValue(), matrixStack, true, 3, bufferSource); + final BlockPos pos = entry.getKey().subtract(tagAnchor); + WorldRenderMacros.renderWhiteLineBox(bufferSource, matrixStack, pos, pos, 0.025f); + WorldRenderMacros.renderDebugText(pos, entry.getKey(), entry.getValue(), matrixStack, true, 3, bufferSource); } } - WorldRenderMacros.renderRedGlintLineBox(bufferSource, matrixStack, tagAnchor, tagAnchor, 0.02f); + WorldRenderMacros.renderRedGlintLineBox(bufferSource, matrixStack, BlockPos.ZERO, BlockPos.ZERO, 0.025f); + + matrixStack.popPose(); mc.getProfiler().pop(); } - - bufferSource.endBatch(); - matrixStack.popPose(); } /** diff --git a/src/main/java/com/ldtteam/structurize/storage/rendering/RenderingCache.java b/src/main/java/com/ldtteam/structurize/storage/rendering/RenderingCache.java index bbf00acb15..27010eafc3 100644 --- a/src/main/java/com/ldtteam/structurize/storage/rendering/RenderingCache.java +++ b/src/main/java/com/ldtteam/structurize/storage/rendering/RenderingCache.java @@ -123,6 +123,7 @@ public static BlueprintPreviewData getOrCreateBlueprintPreviewData(final String /** * @return true when should use light level from {@link #getOurLightLevel()} */ + @Deprecated public static boolean forceLightLevel() { return Structurize.getConfig().getClient().rendererLightLevel.get() >= 0; @@ -131,6 +132,7 @@ public static boolean forceLightLevel() /** * @return static light level */ + @Deprecated public static int getOurLightLevel() { return Structurize.getConfig().getClient().rendererLightLevel.get(); diff --git a/src/main/java/com/ldtteam/structurize/util/WorldRenderMacros.java b/src/main/java/com/ldtteam/structurize/util/WorldRenderMacros.java index 7ca18e2d3b..3f153b1451 100644 --- a/src/main/java/com/ldtteam/structurize/util/WorldRenderMacros.java +++ b/src/main/java/com/ldtteam/structurize/util/WorldRenderMacros.java @@ -930,13 +930,35 @@ public static void populateRectangle(final int x, * @param forceWhite force white for no depth rendering * @param mergeEveryXListElements merge every X elements of text list using a tostring call */ - @SuppressWarnings("resource") public static void renderDebugText(final BlockPos pos, final List text, final PoseStack matrixStack, final boolean forceWhite, final int mergeEveryXListElements, final MultiBufferSource buffer) + { + renderDebugText(pos, pos, text, matrixStack, forceWhite, mergeEveryXListElements, buffer); + } + + /** + * Renders the given list of strings, 3 elements a row. + * + * @param renderPos position to render at + * @param worldPos (logic) position in world + * @param text text list + * @param matrixStack stack to use + * @param buffer render buffer + * @param forceWhite force white for no depth rendering + * @param mergeEveryXListElements merge every X elements of text list using a tostring call + */ + @SuppressWarnings("resource") + public static void renderDebugText(final BlockPos renderPos, + final BlockPos worldPos, + final List text, + final PoseStack matrixStack, + final boolean forceWhite, + final int mergeEveryXListElements, + final MultiBufferSource buffer) { if (mergeEveryXListElements < 1) { @@ -945,15 +967,14 @@ public static void renderDebugText(final BlockPos pos, final EntityRenderDispatcher erm = Minecraft.getInstance().getEntityRenderDispatcher(); final int cap = text.size(); - if (cap > 0 && erm.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) <= MAX_DEBUG_TEXT_RENDER_DIST_SQUARED) + if (cap > 0 && erm.distanceToSqr(worldPos.getX(), worldPos.getY(), worldPos.getZ()) <= MAX_DEBUG_TEXT_RENDER_DIST_SQUARED) { final Font fontrenderer = Minecraft.getInstance().font; matrixStack.pushPose(); - matrixStack.translate(pos.getX() + 0.5d, pos.getY() + 0.75d, pos.getZ() + 0.5d); + matrixStack.translate(renderPos.getX() + 0.5d, renderPos.getY() + 0.6d, renderPos.getZ() + 0.5d); matrixStack.mulPose(erm.cameraOrientation()); matrixStack.scale(-0.014f, -0.014f, 0.014f); - matrixStack.translate(0.0d, 18.0d, 0.0d); final float backgroundTextOpacity = Minecraft.getInstance().options.getBackgroundOpacity(0.25F); final int alphaMask = (int) (backgroundTextOpacity * 255.0F) << 24; @@ -973,7 +994,7 @@ public static void renderDebugText(final BlockPos pos, false, rawPosMatrix, buffer, - Font.DisplayMode.SEE_THROUGH, + Font.DisplayMode.SEE_THROUGH, alphaMask, 0x00f000f0); if (!forceWhite)