mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-05-20 08:40:26 +00:00
Compare commits
332 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e6300df185 | |||
| 65eb66c3ca | |||
| aa3fe18339 | |||
| 6a6a3928cd | |||
| ac1258d233 | |||
| b6d42fdcc1 | |||
| a9251fa228 | |||
| 38a1571941 | |||
| b9af66848a | |||
| e9d30b8794 | |||
| 53dafa4a2c | |||
| df46c617f2 | |||
| e706ef89fc | |||
| a66c2a0749 | |||
| a5fe4d7928 | |||
| 966bcab370 | |||
| eae5a60cf9 | |||
| 9357b18964 | |||
| 86bb4d5a1a | |||
| 47bdd66fe7 | |||
| eb6b3704d0 | |||
| 8eb5a70d4d | |||
| 5dc9f419ac | |||
| 2215ea8336 | |||
| 998b6478f3 | |||
| efa4bf5bb4 | |||
| 2ad05cbbb6 | |||
| 1bbedf51b5 | |||
| bdcd93f164 | |||
| c4a366112e | |||
| cb08401536 | |||
| 9a16336f53 | |||
| 16705057e0 | |||
| d52cd0d7cf | |||
| 7d3382e623 | |||
| 87e437f889 | |||
| 292be6bcec | |||
| f03f39f1d7 | |||
| 8bfff6b010 | |||
| e5d30183ef | |||
| 3777fda641 | |||
| f684c60039 | |||
| ef088dd3f7 | |||
| 4f672dfb7b | |||
| b851b2f881 | |||
| 9c64353111 | |||
| c537605880 | |||
| c6eb2f49f3 | |||
| 6929de7b61 | |||
| a159debe3e | |||
| 99e2907b2d | |||
| ac71b3ec0c | |||
| e184937743 | |||
| 8c155c78eb | |||
| fc779e1120 | |||
| be964da4fa | |||
| 6ca401413b | |||
| e556e2bca1 | |||
| 1fc97a480a | |||
| bba55f2669 | |||
| 97b4ea6d94 | |||
| cf4f7822e2 | |||
| d6285a5901 | |||
| 8b933b0d5c | |||
| f9a5dfbfce | |||
| 24bca3ed98 | |||
| f8f6b0b4bc | |||
| dd2f0365b0 | |||
| ae2d801be0 | |||
| 8578bba7b9 | |||
| d262831107 | |||
| ddc8cc7db5 | |||
| 12f1b3f8fc | |||
| dc7c57d1a3 | |||
| 309fb5af96 | |||
| 9d747aed71 | |||
| 3cf11a9ad4 | |||
| 9f766b0647 | |||
| 8fa3978dc8 | |||
| c282e55f90 | |||
| 8b62badbdb | |||
| 8bceb255c0 | |||
| ad80769d67 | |||
| 9d0fa0a7c4 | |||
| 8c532ede8e | |||
| c3d26527a7 | |||
| 1fe56335c8 | |||
| 3b377d91ee | |||
| 0144200ec9 | |||
| d1ad3d04e1 | |||
| d640b49ded | |||
| ecbfd1740c | |||
| dc5952add7 | |||
| 1b6ebeb05f | |||
| 234ff3e49c | |||
| 243c523b57 | |||
| 1700650753 | |||
| 12d2221d49 | |||
| 42e1adfc3a | |||
| 4ff91c9fea | |||
| 81bc51f5a1 | |||
| ac98726f81 | |||
| 1d2c6d4294 | |||
| 9ca7014344 | |||
| 8d153998fa | |||
| 2b09ed8fd9 | |||
| 96493ede15 | |||
| 48586eb523 | |||
| a80b94ad45 | |||
| 089850d633 | |||
| 42f3c56b71 | |||
| 874ef56025 | |||
| 06f04005ea | |||
| 774d076f77 | |||
| e4561bd48f | |||
| 550a037661 | |||
| 3b25e82a73 | |||
| 9b3a105672 | |||
| 10558b5446 | |||
| 326300bcce | |||
| a7826dec49 | |||
| fd3d1ce830 | |||
| 84a6cd0c26 | |||
| d1faac8b96 | |||
| de4656d01f | |||
| 6dba2e9394 | |||
| 8a8db4a9b8 | |||
| c1a00ca5c7 | |||
| 2b5d613aef | |||
| 8bea1d23e0 | |||
| fb5e597a11 | |||
| 0990df0620 | |||
| 451683aff5 | |||
| 41e9c2f55f | |||
| 4873b321cb | |||
| 64546bb154 | |||
| d97478d2c4 | |||
| 359b4826bc | |||
| 4b218a65f6 | |||
| b88712e569 | |||
| af509ebc3b | |||
| a5c3733568 | |||
| 3ef60f4b33 | |||
| b7864bb6fb | |||
| 757ed6ad4d | |||
| 1ef12fdec0 | |||
| 4e890f96e4 | |||
| 4e70ee99c9 | |||
| b149497c60 | |||
| d9f591bdb4 | |||
| a4b74e2e7f | |||
| b53d475f42 | |||
| 4ddb741d0d | |||
| 852f5aa610 | |||
| 953895a8d4 | |||
| 8788eab839 | |||
| 2b62473372 | |||
| b9187248c3 | |||
| 2d42810ba3 | |||
| 9f546370cd | |||
| 428bf341ef | |||
| 8a61571ceb | |||
| b669f87b79 | |||
| e507675ef6 | |||
| 0fc2105ee6 | |||
| 77b077dd47 | |||
| f38fcd03b0 | |||
| af1e9de474 | |||
| 3322a16f09 | |||
| 78707468c5 | |||
| c658d1a81b | |||
| 56a7234494 | |||
| 217b708177 | |||
| 7d86a41f65 | |||
| 753574fc9b | |||
| 95f89ed2b6 | |||
| cb8aefe8d2 | |||
| cd8d6f0da3 | |||
| d33b75b77b | |||
| 79f9488380 | |||
| 4c2ce65cdc | |||
| 70c448dd0d | |||
| 3ad0ef8501 | |||
| 060bda2ec1 | |||
| 6b60246694 | |||
| 1a1f461550 | |||
| da20e282ce | |||
| 9b14b0ee96 | |||
| 89cbab071f | |||
| 71953c90a2 | |||
| 923cb08b37 | |||
| 21ef8c0dc4 | |||
| 77b1960757 | |||
| a06c6fd980 | |||
| 46f533ca9d | |||
| 9a61334f5a | |||
| 118aeb872f | |||
| 5446b729f9 | |||
| d71c6bb25f | |||
| d8524603c6 | |||
| 85234ddc39 | |||
| 78162eaafe | |||
| 7a041d8a63 | |||
| 8cfa2e1467 | |||
| 5f367c0f2c | |||
| f4db7fc507 | |||
| ad9d16f48c | |||
| a79a347765 | |||
| 46e603d681 | |||
| 3f77b4a975 | |||
| 16755fa049 | |||
| a25e3cd5a5 | |||
| c4dfdafce8 | |||
| 3fe79338db | |||
| 7f324bd72b | |||
| 4eace9e7fb | |||
| 39ae1fdf93 | |||
| e9d1add6af | |||
| 94d135c66c | |||
| 1881051191 | |||
| 28132e0f13 | |||
| 1ef34469cb | |||
| e79ea4ab82 | |||
| 4450a56ef0 | |||
| a061660e46 | |||
| abdff16a0a | |||
| c08e973e3e | |||
| b12fe77f32 | |||
| 28d93d158e | |||
| 118dc32d64 | |||
| d9a4d64b17 | |||
| 56a1feb708 | |||
| 858adfe866 | |||
| bdd80d7832 | |||
| adfdb8d63c | |||
| ef10081bcd | |||
| dc8492a6cb | |||
| 5e1c9d8ebe | |||
| 5dff25670c | |||
| 089b25dea4 | |||
| 1dd59c378e | |||
| d97fb4ff7b | |||
| 761a014ea5 | |||
| 9749eecd87 | |||
| 32cc4976c8 | |||
| e2e0e292b7 | |||
| 227bfe7b29 | |||
| 52dc690243 | |||
| d33d4af296 | |||
| fb0dbda296 | |||
| 4c860ca4ae | |||
| b6e4543625 | |||
| 0921dfb204 | |||
| 5892464a1d | |||
| 8366a5288b | |||
| d2b7384639 | |||
| 8ffb09db36 | |||
| ecbca608a5 | |||
| b4ab88a02e | |||
| ef1c9c125f | |||
| e665e187c1 | |||
| bd28d8170c | |||
| d91e531fa5 | |||
| 2a40f4af1e | |||
| d088d2f5a8 | |||
| 3d66386f99 | |||
| 1912d8e34c | |||
| d48b610b39 | |||
| dc6cfb4187 | |||
| cd2421bb49 | |||
| a82dcd579c | |||
| a20d2c1f60 | |||
| f5f3725dba | |||
| a7a7354c40 | |||
| 42dcc9d9bd | |||
| 581651e83b | |||
| a95a1284a4 | |||
| c95b3c09a8 | |||
| 2df2755631 | |||
| ddb131d413 | |||
| 2e145ccd0a | |||
| 0731d781d5 | |||
| 5bc73dec37 | |||
| b848ddabda | |||
| 7214053b9e | |||
| da5d0c52f2 | |||
| cd69c7e77d | |||
| 56dd15c9aa | |||
| 2f470a3720 | |||
| 5350917412 | |||
| 45528acac8 | |||
| 921212ccb5 | |||
| 37641d43d6 | |||
| 87ea5ce9e7 | |||
| 77f766b8bb | |||
| ecbba57b0a | |||
| 839835afd7 | |||
| 56941c237c | |||
| 179a304cd2 | |||
| 4970bf5720 | |||
| f877f861cf | |||
| d5f0b69bc7 | |||
| b10fd84e00 | |||
| 3e04bae828 | |||
| 82334cfe9e | |||
| 50ba1c6eab | |||
| 27a967f3a6 | |||
| 4c71355535 | |||
| e83b70b5ae | |||
| 56b428d501 | |||
| 7ca24faad3 | |||
| 9d200565d7 | |||
| f6c2795eaf | |||
| 6f03746e41 | |||
| 47c8cb3168 | |||
| a9f973cae9 | |||
| 033181d7c8 | |||
| e11a235386 | |||
| db1e924246 | |||
| c86faa44ec | |||
| de91a6facb | |||
| d4a328eb38 | |||
| b039629b2d | |||
| d48fa96ec7 | |||
| 8dd1f49b88 | |||
| 81528915a8 | |||
| 5979254808 | |||
| c0aaf6c6e8 | |||
| 1ab3233cba | |||
| 59ea5a69d8 | |||
| 4ba71e9c27 | |||
| 5c7441241c |
Vendored
+149
@@ -0,0 +1,149 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
tools {
|
||||
jdk "Temurin Java 21"
|
||||
}
|
||||
|
||||
triggers {
|
||||
githubPush()
|
||||
}
|
||||
|
||||
environment {
|
||||
DISCORD_WEBHOOK_URL = credentials('polydev-discord-webhook-url')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
scmSkip(deleteBuild: true)
|
||||
}
|
||||
}
|
||||
|
||||
stage('Setup Gradle') {
|
||||
steps {
|
||||
sh 'chmod +x gradlew'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
withGradle {
|
||||
sh './gradlew build --rerun-tasks -x check'
|
||||
sh './gradlew javadoc'
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
archiveArtifacts artifacts: 'platforms/fabric/build/libs/Terra-fabric*.jar,platforms/bukkit/build/libs/Terra-bukkit*-shaded.jar,platforms/allay/build/libs/Terra-allay*.jar,platforms/minestom/build/libs/Terra-minestom*.jar', fingerprint: true, onlyIfSuccessful: true
|
||||
|
||||
javadoc javadocDir: 'common/api/build/docs/javadoc', keepAll: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Tests') {
|
||||
steps {
|
||||
withGradle {
|
||||
sh './gradlew test --rerun-tasks'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// stage('Deploy to snapshots repositories') {
|
||||
// when {
|
||||
// allOf {
|
||||
// not { buildingTag() }
|
||||
// not { expression { env.TAG_NAME != null && env.TAG_NAME.matches('v\\d+\\.\\d+\\.\\d+') } }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// steps {
|
||||
// withCredentials([
|
||||
// string(credentialsId: 'maven-signing-key', variable: 'ORG_GRADLE_PROJECT_signingKey'),
|
||||
// string(credentialsId: 'maven-signing-key-password', variable: 'ORG_GRADLE_PROJECT_signingPassword'),
|
||||
// usernamePassword(
|
||||
// credentialsId: 'solo-studios-maven',
|
||||
// passwordVariable: 'ORG_GRADLE_PROJECT_SoloStudiosSnapshotsPassword',
|
||||
// usernameVariable: 'ORG_GRADLE_PROJECT_SoloStudiosSnapshotsUsername'
|
||||
// )
|
||||
// ]) {
|
||||
// withGradle {
|
||||
// sh './gradlew publishAllPublicationsToSoloStudiosSnapshotsRepository'
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
stage('Deploy to releases repositories') {
|
||||
// when {
|
||||
// allOf {
|
||||
// buildingTag()
|
||||
// expression { env.TAG_NAME != null && env.TAG_NAME.matches('v\\d+\\.\\d+\\.\\d+') }
|
||||
// }
|
||||
// }
|
||||
|
||||
steps {
|
||||
withCredentials([
|
||||
string(credentialsId: 'maven-signing-key', variable: 'ORG_GRADLE_PROJECT_signingKey'),
|
||||
string(credentialsId: 'maven-signing-key-password', variable: 'ORG_GRADLE_PROJECT_signingPassword'),
|
||||
usernamePassword(
|
||||
credentialsId: 'solo-studios-maven',
|
||||
passwordVariable: 'ORG_GRADLE_PROJECT_SoloStudiosReleasesPassword',
|
||||
usernameVariable: 'ORG_GRADLE_PROJECT_SoloStudiosReleasesUsername'
|
||||
),
|
||||
// TODO: does not yet exist (uncomment once added)
|
||||
// usernamePassword(
|
||||
// credentialsId: 'sonatype-maven-credentials',
|
||||
// passwordVariable: 'ORG_GRADLE_PROJECT_SonatypePassword',
|
||||
// usernameVariable: 'ORG_GRADLE_PROJECT_SonatypeUsername'
|
||||
// ),
|
||||
// usernamePassword(
|
||||
// credentialsId: 'codemc-maven-credentials',
|
||||
// passwordVariable: 'ORG_GRADLE_PROJECT_CodeMCPassword',
|
||||
// usernameVariable: 'ORG_GRADLE_PROJECT_CodeMCUsername'
|
||||
// )
|
||||
]) {
|
||||
withGradle {
|
||||
sh './gradlew publish'
|
||||
//sh './gradlew publishAllPublicationsToSoloStudiosReleasesRepository'
|
||||
// sh './gradlew publishAllPublicationsToSonatypeRepository'
|
||||
// sh './gradlew publishAllPublicationsToCodeMCRepository'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
discoverReferenceBuild()
|
||||
|
||||
// junit testResults: '**/build/test-results/*/TEST-*.xml'
|
||||
|
||||
recordIssues(
|
||||
aggregatingResults: true,
|
||||
enabledForFailure: true,
|
||||
minimumSeverity: 'ERROR',
|
||||
sourceCodeEncoding: 'UTF-8',
|
||||
checksAnnotationScope: 'ALL',
|
||||
sourceCodeRetention: 'LAST_BUILD',
|
||||
tools: [java(), javaDoc()]
|
||||
)
|
||||
|
||||
discordSend(
|
||||
title: env.JOB_NAME + ' ' + env.BUILD_DISPLAY_NAME,
|
||||
showChangeset: true,
|
||||
enableArtifactsList: true,
|
||||
link: env.BUILD_URL,
|
||||
result: currentBuild.currentResult,
|
||||
customAvatarUrl: 'https://github.com/PolyhedralDev.png',
|
||||
customUsername: 'Solo Studios Jenkins',
|
||||
webhookURL: env.DISCORD_WEBHOOK_URL,
|
||||
)
|
||||
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
preRelease(true)
|
||||
|
||||
versionProjects(":common:api", version("6.6.4"))
|
||||
versionProjects(":common:implementation", version("6.6.4"))
|
||||
versionProjects(":platforms", version("6.6.4"))
|
||||
versionProjects(":common:api", version("7.0.0"))
|
||||
versionProjects(":common:implementation", version("7.0.0"))
|
||||
versionProjects(":platforms", version("7.0.0"))
|
||||
|
||||
|
||||
allprojects {
|
||||
|
||||
@@ -22,11 +22,11 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
//TODO Allow pulling from Versions.kt
|
||||
implementation("com.gradleup.shadow", "shadow-gradle-plugin", "8.3.6")
|
||||
implementation("com.gradleup.shadow", "shadow-gradle-plugin", "8.3.9")
|
||||
|
||||
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "2.0.0-beta.17")
|
||||
implementation("org.ow2.asm", "asm", "9.8")
|
||||
implementation("org.ow2.asm", "asm-tree", "9.8")
|
||||
implementation("com.dfsek.tectonic", "common", "4.2.1")
|
||||
implementation("org.yaml", "snakeyaml", "2.4")
|
||||
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "2.0.0-beta.18")
|
||||
implementation("org.ow2.asm", "asm", "9.9")
|
||||
implementation("org.ow2.asm", "asm-tree", "9.9")
|
||||
implementation("com.dfsek.tectonic", "common", "4.3.1")
|
||||
implementation("org.yaml", "snakeyaml", "2.5")
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import org.gradle.kotlin.dsl.getByName
|
||||
import org.gradle.kotlin.dsl.register
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import org.gradle.plugins.ide.idea.model.IdeaModel
|
||||
|
||||
fun Project.configureCompilation() {
|
||||
apply(plugin = "maven-publish")
|
||||
@@ -21,6 +22,13 @@ fun Project.configureCompilation() {
|
||||
apply(plugin = "idea")
|
||||
apply<TectonicDocPlugin>()
|
||||
|
||||
configure<IdeaModel> {
|
||||
module {
|
||||
isDownloadJavadoc = true
|
||||
isDownloadSources = true
|
||||
}
|
||||
}
|
||||
|
||||
configure<JavaPluginExtension> {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
|
||||
@@ -57,15 +57,6 @@ fun Project.configureDependencies() {
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
|
||||
name = "Sonatype Snapshots"
|
||||
}
|
||||
maven("https://repo.opencollab.dev/maven-releases/") {
|
||||
name = "OpenCollab Releases"
|
||||
}
|
||||
maven("https://repo.opencollab.dev/maven-snapshots/") {
|
||||
name = "OpenCollab Snapshots"
|
||||
}
|
||||
maven("https://storehouse.okaeri.eu/repository/maven-public/") {
|
||||
name = "Okaeri"
|
||||
}
|
||||
maven("https://repo.onarandombox.com/multiverse-releases") {
|
||||
name = "onarandombox"
|
||||
}
|
||||
|
||||
@@ -49,10 +49,21 @@ fun Project.configureDistribution() {
|
||||
doFirst {
|
||||
try {
|
||||
file("${buildDir}/resources/main/packs/").deleteRecursively()
|
||||
file("${buildDir}/resources/main/metapacks/").deleteRecursively()
|
||||
val overworldPackUrl =
|
||||
URL("https://github.com/PolyhedralDev/TerraOverworldConfig/releases/download/" + Versions.Terra.overworldConfig + "/Overworld.zip")
|
||||
val reimagENDPackUrl =
|
||||
URL("https://github.com/PolyhedralDev/ReimagEND/releases/download/" + Versions.Terra.reimagENDConfig + "/ReimagEND.zip")
|
||||
val tartarusPackUrl =
|
||||
URL("https://github.com/PolyhedralDev/Tartarus/releases/download/" + Versions.Terra.tartarusConfig + "/Tartarus.zip")
|
||||
val defaultPackUrl =
|
||||
URL("https://github.com/PolyhedralDev/TerraOverworldConfig/releases/download/" + Versions.Terra.overworldConfig + "/default.zip")
|
||||
downloadPack(defaultPackUrl, project)
|
||||
} catch (_:Exception) {}
|
||||
URL("https://github.com/PolyhedralDev/DefaultMetapack/releases/download/" + Versions.Terra.defaultConfig + "/default.zip")
|
||||
downloadPack(overworldPackUrl, project)
|
||||
downloadPack(reimagENDPackUrl, project)
|
||||
downloadPack(tartarusPackUrl, project)
|
||||
downloadPack(defaultPackUrl, project, true)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +107,13 @@ fun Project.configureDistribution() {
|
||||
resources.computeIfAbsent("packs") { ArrayList() }.add(it.name)
|
||||
}
|
||||
|
||||
val metaPacksDir = File("${project.buildDir}/resources/main/metapacks/")
|
||||
|
||||
metaPacksDir.walkTopDown().forEach {
|
||||
if (it.isDirectory || !it.name.endsWith(".zip")) return@forEach
|
||||
resources.computeIfAbsent("metapacks") { ArrayList() }.add(it.name)
|
||||
}
|
||||
|
||||
val langDir = File("${project(":common:implementation").buildDir}/resources/main/lang/")
|
||||
|
||||
langDir.walkTopDown().forEach {
|
||||
@@ -163,9 +181,10 @@ fun Project.configureDistribution() {
|
||||
}
|
||||
}
|
||||
|
||||
fun downloadPack(packUrl: URL, project: Project) {
|
||||
fun downloadPack(packUrl: URL, project: Project, metapack: Boolean = false) {
|
||||
val fileName = packUrl.file.substring(packUrl.file.lastIndexOf("/"))
|
||||
val file = File("${project.buildDir}/resources/main/packs/${fileName}")
|
||||
val resourceType = if (metapack) "metapacks" else "packs"
|
||||
val file = File("${project.buildDir}/resources/main/${resourceType}/${fileName}")
|
||||
file.parentFile.mkdirs()
|
||||
file.outputStream().write(packUrl.readBytes())
|
||||
}
|
||||
|
||||
@@ -16,16 +16,17 @@ fun Project.configurePublishing() {
|
||||
}
|
||||
|
||||
repositories {
|
||||
val mavenUrl = "https://repo.codemc.io/repository/maven-releases/"
|
||||
val mavenUrl = "https://maven.solo-studios.ca/releases/"
|
||||
//val mavenSnapshotUrl = "https://repo.codemc.io/repository/maven-snapshots/"
|
||||
|
||||
maven(mavenUrl) {
|
||||
val mavenUsername: String? by project
|
||||
val mavenPassword: String? by project
|
||||
if (mavenUsername != null && mavenPassword != null) {
|
||||
val SoloStudiosReleasesUsername: String? by project
|
||||
val SoloStudiosReleasesPassword: String? by project
|
||||
|
||||
if (SoloStudiosReleasesUsername != null && SoloStudiosReleasesPassword != null) {
|
||||
credentials {
|
||||
username = mavenUsername
|
||||
password = mavenPassword
|
||||
username = SoloStudiosReleasesUsername
|
||||
password = SoloStudiosReleasesPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,39 @@
|
||||
object Versions {
|
||||
object Terra {
|
||||
const val overworldConfig = "v1.5.2"
|
||||
const val overworldConfig = "latest"
|
||||
const val reimagENDConfig = "latest"
|
||||
const val tartarusConfig = "latest"
|
||||
const val defaultConfig = "latest"
|
||||
}
|
||||
|
||||
object Libraries {
|
||||
const val tectonic = "4.2.1"
|
||||
const val paralithic = "0.8.1"
|
||||
const val tectonic = "4.3.1"
|
||||
const val paralithic = "2.0.1"
|
||||
const val strata = "1.3.2"
|
||||
const val seismic = "2.5.7"
|
||||
|
||||
const val cloud = "2.0.0"
|
||||
|
||||
const val caffeine = "3.2.1"
|
||||
const val caffeine = "3.2.2"
|
||||
|
||||
const val slf4j = "2.0.17"
|
||||
|
||||
object Internal {
|
||||
const val shadow = "8.3.6"
|
||||
const val apacheText = "1.13.1"
|
||||
const val apacheIO = "2.19.0"
|
||||
const val guava = "33.4.8-jre"
|
||||
const val asm = "9.8"
|
||||
const val snakeYml = "2.4"
|
||||
const val jetBrainsAnnotations = "26.0.2"
|
||||
const val junit = "5.13.1"
|
||||
const val shadow = "8.3.9"
|
||||
const val apacheText = "1.14.0"
|
||||
const val apacheIO = "2.20.0"
|
||||
const val guava = "33.5.0-jre"
|
||||
const val asm = "9.9"
|
||||
const val snakeYml = "2.5"
|
||||
const val jetBrainsAnnotations = "26.0.2-1"
|
||||
const val junit = "6.0.0"
|
||||
const val nbt = "6.1"
|
||||
}
|
||||
}
|
||||
|
||||
object Fabric {
|
||||
const val fabricAPI = "0.127.0+${Mod.minecraft}"
|
||||
const val cloud = "2.0.0-beta.10"
|
||||
const val fabricAPI = "0.134.1+${Mod.minecraft}"
|
||||
const val cloud = "2.0.0-beta.13"
|
||||
}
|
||||
//
|
||||
// object Quilt {
|
||||
@@ -38,15 +42,15 @@ object Versions {
|
||||
// }
|
||||
|
||||
object Mod {
|
||||
const val mixin = "0.15.5+mixin.0.8.7"
|
||||
const val mixinExtras = "0.4.1"
|
||||
const val mixin = "0.16.4+mixin.0.8.7"
|
||||
const val mixinExtras = "0.5.0"
|
||||
|
||||
const val minecraft = "1.21.6"
|
||||
const val minecraft = "1.21.10"
|
||||
const val yarn = "$minecraft+build.1"
|
||||
const val fabricLoader = "0.16.14"
|
||||
const val fabricLoader = "0.18.2"
|
||||
|
||||
const val architecuryLoom = "1.10.431"
|
||||
const val architecturyPlugin = "3.4.161"
|
||||
const val architecuryLoom = "1.11.451"
|
||||
const val architecturyPlugin = "3.4.162"
|
||||
|
||||
}
|
||||
//
|
||||
@@ -56,16 +60,17 @@ object Versions {
|
||||
// }
|
||||
|
||||
object Bukkit {
|
||||
const val minecraft = "1.21.6-R0.1"
|
||||
const val paperBuild = "$minecraft-20250617.170821-8"
|
||||
const val minecraft = "1.21.10"
|
||||
const val nms = "$minecraft-R0.1"
|
||||
const val paperBuild = "$nms-20251012.013929-7"
|
||||
const val paper = paperBuild
|
||||
const val paperLib = "1.0.8"
|
||||
const val reflectionRemapper = "0.1.2"
|
||||
const val reflectionRemapper = "0.1.3"
|
||||
const val paperDevBundle = paperBuild
|
||||
const val runPaper = "2.3.1"
|
||||
const val paperWeight = "2.0.0-beta.17"
|
||||
const val cloud = "2.0.0-beta.10"
|
||||
const val multiverse = "5.0.2"
|
||||
const val paperWeight = "2.0.0-beta.19"
|
||||
const val cloud = "2.0.0-beta.12"
|
||||
const val multiverse = "5.3.0"
|
||||
}
|
||||
|
||||
//
|
||||
@@ -76,18 +81,21 @@ object Versions {
|
||||
// }
|
||||
//
|
||||
object CLI {
|
||||
const val logback = "1.5.18"
|
||||
const val logback = "1.5.19"
|
||||
const val picocli = "4.7.7"
|
||||
}
|
||||
|
||||
object Allay {
|
||||
const val api = "0.4.1"
|
||||
const val gson = "2.13.1"
|
||||
const val mappings = "3626653"
|
||||
const val mappingsGenerator = "366618e"
|
||||
const val api = "0.13.0"
|
||||
const val gson = "2.13.2"
|
||||
|
||||
const val mappings = "15398c1"
|
||||
const val mappingsGenerator = "8fa6058"
|
||||
|
||||
const val mcmeta = "e85a17c"
|
||||
}
|
||||
|
||||
object Minestom {
|
||||
const val minestom = "1_21_6-c3ccee696b"
|
||||
const val minestom = "2025.10.04-1.21.8"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class ApiAddon implements BaseAddon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class ApiAddonLoader implements BootstrapBaseAddon<BaseAddon> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return VERSION;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -66,12 +66,12 @@ public class ManifestAddon implements BaseAddon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, VersionRange> getDependencies() {
|
||||
public Map<String, VersionRange> dependencies() {
|
||||
return manifest.getDependencies();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return manifest.getVersion();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -132,7 +132,7 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
public Version version() {
|
||||
return VERSION;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
schema-version: 1
|
||||
contributors:
|
||||
- Terra contributors
|
||||
id: biome-query-api
|
||||
id: api-biome-query
|
||||
version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.query.BiomeQueryAPIAddon"
|
||||
@@ -0,0 +1,7 @@
|
||||
version = version("1.1.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
|
||||
|
||||
}
|
||||
+9
-9
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.addons.image;
|
||||
|
||||
import com.dfsek.seismic.type.sampler.Sampler;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
@@ -15,8 +16,8 @@ import com.dfsek.terra.addons.image.config.colorsampler.mutate.RotateColorSample
|
||||
import com.dfsek.terra.addons.image.config.colorsampler.mutate.TranslateColorSamplerTemplate;
|
||||
import com.dfsek.terra.addons.image.config.image.ImageTemplate;
|
||||
import com.dfsek.terra.addons.image.config.image.StitchedImageTemplate;
|
||||
import com.dfsek.terra.addons.image.config.noisesampler.ChannelNoiseSamplerTemplate;
|
||||
import com.dfsek.terra.addons.image.config.noisesampler.DistanceTransformNoiseSamplerTemplate;
|
||||
import com.dfsek.terra.addons.image.config.sampler.ChannelSamplerTemplate;
|
||||
import com.dfsek.terra.addons.image.config.sampler.DistanceTransformSamplerTemplate;
|
||||
import com.dfsek.terra.addons.image.image.Image;
|
||||
import com.dfsek.terra.addons.image.operator.DistanceTransform;
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
@@ -26,7 +27,6 @@ import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ImageLibraryAddon implements AddonInitializer {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<ColorSampler>>> COLOR_PICKER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
public static final TypeKey<Supplier<ObjectTemplate<NoiseSampler>>> NOISE_SAMPLER_TOKEN = new TypeKey<>() {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<Sampler>>> NOISE_SAMPLER_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
@Inject
|
||||
private Platform platform;
|
||||
@@ -60,8 +60,8 @@ public class ImageLibraryAddon implements AddonInitializer {
|
||||
.then(event -> {
|
||||
ConfigPack pack = event.getPack();
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Image>>> imageRegistry = pack.getOrCreateRegistry(IMAGE_REGISTRY_KEY);
|
||||
imageRegistry.register(addon.key("BITMAP"), () -> new ImageTemplate(pack.getLoader(), pack));
|
||||
imageRegistry.register(addon.key("STITCHED_BITMAP"), () -> new StitchedImageTemplate(pack.getLoader(), pack));
|
||||
imageRegistry.register(addon.key("BITMAP"), () -> new ImageTemplate(pack));
|
||||
imageRegistry.register(addon.key("STITCHED_BITMAP"), () -> new StitchedImageTemplate(pack));
|
||||
})
|
||||
.then(event -> {
|
||||
event.getPack()
|
||||
@@ -71,10 +71,10 @@ public class ImageLibraryAddon implements AddonInitializer {
|
||||
(type, o, loader, depthTracker) -> DistanceTransform.Normalization.valueOf((String) o))
|
||||
.applyLoader(ColorString.class, new ColorLoader());
|
||||
|
||||
CheckedRegistry<Supplier<ObjectTemplate<NoiseSampler>>> noiseRegistry = event.getPack().getOrCreateRegistry(
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Sampler>>> noiseRegistry = event.getPack().getOrCreateRegistry(
|
||||
NOISE_SAMPLER_TOKEN);
|
||||
noiseRegistry.register(addon.key("DISTANCE_TRANSFORM"), DistanceTransformNoiseSamplerTemplate::new);
|
||||
noiseRegistry.register(addon.key("CHANNEL"), ChannelNoiseSamplerTemplate::new);
|
||||
noiseRegistry.register(addon.key("DISTANCE_TRANSFORM"), DistanceTransformSamplerTemplate::new);
|
||||
noiseRegistry.register(addon.key("CHANNEL"), ChannelSamplerTemplate::new);
|
||||
})
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<ColorSampler>>> colorSamplerRegistry = event.getPack().getOrCreateRegistry(
|
||||
+4
-3
@@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.addons.image.colorsampler.mutate;
|
||||
|
||||
import com.dfsek.seismic.math.trigonometry.TrigonometryFunctions;
|
||||
|
||||
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
|
||||
public class RotateColorSampler implements ColorSampler {
|
||||
@@ -39,14 +40,14 @@ public class RotateColorSampler implements ColorSampler {
|
||||
case DEG_90 -> -z;
|
||||
case DEG_180 -> -x;
|
||||
case DEG_270 -> z;
|
||||
case RAD_ANY -> (int) (x * MathUtil.cos(radians) - z * MathUtil.sin(radians));
|
||||
case RAD_ANY -> (int) (x * TrigonometryFunctions.cos(radians) - z * TrigonometryFunctions.sin(radians));
|
||||
};
|
||||
int rz = switch(rotationMethod) {
|
||||
case DEG_0 -> z;
|
||||
case DEG_90 -> x;
|
||||
case DEG_180 -> -z;
|
||||
case DEG_270 -> -x;
|
||||
case RAD_ANY -> (int) (z * MathUtil.cos(radians) + x * MathUtil.sin(radians));
|
||||
case RAD_ANY -> (int) (z * TrigonometryFunctions.cos(radians) + x * TrigonometryFunctions.sin(radians));
|
||||
};
|
||||
return sampler.apply(rx, rz);
|
||||
}
|
||||
+11
-20
@@ -2,10 +2,13 @@ package com.dfsek.terra.addons.image.config.image;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.github.benmanes.caffeine.cache.Scheduler;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.dfsek.terra.addons.image.config.ImageLibraryPackConfigTemplate;
|
||||
@@ -13,11 +16,8 @@ import com.dfsek.terra.addons.image.image.BufferedImageWrapper;
|
||||
import com.dfsek.terra.addons.image.image.Image;
|
||||
import com.dfsek.terra.addons.image.image.SuppliedImage;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.Loader;
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Scheduler;
|
||||
import com.dfsek.terra.api.util.generic.Memo;
|
||||
|
||||
import static com.dfsek.terra.api.util.cache.CacheUtils.CACHE_EXECUTOR;
|
||||
|
||||
@@ -26,13 +26,13 @@ import static com.dfsek.terra.api.util.cache.CacheUtils.CACHE_EXECUTOR;
|
||||
* Cache prevents configs from loading the same image multiple times into memory
|
||||
*/
|
||||
record ImageCache(LoadingCache<String, Image> cache) implements Properties {
|
||||
public static Image load(String path, ConfigPack pack, Loader files) throws IOException {
|
||||
public static Image load(String path, ConfigPack pack) throws IOException {
|
||||
ImageLibraryPackConfigTemplate config = pack.getContext().get(ImageLibraryPackConfigTemplate.class);
|
||||
ImageCache images;
|
||||
if(!pack.getContext().has(ImageCache.class)) {
|
||||
var cacheBuilder = Caffeine.newBuilder().executor(CACHE_EXECUTOR).scheduler(Scheduler.systemScheduler());
|
||||
if(config.unloadOnTimeout()) cacheBuilder.expireAfterAccess(config.getCacheTimeout(), TimeUnit.SECONDS);
|
||||
images = new ImageCache(cacheBuilder.build(s -> loadImage(s, files)));
|
||||
images = new ImageCache(cacheBuilder.build(s -> loadImage(s, pack.getRootPath())));
|
||||
pack.getContext().put(images);
|
||||
} else images = pack.getContext().get(ImageCache.class);
|
||||
|
||||
@@ -41,7 +41,7 @@ record ImageCache(LoadingCache<String, Image> cache) implements Properties {
|
||||
return new SuppliedImage(() -> images.cache.get(path));
|
||||
} else {
|
||||
// If images do not time out, image can be lazily loaded once instead of performing cache lookups for each image operation
|
||||
Lazy<Image> lazyImage = Lazy.lazy(() -> images.cache.get(path));
|
||||
Memo<Image> lazyImage = Memo.lazy(() -> images.cache.get(path));
|
||||
return new SuppliedImage(lazyImage::value);
|
||||
}
|
||||
}
|
||||
@@ -49,17 +49,8 @@ record ImageCache(LoadingCache<String, Image> cache) implements Properties {
|
||||
return images.cache.get(path);
|
||||
}
|
||||
|
||||
private static Image loadImage(String path, Loader files) throws IOException {
|
||||
try {
|
||||
return new BufferedImageWrapper(ImageIO.read(files.get(path)));
|
||||
} catch(IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("Unable to load image (image might be too large?)", e);
|
||||
} catch(IOException e) {
|
||||
if(e instanceof FileNotFoundException) {
|
||||
// Rethrow using nicer message
|
||||
throw new IOException("Unable to load image: No such file or directory: " + path, e);
|
||||
}
|
||||
throw new IOException("Unable to load image", e);
|
||||
}
|
||||
private static Image loadImage(String path, Path directory) throws IOException {
|
||||
InputStream is = Files.newInputStream(directory.resolve(path));
|
||||
return new BufferedImageWrapper(ImageIO.read(is));
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -7,25 +7,22 @@ import java.io.IOException;
|
||||
|
||||
import com.dfsek.terra.addons.image.image.Image;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.Loader;
|
||||
|
||||
|
||||
public class ImageTemplate implements ObjectTemplate<Image> {
|
||||
|
||||
private final Loader files;
|
||||
private final ConfigPack pack;
|
||||
@Value("path")
|
||||
private String path;
|
||||
|
||||
public ImageTemplate(Loader files, ConfigPack pack) {
|
||||
this.files = files;
|
||||
public ImageTemplate(ConfigPack pack) {
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image get() {
|
||||
try {
|
||||
return ImageCache.load(path, pack, files);
|
||||
return ImageCache.load(path, pack);
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
+2
-5
@@ -11,12 +11,10 @@ import java.io.IOException;
|
||||
import com.dfsek.terra.addons.image.image.Image;
|
||||
import com.dfsek.terra.addons.image.image.StitchedImage;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.config.Loader;
|
||||
|
||||
|
||||
public class StitchedImageTemplate implements ObjectTemplate<Image>, ValidatedConfigTemplate {
|
||||
|
||||
private final Loader files;
|
||||
private final ConfigPack pack;
|
||||
@Value("path-format")
|
||||
private String path;
|
||||
@@ -28,8 +26,7 @@ public class StitchedImageTemplate implements ObjectTemplate<Image>, ValidatedCo
|
||||
@Default
|
||||
private boolean zeroIndexed = false;
|
||||
|
||||
public StitchedImageTemplate(Loader files, ConfigPack pack) {
|
||||
this.files = files;
|
||||
public StitchedImageTemplate(ConfigPack pack) {
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
@@ -39,7 +36,7 @@ public class StitchedImageTemplate implements ObjectTemplate<Image>, ValidatedCo
|
||||
for(int i = 0; i < rows; i++) {
|
||||
for(int j = 0; j < cols; j++) {
|
||||
try {
|
||||
grid[i][j] = ImageCache.load(getFormattedPath(i, j), pack, files);
|
||||
grid[i][j] = ImageCache.load(getFormattedPath(i, j), pack);
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
+6
-6
@@ -1,16 +1,16 @@
|
||||
package com.dfsek.terra.addons.image.config.noisesampler;
|
||||
package com.dfsek.terra.addons.image.config.sampler;
|
||||
|
||||
import com.dfsek.seismic.type.sampler.Sampler;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
|
||||
import com.dfsek.terra.addons.image.noisesampler.ChannelNoiseSampler;
|
||||
import com.dfsek.terra.addons.image.sampler.ChannelSampler;
|
||||
import com.dfsek.terra.addons.image.util.ColorUtil.Channel;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class ChannelNoiseSamplerTemplate implements ObjectTemplate<NoiseSampler> {
|
||||
public class ChannelSamplerTemplate implements ObjectTemplate<Sampler> {
|
||||
|
||||
@Value("color-sampler")
|
||||
private ColorSampler colorSampler;
|
||||
@@ -35,7 +35,7 @@ public class ChannelNoiseSamplerTemplate implements ObjectTemplate<NoiseSampler>
|
||||
private boolean premultiply = false;
|
||||
|
||||
@Override
|
||||
public NoiseSampler get() {
|
||||
return new ChannelNoiseSampler(colorSampler, channel, normalize, premultiply);
|
||||
public Sampler get() {
|
||||
return new ChannelSampler(colorSampler, channel, normalize, premultiply);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.addons.image.config.noisesampler;
|
||||
package com.dfsek.terra.addons.image.config.sampler;
|
||||
|
||||
import com.dfsek.seismic.type.sampler.Sampler;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
@@ -9,10 +10,9 @@ import com.dfsek.terra.addons.image.operator.DistanceTransform;
|
||||
import com.dfsek.terra.addons.image.operator.DistanceTransform.CostFunction;
|
||||
import com.dfsek.terra.addons.image.operator.DistanceTransform.Normalization;
|
||||
import com.dfsek.terra.addons.image.util.ColorUtil.Channel;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class DistanceTransformNoiseSamplerTemplate implements ObjectTemplate<NoiseSampler> {
|
||||
public class DistanceTransformSamplerTemplate implements ObjectTemplate<Sampler> {
|
||||
|
||||
@Value("image")
|
||||
private Image image;
|
||||
@@ -68,7 +68,7 @@ public class DistanceTransformNoiseSamplerTemplate implements ObjectTemplate<Noi
|
||||
private Normalization normalization = Normalization.None;
|
||||
|
||||
@Override
|
||||
public NoiseSampler get() {
|
||||
public Sampler get() {
|
||||
return new DistanceTransform.Noise(new DistanceTransform(image, channel, threshold, clampToEdge, costFunction, invertThreshold),
|
||||
normalization);
|
||||
}
|
||||
+8
-6
@@ -1,9 +1,11 @@
|
||||
package com.dfsek.terra.addons.image.operator;
|
||||
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
import com.dfsek.seismic.type.sampler.Sampler;
|
||||
|
||||
import com.dfsek.terra.addons.image.image.Image;
|
||||
import com.dfsek.terra.addons.image.util.ColorUtil;
|
||||
import com.dfsek.terra.addons.image.util.ColorUtil.Channel;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import static com.dfsek.terra.addons.image.util.MathUtil.lerp;
|
||||
|
||||
@@ -220,7 +222,7 @@ public class DistanceTransform {
|
||||
}
|
||||
|
||||
|
||||
public static class Noise implements NoiseSampler {
|
||||
public static class Noise implements Sampler {
|
||||
|
||||
private final DistanceTransform transform;
|
||||
|
||||
@@ -230,14 +232,14 @@ public class DistanceTransform {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(long seed, double x, double y) {
|
||||
public double getSample(long seed, double x, double y) {
|
||||
if(x < 0 || y < 0 || x >= transform.width || y >= transform.height) return transform.minDistance;
|
||||
return transform.distances[(int) Math.floor(x)][(int) Math.floor(y)];
|
||||
return transform.distances[FloatingPointFunctions.floor(x)][FloatingPointFunctions.floor(y)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
return noise(seed, x, z);
|
||||
public double getSample(long seed, double x, double y, double z) {
|
||||
return getSample(seed, x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -1,14 +1,15 @@
|
||||
package com.dfsek.terra.addons.image.noisesampler;
|
||||
package com.dfsek.terra.addons.image.sampler;
|
||||
|
||||
import com.dfsek.seismic.type.sampler.Sampler;
|
||||
|
||||
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
|
||||
import com.dfsek.terra.addons.image.util.ColorUtil;
|
||||
import com.dfsek.terra.addons.image.util.ColorUtil.Channel;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import static com.dfsek.terra.addons.image.util.MathUtil.lerp;
|
||||
|
||||
|
||||
public class ChannelNoiseSampler implements NoiseSampler {
|
||||
public class ChannelSampler implements Sampler {
|
||||
|
||||
private final ColorSampler colorSampler;
|
||||
|
||||
@@ -18,7 +19,7 @@ public class ChannelNoiseSampler implements NoiseSampler {
|
||||
|
||||
private final boolean premultiply;
|
||||
|
||||
public ChannelNoiseSampler(ColorSampler colorSampler, Channel channel, boolean normalize, boolean premultiply) {
|
||||
public ChannelSampler(ColorSampler colorSampler, Channel channel, boolean normalize, boolean premultiply) {
|
||||
this.colorSampler = colorSampler;
|
||||
this.channel = channel;
|
||||
this.normalize = normalize;
|
||||
@@ -26,7 +27,7 @@ public class ChannelNoiseSampler implements NoiseSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(long seed, double x, double y) {
|
||||
public double getSample(long seed, double x, double y) {
|
||||
int sample = colorSampler.apply((int) x, (int) y);
|
||||
int premultiplied = premultiply ? ColorUtil.premultiply(sample) : sample;
|
||||
double channelValue = channel.from(premultiplied);
|
||||
@@ -34,7 +35,7 @@ public class ChannelNoiseSampler implements NoiseSampler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(long seed, double x, double y, double z) {
|
||||
return noise(seed, x, z);
|
||||
public double getSample(long seed, double x, double y, double z) {
|
||||
return getSample(seed, x, z);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
schema-version: 1
|
||||
contributors:
|
||||
- Terra contributors
|
||||
id: library-image
|
||||
id: api-image
|
||||
version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.image.ImageLibraryAddon"
|
||||
@@ -1,6 +1,6 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:biome-query-api"))
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:api-biome-query"))
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,6 +46,6 @@ class BaseBiomeColumn implements Column<Biome> {
|
||||
|
||||
@Override
|
||||
public Biome get(int y) {
|
||||
return biomeProvider.extrude(base, x, y, z, seed);
|
||||
return biomeProvider.pipeline.extrude(base, x, y, z, seed);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-14
@@ -6,48 +6,45 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.addons.biome.extrusion.utils.ExtrusionPipeline;
|
||||
import com.dfsek.terra.addons.biome.extrusion.utils.ExtrusionPipelineFactory;
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.util.generic.data.types.Maybe;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class BiomeExtrusionProvider implements BiomeProvider {
|
||||
public final ExtrusionPipeline pipeline;
|
||||
private final BiomeProvider delegate;
|
||||
private final Set<Biome> biomes;
|
||||
private final List<Extrusion> extrusions;
|
||||
private final int resolution;
|
||||
|
||||
public BiomeExtrusionProvider(BiomeProvider delegate, List<Extrusion> extrusions, int resolution) {
|
||||
this.delegate = delegate;
|
||||
this.biomes = delegate.stream().collect(Collectors.toSet());
|
||||
extrusions.forEach(e -> biomes.addAll(e.getBiomes()));
|
||||
this.extrusions = extrusions;
|
||||
|
||||
this.pipeline = ExtrusionPipelineFactory.create(extrusions);
|
||||
|
||||
this.resolution = resolution;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int y, int z, long seed) {
|
||||
Biome delegated = delegate.getBiome(x, y, z, seed);
|
||||
|
||||
return extrude(delegated, x, y, z, seed);
|
||||
}
|
||||
|
||||
public Biome extrude(Biome original, int x, int y, int z, long seed) {
|
||||
for(Extrusion extrusion : extrusions) {
|
||||
original = extrusion.extrude(original, x, y, z, seed);
|
||||
}
|
||||
return original;
|
||||
return pipeline.extrude(delegated, x, y, z, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Column<Biome> getColumn(int x, int z, long seed, int min, int max) {
|
||||
return delegate.getBaseBiome(x, z, seed)
|
||||
.map(base -> (Column<Biome>) new BaseBiomeColumn(this, base, min, max, x, z, seed))
|
||||
.orElseGet(() -> BiomeProvider.super.getColumn(x, z, seed, min, max));
|
||||
.get(() -> BiomeProvider.super.getColumn(x, z, seed, min, max));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return delegate.getBaseBiome(x, z, seed);
|
||||
}
|
||||
|
||||
@@ -64,4 +61,4 @@ public class BiomeExtrusionProvider implements BiomeProvider {
|
||||
public BiomeProvider getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.api;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
public interface Extrusion {
|
||||
Biome extrude(Biome original, int x, int y, int z, long seed);
|
||||
|
||||
+1
-1
@@ -27,6 +27,6 @@ public class ReplaceableBiomeLoader implements TypeLoader<ReplaceableBiome> {
|
||||
return biomeRegistry
|
||||
.getByID((String) c)
|
||||
.map(ReplaceableBiome::of)
|
||||
.orElseThrow(() -> new LoadException("No such biome: " + c, depthTracker));
|
||||
.collectThrow(left -> new LoadException("No such biome: " + c + ": " + left, depthTracker));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,17 +1,17 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.config.extrusions;
|
||||
|
||||
import com.dfsek.seismic.type.sampler.Sampler;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.range.Range;
|
||||
|
||||
|
||||
public abstract class SamplerExtrusionTemplate implements ObjectTemplate<Extrusion> {
|
||||
@Value("sampler")
|
||||
protected @Meta NoiseSampler sampler;
|
||||
protected @Meta Sampler sampler;
|
||||
|
||||
@Value("range")
|
||||
protected @Meta Range range;
|
||||
|
||||
+27
-9
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.extrusions;
|
||||
|
||||
import com.dfsek.seismic.type.sampler.Sampler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -7,9 +9,9 @@ import java.util.stream.Collectors;
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.ReplaceableBiome;
|
||||
import com.dfsek.terra.addons.biome.query.api.BiomeQueries;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.collection.TriStateIntCache;
|
||||
import com.dfsek.terra.api.util.range.Range;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
@@ -17,26 +19,42 @@ import com.dfsek.terra.api.world.biome.Biome;
|
||||
* Sets biomes at locations based on a sampler.
|
||||
*/
|
||||
public class ReplaceExtrusion implements Extrusion {
|
||||
private final NoiseSampler sampler;
|
||||
|
||||
private final Sampler sampler;
|
||||
private final Range range;
|
||||
|
||||
private final ProbabilityCollection<ReplaceableBiome> biomes;
|
||||
|
||||
private final Predicate<Biome> hasTag;
|
||||
private final TriStateIntCache cache;
|
||||
|
||||
public ReplaceExtrusion(NoiseSampler sampler, Range range, ProbabilityCollection<ReplaceableBiome> biomes, String tag) {
|
||||
public ReplaceExtrusion(Sampler sampler, Range range, ProbabilityCollection<ReplaceableBiome> biomes, String tag) {
|
||||
this.sampler = sampler;
|
||||
this.range = range;
|
||||
this.biomes = biomes;
|
||||
this.hasTag = BiomeQueries.has(tag);
|
||||
this.cache = new TriStateIntCache(Biome.INT_ID_COUNTER.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome extrude(Biome original, int x, int y, int z, long seed) {
|
||||
if(hasTag.test(original)) {
|
||||
return range.ifInRange(y, () -> biomes.get(sampler, x, y, z, seed).get(original), original);
|
||||
int id = original.getIntID();
|
||||
|
||||
long state = cache.get(id);
|
||||
boolean passes;
|
||||
|
||||
if(state == TriStateIntCache.STATE_UNSET) {
|
||||
// Only run the test if unset in cache
|
||||
passes = hasTag.test(original);
|
||||
cache.set(id, passes);
|
||||
} else {
|
||||
// Read the primitive long directly
|
||||
passes = (state == TriStateIntCache.STATE_TRUE);
|
||||
}
|
||||
|
||||
if(passes) {
|
||||
if(range.isInRange(y)) {
|
||||
return biomes.get(sampler, x, y, z, seed).get(original);
|
||||
}
|
||||
}
|
||||
|
||||
return original;
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -1,14 +1,15 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.extrusions;
|
||||
|
||||
import com.dfsek.seismic.type.sampler.Sampler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.ReplaceableBiome;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.range.Range;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
@@ -16,13 +17,13 @@ import com.dfsek.terra.api.world.biome.Biome;
|
||||
* Sets biomes at locations based on a sampler.
|
||||
*/
|
||||
public class SetExtrusion implements Extrusion {
|
||||
private final NoiseSampler sampler;
|
||||
private final Sampler sampler;
|
||||
|
||||
private final Range range;
|
||||
|
||||
private final ProbabilityCollection<ReplaceableBiome> biomes;
|
||||
|
||||
public SetExtrusion(NoiseSampler sampler, Range range, ProbabilityCollection<ReplaceableBiome> biomes) {
|
||||
public SetExtrusion(Sampler sampler, Range range, ProbabilityCollection<ReplaceableBiome> biomes) {
|
||||
this.sampler = sampler;
|
||||
this.range = range;
|
||||
this.biomes = biomes;
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.utils;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
public interface ExtrusionPipeline {
|
||||
Biome extrude(Biome original, int x, int y, int z, long seed);
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.utils;
|
||||
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.FieldVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.AALOAD;
|
||||
import static org.objectweb.asm.Opcodes.ACC_FINAL;
|
||||
import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
|
||||
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||
import static org.objectweb.asm.Opcodes.ALOAD;
|
||||
import static org.objectweb.asm.Opcodes.ARETURN;
|
||||
import static org.objectweb.asm.Opcodes.GETFIELD;
|
||||
import static org.objectweb.asm.Opcodes.ILOAD;
|
||||
import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
|
||||
import static org.objectweb.asm.Opcodes.INVOKESPECIAL;
|
||||
import static org.objectweb.asm.Opcodes.LLOAD;
|
||||
import static org.objectweb.asm.Opcodes.PUTFIELD;
|
||||
import static org.objectweb.asm.Opcodes.RETURN;
|
||||
import static org.objectweb.asm.Opcodes.SIPUSH;
|
||||
import static org.objectweb.asm.Opcodes.SWAP;
|
||||
import static org.objectweb.asm.Opcodes.V1_8;
|
||||
|
||||
|
||||
public class ExtrusionPipelineFactory {
|
||||
private static final AtomicInteger ID_COUNTER = new AtomicInteger(0);
|
||||
|
||||
// Type Descriptors
|
||||
private static final String EXTRUSION_TYPE = Type.getInternalName(Extrusion.class);
|
||||
private static final String EXTRUSION_DESC = Type.getDescriptor(Extrusion.class);
|
||||
private static final String BIOME_DESC = Type.getDescriptor(Biome.class);
|
||||
private static final String PIPELINE_INTERFACE = Type.getInternalName(ExtrusionPipeline.class);
|
||||
|
||||
// Method Signature: (Biome, int, int, int, long) -> Biome
|
||||
private static final String EXTRUDE_SIG = "(" + BIOME_DESC + "IIIJ)" + BIOME_DESC;
|
||||
|
||||
public static ExtrusionPipeline create(List<Extrusion> extrusions) {
|
||||
// Optimization: If empty, return identity
|
||||
if(extrusions.isEmpty()) {
|
||||
return (original, x, y, z, seed) -> original;
|
||||
}
|
||||
|
||||
String className = "com/dfsek/terra/addons/biome/extrusion/GeneratedExtrusionPipeline_" + ID_COUNTER.getAndIncrement();
|
||||
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
|
||||
// 1. Define Class
|
||||
cw.visit(V1_8, ACC_PUBLIC | ACC_FINAL, className, null, "java/lang/Object", new String[]{ PIPELINE_INTERFACE });
|
||||
|
||||
// 2. Define Fields (e0, e1, e2...)
|
||||
for(int i = 0; i < extrusions.size(); i++) {
|
||||
FieldVisitor fv = cw.visitField(ACC_PRIVATE | ACC_FINAL, "e" + i, EXTRUSION_DESC, null, null);
|
||||
fv.visitEnd();
|
||||
}
|
||||
|
||||
// 3. Generate Constructor(Extrusion[])
|
||||
generateConstructor(cw, className, extrusions.size());
|
||||
|
||||
// 4. Generate extrude() method
|
||||
generateExtrudeMethod(cw, className, extrusions.size());
|
||||
|
||||
cw.visitEnd();
|
||||
|
||||
// 5. Load and Instantiate
|
||||
byte[] bytecode = cw.toByteArray();
|
||||
try {
|
||||
Class<?> generatedClass = new PipelineClassLoader(ExtrusionPipelineFactory.class.getClassLoader())
|
||||
.defineClass(className.replace('/', '.'), bytecode);
|
||||
|
||||
return (ExtrusionPipeline) generatedClass.getConstructor(Extrusion[].class)
|
||||
.newInstance((Object) extrusions.toArray(new Extrusion[0]));
|
||||
} catch(Exception e) {
|
||||
throw new RuntimeException("Failed to generate ExtrusionPipeline", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateConstructor(ClassWriter cw, String className, int count) {
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "([L" + EXTRUSION_TYPE + ";)V", null, null);
|
||||
mv.visitCode();
|
||||
|
||||
// super()
|
||||
mv.visitVarInsn(ALOAD, 0);
|
||||
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
|
||||
|
||||
// Assign array elements to fields
|
||||
for(int i = 0; i < count; i++) {
|
||||
mv.visitVarInsn(ALOAD, 0); // Load this
|
||||
mv.visitVarInsn(ALOAD, 1); // Load array argument
|
||||
mv.visitIntInsn(SIPUSH, i); // Load index
|
||||
mv.visitInsn(AALOAD); // Load array[i]
|
||||
mv.visitFieldInsn(PUTFIELD, className, "e" + i, EXTRUSION_DESC);
|
||||
}
|
||||
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0, 0); // Computed automatically
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
private static void generateExtrudeMethod(ClassWriter cw, String className, int count) {
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "extrude", EXTRUDE_SIG, null, null);
|
||||
mv.visitCode();
|
||||
|
||||
// Helper var indices:
|
||||
// 0: this
|
||||
// 1: Biome original (We will update this or chain it on stack)
|
||||
// 2: int x
|
||||
// 3: int y
|
||||
// 4: int z
|
||||
// 5: long seed
|
||||
|
||||
mv.visitVarInsn(ALOAD, 1); // Load 'original' Biome onto stack initially
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
// Stack contains: [CurrentBiome]
|
||||
|
||||
mv.visitVarInsn(ALOAD, 0); // Load 'this'
|
||||
mv.visitFieldInsn(GETFIELD, className, "e" + i, EXTRUSION_DESC); // Load Extrusion field
|
||||
|
||||
// Stack: [CurrentBiome, Extrusion]
|
||||
// We need: [Extrusion, CurrentBiome, x, y, z, seed]
|
||||
|
||||
mv.visitInsn(SWAP); // Swap to get [Extrusion, CurrentBiome]
|
||||
|
||||
mv.visitVarInsn(ILOAD, 2); // x
|
||||
mv.visitVarInsn(ILOAD, 3); // y
|
||||
mv.visitVarInsn(ILOAD, 4); // z
|
||||
mv.visitVarInsn(LLOAD, 5); // seed
|
||||
|
||||
// Invoke Extrusion.extrude(Biome, x, y, z, seed)
|
||||
mv.visitMethodInsn(INVOKEINTERFACE, EXTRUSION_TYPE, "extrude", EXTRUDE_SIG, true);
|
||||
|
||||
// Stack now contains: [NewBiome]
|
||||
// Loop continues using this result as input for the next one
|
||||
}
|
||||
|
||||
mv.visitInsn(ARETURN); // Return the final Biome
|
||||
mv.visitMaxs(0, 0);
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
// Custom ClassLoader to inject the bytes
|
||||
private static class PipelineClassLoader extends ClassLoader {
|
||||
public PipelineClassLoader(ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
public Class<?> defineClass(String name, byte[] b) {
|
||||
return defineClass(name, b, 0, b.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,4 @@ website:
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
biome-query-api: "1.+"
|
||||
api-biome-query: "1.+"
|
||||
@@ -1,5 +0,0 @@
|
||||
# biome-provider-image-v2
|
||||
|
||||
Implements and registers the `IMAGE` biome provider, which
|
||||
utilizes various config types provided by the `library-image` addon to
|
||||
distribute biomes based on images.
|
||||
@@ -1,8 +0,0 @@
|
||||
version = version("1.0.1")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:library-image"))
|
||||
|
||||
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2025 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.biome.image.v2;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
|
||||
import com.dfsek.terra.addons.image.converter.ColorConverter;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class ImageBiomeProvider implements BiomeProvider {
|
||||
private final int resolution;
|
||||
|
||||
private final ColorConverter<Biome> colorConverter;
|
||||
|
||||
private final ColorSampler colorSampler;
|
||||
|
||||
public ImageBiomeProvider(ColorConverter<Biome> colorConverter, ColorSampler colorSampler, int resolution) {
|
||||
this.resolution = resolution;
|
||||
this.colorConverter = colorConverter;
|
||||
this.colorSampler = colorSampler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int y, int z, long seed) {
|
||||
return getBiome(x, z);
|
||||
}
|
||||
|
||||
public Biome getBiome(int x, int z) {
|
||||
x /= resolution;
|
||||
z /= resolution;
|
||||
return colorConverter.apply(colorSampler.apply(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Optional.of(getBiome(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Biome> getBiomes() {
|
||||
return colorConverter.getEntries();
|
||||
}
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2025 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.biome.image.v2;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.biome.image.v2.config.ImageProviderTemplate;
|
||||
import com.dfsek.terra.addons.biome.image.v2.config.converter.ClosestBiomeColorConverterTemplate;
|
||||
import com.dfsek.terra.addons.biome.image.v2.config.converter.ExactBiomeColorConverterTemplate;
|
||||
import com.dfsek.terra.addons.biome.image.v2.config.converter.mapping.DefinedBiomeColorMappingTemplate;
|
||||
import com.dfsek.terra.addons.image.converter.ColorConverter;
|
||||
import com.dfsek.terra.addons.image.converter.mapping.BiomeDefinedColorMapping;
|
||||
import com.dfsek.terra.addons.image.converter.mapping.ColorMapping;
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class ImageBiomeProviderAddon implements AddonInitializer {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<BiomeProvider>>> PROVIDER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
public static final TypeKey<Supplier<ObjectTemplate<ColorConverter<Biome>>>> BIOME_COLOR_CONVERTER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
public static final TypeKey<Supplier<ObjectTemplate<ColorMapping<Biome>>>> BIOME_COLOR_MAPPING_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
@Inject
|
||||
private BaseAddon addon;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.priority(501)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(
|
||||
PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register(addon.key("IMAGE"), ImageProviderTemplate::new);
|
||||
})
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<ColorConverter<Biome>>>> biomeColorConverterRegistry =
|
||||
event.getPack().getOrCreateRegistry(
|
||||
BIOME_COLOR_CONVERTER_REGISTRY_KEY);
|
||||
biomeColorConverterRegistry.register(addon.key("EXACT"), ExactBiomeColorConverterTemplate::new);
|
||||
biomeColorConverterRegistry.register(addon.key("CLOSEST"), ClosestBiomeColorConverterTemplate::new);
|
||||
})
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<ColorMapping<Biome>>>> biomeColorMappingRegistry =
|
||||
event.getPack().getOrCreateRegistry(
|
||||
BIOME_COLOR_MAPPING_REGISTRY_KEY);
|
||||
biomeColorMappingRegistry.register(addon.key("USE_BIOME_COLORS"),
|
||||
() -> () -> new BiomeDefinedColorMapping<>(event.getPack().getRegistry(Biome.class),
|
||||
b -> b));
|
||||
biomeColorMappingRegistry.register(addon.key("MAP"), DefinedBiomeColorMappingTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
# biome-provider-image
|
||||
# biome-provider-image-v2
|
||||
|
||||
Implements and registers the `IMAGE` biome provider, a biome provider which
|
||||
generates biomes from an image, using the `color` attribute of biomes.
|
||||
|
||||
This addon registers the provider type, and all associated config options.
|
||||
Implements and registers the `IMAGE` biome provider, which
|
||||
utilizes various config types provided by the `api-image` addon to
|
||||
distribute biomes based on images.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
version = version("1.0.1")
|
||||
version = version("2.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:addon-loader-manifest"))
|
||||
compileOnlyApi(project(":common:addons:api-image"))
|
||||
|
||||
|
||||
}
|
||||
|
||||
+14
-46
@@ -7,32 +7,26 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.image;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
|
||||
import com.dfsek.terra.addons.image.converter.ColorConverter;
|
||||
import com.dfsek.terra.api.util.generic.data.types.Maybe;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class ImageBiomeProvider implements BiomeProvider {
|
||||
private final Map<Color, Biome> colorBiomeMap = new HashMap<>();
|
||||
private final BufferedImage image;
|
||||
private final int resolution;
|
||||
private final Align align;
|
||||
|
||||
public ImageBiomeProvider(Set<Biome> registry, BufferedImage image, int resolution, Align align) {
|
||||
this.image = image;
|
||||
private final ColorConverter<Biome> colorConverter;
|
||||
|
||||
private final ColorSampler colorSampler;
|
||||
|
||||
public ImageBiomeProvider(ColorConverter<Biome> colorConverter, ColorSampler colorSampler, int resolution) {
|
||||
this.resolution = resolution;
|
||||
this.align = align;
|
||||
registry.forEach(biome -> colorBiomeMap.put(new Color(biome.getColor()), biome));
|
||||
}
|
||||
|
||||
private static int distance(Color a, Color b) {
|
||||
return Math.abs(a.getRed() - b.getRed()) + Math.abs(a.getGreen() - b.getGreen()) + Math.abs(a.getBlue() - b.getBlue());
|
||||
this.colorConverter = colorConverter;
|
||||
this.colorSampler = colorSampler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,42 +37,16 @@ public class ImageBiomeProvider implements BiomeProvider {
|
||||
public Biome getBiome(int x, int z) {
|
||||
x /= resolution;
|
||||
z /= resolution;
|
||||
Color color = align.getColor(image, x, z);
|
||||
return colorBiomeMap.get(colorBiomeMap.keySet()
|
||||
.stream()
|
||||
.reduce(colorBiomeMap.keySet().stream().findAny().orElseThrow(IllegalStateException::new),
|
||||
(running, element) -> {
|
||||
int d1 = distance(color, running);
|
||||
int d2 = distance(color, element);
|
||||
return d1 < d2 ? running : element;
|
||||
}));
|
||||
return colorConverter.apply(colorSampler.apply(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Optional.of(getBiome(x, z));
|
||||
public Maybe<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Maybe.just(getBiome(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Biome> getBiomes() {
|
||||
return colorBiomeMap.values();
|
||||
}
|
||||
|
||||
public enum Align {
|
||||
CENTER {
|
||||
@Override
|
||||
public Color getColor(BufferedImage image, int x, int z) {
|
||||
return new Color(image.getRGB(Math.floorMod(x - image.getWidth() / 2, image.getWidth()),
|
||||
Math.floorMod(z - image.getHeight() / 2, image.getHeight())));
|
||||
}
|
||||
},
|
||||
NONE {
|
||||
@Override
|
||||
public Color getColor(BufferedImage image, int x, int z) {
|
||||
return new Color(image.getRGB(Math.floorMod(x, image.getWidth()), Math.floorMod(z, image.getHeight())));
|
||||
}
|
||||
};
|
||||
|
||||
public abstract Color getColor(BufferedImage image, int x, int z);
|
||||
return colorConverter.getEntries();
|
||||
}
|
||||
}
|
||||
|
||||
+32
-10
@@ -8,11 +8,16 @@
|
||||
package com.dfsek.terra.addons.biome.image;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.biome.image.config.ImageProviderTemplate;
|
||||
import com.dfsek.terra.addons.biome.image.config.converter.ClosestBiomeColorConverterTemplate;
|
||||
import com.dfsek.terra.addons.biome.image.config.converter.ExactBiomeColorConverterTemplate;
|
||||
import com.dfsek.terra.addons.biome.image.config.converter.mapping.DefinedBiomeColorMappingTemplate;
|
||||
import com.dfsek.terra.addons.image.converter.ColorConverter;
|
||||
import com.dfsek.terra.addons.image.converter.mapping.BiomeDefinedColorMapping;
|
||||
import com.dfsek.terra.addons.image.converter.mapping.ColorMapping;
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
@@ -26,10 +31,15 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class ImageBiomeProviderAddon implements AddonInitializer {
|
||||
|
||||
public static final TypeKey<Supplier<ObjectTemplate<BiomeProvider>>> PROVIDER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
private static final Logger logger = LoggerFactory.getLogger(ImageBiomeProviderAddon.class);
|
||||
|
||||
public static final TypeKey<Supplier<ObjectTemplate<ColorConverter<Biome>>>> BIOME_COLOR_CONVERTER_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
public static final TypeKey<Supplier<ObjectTemplate<ColorMapping<Biome>>>> BIOME_COLOR_MAPPING_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
@@ -41,16 +51,28 @@ public class ImageBiomeProviderAddon implements AddonInitializer {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.priority(501)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry = event.getPack().getOrCreateRegistry(
|
||||
PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register(addon.key("IMAGE"),
|
||||
() -> new ImageProviderTemplate(event.getPack().getRegistry(Biome.class)));
|
||||
providerRegistry.register(addon.key("IMAGE"), ImageProviderTemplate::new);
|
||||
})
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<ColorConverter<Biome>>>> biomeColorConverterRegistry =
|
||||
event.getPack().getOrCreateRegistry(
|
||||
BIOME_COLOR_CONVERTER_REGISTRY_KEY);
|
||||
biomeColorConverterRegistry.register(addon.key("EXACT"), ExactBiomeColorConverterTemplate::new);
|
||||
biomeColorConverterRegistry.register(addon.key("CLOSEST"), ClosestBiomeColorConverterTemplate::new);
|
||||
})
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<ColorMapping<Biome>>>> biomeColorMappingRegistry =
|
||||
event.getPack().getOrCreateRegistry(
|
||||
BIOME_COLOR_MAPPING_REGISTRY_KEY);
|
||||
biomeColorMappingRegistry.register(addon.key("USE_BIOME_COLORS"),
|
||||
() -> () -> new BiomeDefinedColorMapping<>(event.getPack().getRegistry(Biome.class),
|
||||
b -> b));
|
||||
biomeColorMappingRegistry.register(addon.key("MAP"), DefinedBiomeColorMappingTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
if(platform.getTerraConfig().isDebugLog())
|
||||
logger.warn(
|
||||
"The biome-provider-image addon is deprecated and scheduled for removal in Terra 7.0. It is recommended to use the " +
|
||||
"biome-provider-image-v2 addon for future pack development instead.");
|
||||
}
|
||||
}
|
||||
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2025 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.biome.image;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Description;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class ImageProviderTemplate implements ObjectTemplate<BiomeProvider> {
|
||||
private final Registry<Biome> biomes;
|
||||
@Value("resolution")
|
||||
@Default
|
||||
@Description("Sets the resolution at which to sample the image.")
|
||||
private int resolution = 1;
|
||||
@Value("image.name")
|
||||
@Description("Sets the location of the image on the filesystem, relative to the pack root.")
|
||||
private BufferedImage image;
|
||||
@Value("image.align")
|
||||
@Description("Sets the alignment style to use for the image.")
|
||||
private ImageBiomeProvider.Align align;
|
||||
|
||||
public ImageProviderTemplate(Registry<Biome> set) {
|
||||
this.biomes = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider get() {
|
||||
return new ImageBiomeProvider(new HashSet<>(biomes.entries()), image, resolution, align);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -5,14 +5,14 @@
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.biome.image.v2.config;
|
||||
package com.dfsek.terra.addons.biome.image.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Description;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.biome.image.v2.ImageBiomeProvider;
|
||||
import com.dfsek.terra.addons.biome.image.ImageBiomeProvider;
|
||||
import com.dfsek.terra.addons.image.colorsampler.ColorSampler;
|
||||
import com.dfsek.terra.addons.image.converter.ColorConverter;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.addons.biome.image.v2.config.converter;
|
||||
package com.dfsek.terra.addons.biome.image.config.converter;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.addons.biome.image.v2.config.converter;
|
||||
package com.dfsek.terra.addons.biome.image.config.converter;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.addons.biome.image.v2.config.converter.mapping;
|
||||
package com.dfsek.terra.addons.biome.image.config.converter.mapping;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user