Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{ "module": "integration", "needs": [] },
{ "module": "moveable-entity-block", "needs": [] },
{ "module": "network", "needs": [] },
{ "module": "renderer", "needs": [] },
{ "module": "font", "needs": [] },

{ "module": "explosion", "needs": ["config"] },
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/roseau_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
MODULES=(
codec collision config explosion font integration
moveable-entity-block multiblock network recipe registrum
rpc space-select sync util wheel main
renderer rpc space-select sync util wheel main
)

row() {
Expand Down
2 changes: 2 additions & 0 deletions module.main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ dependencies {
jarJar(api("dev.anvilcraft.lib:anvillib-recipe-neoforge-1.21.1:latest.release"))
interfaceInjectionData("dev.anvilcraft.lib:anvillib-recipe-neoforge-1.21.1:latest.release")
jarJar(api("dev.anvilcraft.lib:anvillib-registrum-neoforge-1.21.1:latest.release"))
jarJar(api("dev.anvilcraft.lib:anvillib-renderer-neoforge-1.21.1:latest.release"))
jarJar(api("dev.anvilcraft.lib:anvillib-rpc-neoforge-1.21.1:latest.release"))
jarJar(api("dev.anvilcraft.lib:anvillib-space-select-neoforge-1.21.1:latest.release"))
jarJar(api("dev.anvilcraft.lib:anvillib-sync-neoforge-1.21.1:latest.release"))
Expand All @@ -162,6 +163,7 @@ dependencies {
jarJar(api project(":anvillib-recipe-neoforge-1.21.1"))
interfaceInjectionData project(":anvillib-recipe-neoforge-1.21.1")
jarJar(api project(":anvillib-registrum-neoforge-1.21.1"))
jarJar(api project(":anvillib-renderer-neoforge-1.21.1"))
jarJar(api project(":anvillib-rpc-neoforge-1.21.1"))
jarJar(api project(":anvillib-space-select-neoforge-1.21.1"))
jarJar(api project(":anvillib-sync-neoforge-1.21.1"))
Expand Down
287 changes: 287 additions & 0 deletions module.renderer/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
alias libs.plugins.modDevGradle
alias libs.plugins.lombok
alias libs.plugins.machete
id 'org.jreleaser' version '1.23.0'
id "me.modmuss50.mod-publish-plugin" version "1.1.0"
}

String buildType = 'snapshot'
String buildNumber
if (System.getenv("CI_BUILD") == 'false') buildNumber = null
else {
if (System.getenv("PR_BUILD") != 'false') buildType = 'pr'
buildNumber = System.getenv("GITHUB_RUN_NUMBER")
}
version = "${mod_version}" + (buildNumber != null ? "+${buildType}.${buildNumber}" : "")
group = mod_group_id

base {
archivesName = "${project.mod_id}-neoforge-${libs.versions.minecraft.get()}"
}

repositories {
maven { url = "https://server.cjsah.net:1002/maven/" }
mavenLocal()
mavenCentral()
}

java.toolchain.languageVersion = JavaLanguageVersion.of(21)

neoForge {
// Specify the version of NeoForge to use.
version = libs.versions.neoForge.get()

parchment {
mappingsVersion = project.parchment_mappings_version
minecraftVersion = project.parchment_minecraft_version
}

// This line is optional. Access Transformers are automatically detected
// accessTransformers.add('src/main/resources/META-INF/accesstransformer.cfg')

interfaceInjectionData {
// from 'src/main/resources/interface_injections.json'
// publish file('src/main/resources/interface_injections.json')
}

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
client()

// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

server {
server()
programArgument '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

data {
data()

// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// gameDirectory = project.file('run-data')

// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}

// applies to all the run configs above
configureEach {
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
systemProperty 'forge.logging.markers', 'REGISTRIES'

// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
logLevel = org.slf4j.event.Level.DEBUG
}
}

mods {
// define mod <-> source bindings
// these are used to tell the game which sources are for which mod
// mostly optional in a single mod project
// but multi mod projects should define one per mod
"${mod_id}" {
sourceSet(sourceSets.main)
}
}
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

dependencies {
compileOnly 'org.jspecify:jspecify:1.0.0'
}

// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [minecraft_version : libs.versions.minecraft.get(),
minecraft_version_range: minecraft_version_range,
neo_version : libs.versions.neoForge.get(),
neo_version_range : neo_version_range,
loader_version_range : loader_version_range,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : version,
mod_authors : mod_authors,
mod_description : mod_description]
inputs.properties replaceProperties

filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties
}
}

tasks.register('sourcesJar', Jar) {
from delombok.outputs.files
dependsOn delombok
archiveClassifier = "sources"
}

tasks.register('javadocJar', Jar) {
from javadoc.destinationDir
dependsOn javadoc
archiveClassifier = "javadoc"
}

javadoc {
options.encoding = 'UTF-8'
options.addStringOption('Xdoclint:none', '-quiet')
}

jar {
from(rootProject.file("LICENSE"))
from(rootProject.file("ASSETS_LICENSE"))
from(rootProject.file("README.md"))
from(rootProject.file("README.en.md"))
}

artifacts {
archives tasks.jar
archives tasks.sourcesJar
archives tasks.javadocJar
}

def this_name = base.archivesName.get()
def this_description = mod_description

publishing {
publications {
register('mavenJava', MavenPublication) {
from components.java

artifact sourcesJar
artifact javadocJar

versionMapping {
allVariants {
fromResolutionResult()
}
}

pom {
name = this_name
description = this_description
url = 'https://github.com/Anvil-Dev/AnvilLib'

licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/license/mit'
}
}
developers {
developer {
id = 'Anvil-Dev'
name = 'AnvilCraft Dev'
email = 'admin@anvilcraft.dev'
}
}
scm {
url = 'https://github.com/Anvil-Dev/AnvilLib'
connection = 'https://github.com/Anvil-Dev/AnvilLib.git'
developerConnection = 'https://github.com/Anvil-Dev/AnvilLib.git'
}
}
}
}
repositories {
// Add repositories to publish to here.
def MAVEN_URL = System.getenv("MAVEN_URL")
if (MAVEN_URL != null) {
maven {
url MAVEN_URL
credentials {
username System.getenv("MAVEN_USERNAME")
password System.getenv("MAVEN_PASSWORD")
}
}
}
mavenLocal()
maven {
name = "staging"
url = layout.buildDirectory.dir("staging-deploy")
}
}
}

jreleaser {
signing {
active = 'ALWAYS'
armored = true
}

deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository('build/staging-deploy')
}
}
}
}
}

// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}

machete {
// disable machete locally for faster builds
enabled = false
}

lombok {
version = "1.18.34"
}

if (providers.gradleProperty('projectionTest').isPresent()) {
apply from: 'client-test.gradle'
}

// 默认构建不扫描被 Git 忽略的本地测试,避免本地文件影响 CI 和发布结果。
sourceSets.test.java.setSrcDirs([])
sourceSets.test.resources.setSrcDirs([])
tasks.named('test') { enabled = false }

if (providers.gradleProperty('cubeLocalTests').isPresent() || providers.gradleProperty('cubeClientSmoke').isPresent()) {
def localTests = layout.projectDirectory.file('local-tests.gradle').asFile
if (!localTests.isFile()) {
throw new GradleException('本地测试脚本 local-tests.gradle 不存在,请移除本地测试参数后执行默认构建')
}
apply from: localTests
}
29 changes: 29 additions & 0 deletions module.renderer/client-test.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
sourceSets {
clientTest {
compileClasspath += sourceSets.main.output + sourceSets.main.compileClasspath
runtimeClasspath += sourceSets.main.output + sourceSets.main.runtimeClasspath
}
}

neoForge {
mods {
anvillib_renderer_test { sourceSet sourceSets.clientTest }
}
runs {
projectionTest {
client()
gameDirectory = project.file('build/projection-test/run')
programArguments.addAll '--width', '800', '--height', '600'
}
}
}

def projectionTestLog = layout.buildDirectory.file('projection-test/run/logs/latest.log')
tasks.named('runProjectionTest') {
doLast {
def log = projectionTestLog.get().asFile.getText('UTF-8')
if (!log.contains('PROJECTION_TEST ALL PASS') || log.contains('PROJECTION_TEST FAILED')) {
throw new GradleException('Projection regression failed; inspect the isolated client log')
}
}
}
4 changes: 4 additions & 0 deletions module.renderer/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Mod Properties
mod_id=anvillib_renderer
mod_name=AnvilLib-Renderer
mod_description=Reusable client projection rendering
Loading
Loading