mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-05-20 16:50:28 +00:00
Compare commits
412 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 75a2dd7b6e | |||
| 3cec404c6b | |||
| b3a8f375bc | |||
| dc5e71e3de | |||
| 1d5abbcb6b | |||
| a1acfef721 | |||
| 7bef490125 | |||
| 8a2c54c85b | |||
| ef4a28fd23 | |||
| 10d44ce217 | |||
| 36ceabd749 | |||
| 29e1d05c71 | |||
| f92ecb31a7 | |||
| b7343ca327 | |||
| b6d8453042 | |||
| 0ee359b0a3 | |||
| 60046c4664 | |||
| b31f917acf | |||
| 639fc71f7a | |||
| 8d19368999 | |||
| 19e46fbe4c | |||
| d280e113e6 | |||
| 0e9f9bd2b0 | |||
| 7e883ab5ce | |||
| 892ba38fec | |||
| 5da26e2b53 | |||
| 2edf365781 | |||
| 82920e570f | |||
| f5da9d1dfb | |||
| cdb957403e | |||
| 21d8be4726 | |||
| 7a4bf38cbc | |||
| 18de2c3f99 | |||
| d7be33fa55 | |||
| ca791026bd | |||
| e21bb5c26d | |||
| 71aa42011f | |||
| b0bf9d042e | |||
| dbd5edabae | |||
| 4487be03f1 | |||
| 3610230c71 | |||
| 6e6a378225 | |||
| b05852e074 | |||
| cffdf7aeeb | |||
| e4d05312aa | |||
| 0997326aef | |||
| 3139416b35 | |||
| 42cf7b9543 | |||
| 2ae4f80351 | |||
| 3b156586dc | |||
| 6ba4a48e29 | |||
| 7c2908e5ca | |||
| 2a24fa56d7 | |||
| 2a6d130d20 | |||
| 1a1000bbef | |||
| e1cbb29ae4 | |||
| 37c358e3d1 | |||
| 32b2f15f3b | |||
| 752f57bbea | |||
| e2bb2d8712 | |||
| aeb2da4ede | |||
| 0c02e4cb9a | |||
| 546431bbef | |||
| 111eb6b593 | |||
| 7c2982aa0a | |||
| e1656bac20 | |||
| a0225d6ece | |||
| 13497a02a4 | |||
| c120ab76d0 | |||
| a47541cfeb | |||
| 14273268c8 | |||
| cce9b69c45 | |||
| e85afd7dd6 | |||
| f3329bbff1 | |||
| c6428cff66 | |||
| cb4c8f28ef | |||
| 0829960232 | |||
| 924783adb2 | |||
| 86d34347db | |||
| ccb8adec10 | |||
| 98a9035ae8 | |||
| 536733911b | |||
| 865ec58d70 | |||
| 33ca98ccaf | |||
| 41fc28e1e9 | |||
| abca785b1e | |||
| 92d173cb89 | |||
| dff2388b37 | |||
| 2f2fb54dea | |||
| 2daac81565 | |||
| 901b58f56a | |||
| 3000547ee9 | |||
| 15fec550c7 | |||
| c49202017f | |||
| 78d34498d9 | |||
| 8a2024e8d8 | |||
| 7de66fecf8 | |||
| 642372eaa1 | |||
| 6a95810e65 | |||
| 4c6c284b93 | |||
| 1d8c012ae5 | |||
| 522d4e4d3a | |||
| 915dcf9b9b | |||
| 4dd43ea86d | |||
| 21ec335db9 | |||
| 46c03438b3 | |||
| 9ced14b813 | |||
| d2055d60fd | |||
| 529cd463de | |||
| ab78bea9aa | |||
| 5df016e43e | |||
| cacfd66cf7 | |||
| fce8c823be | |||
| 036a166909 | |||
| 36682bc04c | |||
| 7574c356a0 | |||
| e1ce5e117c | |||
| ef0692977c | |||
| cfdce200dd | |||
| 727f7ce2fb | |||
| bcae15225f | |||
| baccd04c8d | |||
| 34b1aca556 | |||
| ba179c0991 | |||
| 01ba75a29b | |||
| c96e908a1e | |||
| 355805347b | |||
| e13f8163a2 | |||
| 099d5f60c8 | |||
| 80583e1596 | |||
| c83924a7a4 | |||
| 9081f3a004 | |||
| cfeeb432ea | |||
| c31925f383 | |||
| 72ad5b65df | |||
| b7c381b0f9 | |||
| 7b23aa796f | |||
| 2c44857575 | |||
| 2001b4c6f8 | |||
| d73872a1c6 | |||
| 23a35f8097 | |||
| df4636428c | |||
| 589e46477e | |||
| 11cf4c3a95 | |||
| 7d92d273cf | |||
| e5fa4fd1f1 | |||
| 8c9afc4592 | |||
| 3122962dc1 | |||
| 14e035bf2e | |||
| b2cc0d48aa | |||
| 613b96288a | |||
| 8b12dda604 | |||
| 61a40b4825 | |||
| eac8d3b4e8 | |||
| 5799b81414 | |||
| 1aa73bf742 | |||
| 9f6dcfd71b | |||
| d80d653d3a | |||
| 4f92205085 | |||
| b62c4d742f | |||
| 012209cfcf | |||
| 4d6d14a3d8 | |||
| 7f05933a1a | |||
| 29d8e7eed4 | |||
| 3cf680ab88 | |||
| 9abac34b83 | |||
| a94c0adeb5 | |||
| e2088bbbb8 | |||
| 1d7ddc2844 | |||
| 443b372736 | |||
| 170b3d95ea | |||
| ee88f9e75f | |||
| fbc1a38a8d | |||
| d333b186b1 | |||
| 2363ad8c6c | |||
| 55686e2704 | |||
| 5a445fefac | |||
| 2c85284cfb | |||
| 0c2a8c6bbc | |||
| b3efaa4f6a | |||
| 69b994df0d | |||
| 2141e7489e | |||
| f4f0dca3bd | |||
| 9d6ad582d8 | |||
| 0aadfdb356 | |||
| 7d6746ad47 | |||
| 5409725709 | |||
| 779834267e | |||
| a33982a432 | |||
| 881477c42f | |||
| d58eb699f1 | |||
| 1aa0c715b9 | |||
| db61729e11 | |||
| dbadef5672 | |||
| aac16414d9 | |||
| 47d2b66046 | |||
| e2ba671626 | |||
| 0cb29e471e | |||
| ad5435f69d | |||
| c9221ca64c | |||
| e5f0e64cf3 | |||
| 2c5567296d | |||
| 2da54b9843 | |||
| 8126f3c2be | |||
| 3b2f2ab679 | |||
| ee6ecb9613 | |||
| 12d51e3f27 | |||
| d71b1ca984 | |||
| 37d98df8c3 | |||
| 132a200e43 | |||
| aa5947a9bd | |||
| deb6de3d6c | |||
| b148401f0f | |||
| 33a39cb237 | |||
| 8f5d2c80f4 | |||
| 50f895c8f4 | |||
| dad0a0bd29 | |||
| 4a3f21f8f7 | |||
| 47d2ec6bb0 | |||
| 0e815500d0 | |||
| 6d2a634686 | |||
| 158adb55af | |||
| dc80fc1ffb | |||
| 09e7d58eaf | |||
| cc9f9cc8d8 | |||
| 7ce8dfbc65 | |||
| d95e998e5d | |||
| 81023e1d67 | |||
| 6434b6b213 | |||
| 20c7f2f1fb | |||
| e5e926cf10 | |||
| 544b3767d2 | |||
| 876e4b86ae | |||
| 089710247b | |||
| 0797c113a6 | |||
| 1e3cb91ed2 | |||
| dcc6f025a6 | |||
| f23e7f29fd | |||
| 3c94b5960d | |||
| 245acde336 | |||
| 53df9a47fc | |||
| f036bddf9e | |||
| 3d4e2e4263 | |||
| 111470c9f4 | |||
| 8a1d329fd9 | |||
| 2307138fa8 | |||
| 84cb428b6c | |||
| c46f84a00e | |||
| d93f11b5f2 | |||
| 6f41d16408 | |||
| 0feae25be5 | |||
| d0069ffe83 | |||
| cec83aeb78 | |||
| c468054bbe | |||
| 372931a9c5 | |||
| 9a640de8d3 | |||
| f4968e1509 | |||
| 1858bab210 | |||
| c811fd31b1 | |||
| 098cb740dd | |||
| 9ac63ce469 | |||
| db0067a6d9 | |||
| 5de8df188a | |||
| fa66bd3c42 | |||
| e89d473669 | |||
| 90f3138395 | |||
| 4e789479e4 | |||
| 3fbb93d157 | |||
| 90a48345c2 | |||
| 7c00cad4c9 | |||
| 963e070f92 | |||
| 908a5dc309 | |||
| 3adcdb4019 | |||
| fbbf09a937 | |||
| 254bc93f93 | |||
| ed7bfd2d68 | |||
| 76e8c2d2b1 | |||
| b0aca47e74 | |||
| 5d703327db | |||
| 5ebe09444b | |||
| 136ceddff5 | |||
| b4bee3a65d | |||
| f870dab568 | |||
| 7027574d35 | |||
| c55c19a32e | |||
| f05e4c1852 | |||
| 1eb2d5c3ac | |||
| 3b98f8c0ab | |||
| 229886d84c | |||
| c1dc637eb2 | |||
| a5db29f2ad | |||
| 20e6b8bb63 | |||
| c7f6e34647 | |||
| dc59bb5d2e | |||
| 64f66474b1 | |||
| d4abedaa05 | |||
| 6e18978586 | |||
| 5b2e8b7fbd | |||
| 2608e94980 | |||
| 1d469687cb | |||
| a9248435a2 | |||
| b4cdb7f16c | |||
| 675a4465d7 | |||
| 839013d89a | |||
| 8e933a1bb4 | |||
| 10308959a1 | |||
| 68ac277471 | |||
| b93ff99b2e | |||
| 285367f616 | |||
| e3dd42c856 | |||
| a54b48f68a | |||
| de2d37cdf5 | |||
| 75b72a500d | |||
| 7da0580eda | |||
| 6883151809 | |||
| 00e9ab4263 | |||
| 2acfada4f8 | |||
| d07f9fe341 | |||
| 9c9487ced6 | |||
| 9d131a8992 | |||
| cd57a32f31 | |||
| 4c2ece3eb7 | |||
| 59318d75fc | |||
| d9eef2e5d5 | |||
| 2f189d94ac | |||
| 223db88462 | |||
| f2d9511f01 | |||
| ef1f1c0af0 | |||
| da28244f81 | |||
| 77ba13ce93 | |||
| eb8bafe5d8 | |||
| 411ef10c0c | |||
| 01d4174092 | |||
| d072e72590 | |||
| 38e4e9bc94 | |||
| 126ddaf9c7 | |||
| 4bf5be5734 | |||
| c8a4f8be6a | |||
| 049c5cc83a | |||
| ef1f2e882d | |||
| e94d90050a | |||
| 8977e82b73 | |||
| dfff178bfe | |||
| 4f00dadc22 | |||
| 7b439f005e | |||
| 5c165cd40d | |||
| 43a84cca3d | |||
| a4d87a428c | |||
| 414c0b8a38 | |||
| a11e02a84a | |||
| 1a08414822 | |||
| 0b6b66b7e6 | |||
| 278ab648dd | |||
| fe101f1221 | |||
| b6b6cb185d | |||
| ee373bbe4b | |||
| 49857f6b91 | |||
| 8655f7811a | |||
| ce47cd9316 | |||
| c4c71ac9ef | |||
| eaebc445f6 | |||
| 3ec15960cf | |||
| 5275c40c6a | |||
| 68ef5a5a32 | |||
| 63bfa6bf14 | |||
| bce25b8702 | |||
| c88fbc0321 | |||
| 0d1e7fd686 | |||
| bd2ec52832 | |||
| c3b9902c5f | |||
| 69a5cfecd1 | |||
| 304ae3075b | |||
| 0550f36447 | |||
| b82e84d447 | |||
| 7a59aeb80c | |||
| 0228facd71 | |||
| af90088505 | |||
| 2ddf620fb8 | |||
| 0c3d4f4f4e | |||
| e339b26657 | |||
| cee42ac467 | |||
| a2b061ce0d | |||
| 7d2c2bb141 | |||
| 8cd31ead99 | |||
| 3a8fb37cd6 | |||
| 2abf809d0f | |||
| cc9c7870ba | |||
| 2fe04d7f6b | |||
| 977316c57f | |||
| d2c5f711ef | |||
| b8baa05922 | |||
| 98b332fe54 | |||
| 6e61154cc5 | |||
| 0a5450a345 | |||
| 83baf377e0 | |||
| ffc884384c | |||
| 0c302456a2 | |||
| 41e7ad35bd | |||
| 82b474ead2 | |||
| d544e16885 | |||
| 4396623420 | |||
| d2795bfdb6 | |||
| 42fb3642f9 | |||
| e445fd986d | |||
| d7bb818f51 | |||
| eef0e04682 | |||
| 9c857bf86b | |||
| d440dacf30 | |||
| ffbc253477 | |||
| b4ed874043 | |||
| f1845b1ecd | |||
| f2946d85aa |
@@ -21,8 +21,8 @@ assignees: ""
|
||||
- You must be on the LATEST version of Terra to receive any support. There is no support for older versions of Terra.
|
||||
- Make sure that this is not a *specific* compatibility issue with another terrain generation mod.
|
||||
Do not request *specific* compatibility with mods or plugins (e.g. "Compatibility with TechCraft v7").
|
||||
That should be implemented in an addon, **not** in the platform project.
|
||||
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from parent biomes") will be considered in the platform project.
|
||||
That should be implemented in an addon, **not** in the main project.
|
||||
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from parent biomes") will be considered in the main project.
|
||||
- Make sure that there are no already existing issues open with your problem. If you open a duplicate, it will be closed as such.
|
||||
- Make sure that it is actually Terra causing the issue, and not another mod/plugin.
|
||||
You can do this by testing to see if you can recreate the issue without Terra installed.
|
||||
|
||||
@@ -72,19 +72,15 @@
|
||||
|
||||
- [ ] Bug Fix <!-- Anything which fixes an issue in Terra. -->
|
||||
- [ ] Build system <!-- Anything which pretain to the build system. -->
|
||||
- [ ]
|
||||
Documentation <!-- Anything which adds or improves documentation for existing features. -->
|
||||
- [ ] Documentation <!-- Anything which adds or improves documentation for existing features. -->
|
||||
- [ ] New Feature <!-- Anything which adds new functionality to Terra. -->
|
||||
- [ ] Performance <!-- Anything which is imrpoves the performance of Terra. -->
|
||||
- [ ]
|
||||
Refactoring <!-- Anything which does not add any new code, only moves code around. -->
|
||||
- [ ]
|
||||
Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
|
||||
- [ ] Refactoring <!-- Anything which does not add any new code, only moves code around. -->
|
||||
- [ ] Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
|
||||
- [ ] Revert <!-- Anything which reverts previous commits. -->
|
||||
- [ ] Style <!-- Anything which updates style. -->
|
||||
- [ ] Tests <!-- Anything which adds or updates tests. -->
|
||||
- [ ]
|
||||
Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
|
||||
- [ ] Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
|
||||
|
||||
#### Compatiblity
|
||||
|
||||
@@ -119,4 +115,4 @@
|
||||
<!--
|
||||
If it only introduces small changes, you don't need to add tests.
|
||||
But if you add big changes, you should probably at least write *some* testing, where applicable.
|
||||
-->
|
||||
-->
|
||||
|
||||
+4
-1
@@ -245,4 +245,7 @@ nbdist/
|
||||
|
||||
/run/
|
||||
|
||||
**/testDir/
|
||||
**/testDir/
|
||||
|
||||
platforms/**/run/**
|
||||
|
||||
|
||||
+5
-2
@@ -63,7 +63,8 @@ to [Terra global moderation team](CODE_OF_CONDUCT.md#Reporting).
|
||||
|
||||
## I don't want to read this whole thing I just have a question!!!
|
||||
|
||||
> **Note:** Please don't file an issue to ask a question. You'll get faster results by using the resources below.
|
||||
> **Note:** Please don't file an issue to ask a question. You'll get faster
|
||||
> results by using the resources below.
|
||||
|
||||
We have an official discord server where you can request help from various users
|
||||
|
||||
@@ -103,7 +104,9 @@ you don't need to create one. When you are creating a bug report,
|
||||
please [include as many details as possible](#how-do-i-submit-a-good-bug-report)
|
||||
.
|
||||
|
||||
> **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one.
|
||||
> **Note:** If you find a **Closed** issue that seems like it is the same thing
|
||||
> that you're experiencing, open a new issue and include a link to the original
|
||||
> issue in the body of your new one.
|
||||
|
||||
#### Before Submitting A Bug Report
|
||||
|
||||
|
||||
+10
-6
@@ -1,8 +1,8 @@
|
||||
preRelease(true)
|
||||
|
||||
versionProjects(":common:api", version("6.0.0"))
|
||||
versionProjects(":common:implementation", version("6.0.0"))
|
||||
versionProjects(":platforms", version("6.0.0"))
|
||||
versionProjects(":common:api", version("6.2.0"))
|
||||
versionProjects(":common:implementation", version("6.2.0"))
|
||||
versionProjects(":platforms", version("6.2.0"))
|
||||
|
||||
|
||||
allprojects {
|
||||
@@ -39,14 +39,18 @@ allprojects {
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
forSubProjects(":platforms") {
|
||||
forImmediateSubProjects(":platforms") {
|
||||
configureDistribution()
|
||||
}
|
||||
forSubProjects(":common:addons") {
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
|
||||
tasks.named("build") {
|
||||
finalizedBy(tasks.named("shadowJar"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"compileOnly"(project(":common:api"))
|
||||
"shadedImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
"testImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
"testImplementation"(project(":common:api"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,16 +3,32 @@ plugins {
|
||||
kotlin("jvm") version embeddedKotlinVersion
|
||||
}
|
||||
|
||||
buildscript {
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
force("org.ow2.asm:asm:9.3") // TODO: remove when ShadowJar updates ASM version
|
||||
force("org.ow2.asm:asm-commons:9.3")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
|
||||
maven("https://repo.codemc.org/repository/maven-public") {
|
||||
name = "CodeMC"
|
||||
}
|
||||
maven("https://papermc.io/repo/repository/maven-public/") {
|
||||
name = "PaperMC"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:+")
|
||||
implementation("org.ow2.asm:asm:9.2")
|
||||
implementation("org.ow2.asm:asm-tree:9.2")
|
||||
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.3.5")
|
||||
|
||||
implementation("org.ow2.asm:asm:9.3")
|
||||
implementation("org.ow2.asm:asm-tree:9.3")
|
||||
implementation("com.dfsek.tectonic:common:4.2.0")
|
||||
implementation("org.yaml:snakeyaml:1.27")
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import java.io.File
|
||||
import java.util.function.Predicate
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.extra
|
||||
import kotlin.streams.asStream
|
||||
|
||||
@@ -12,31 +11,33 @@ import kotlin.streams.asStream
|
||||
* Configures a directory where addons will be put.
|
||||
*/
|
||||
fun Project.addonDir(dir: File, task: Task) {
|
||||
task.doFirst {
|
||||
dir.parentFile.mkdirs()
|
||||
matchingAddons(dir) {
|
||||
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
|
||||
}.forEach {
|
||||
println("Deleting old addon: " + it.absolutePath)
|
||||
it.delete()
|
||||
}
|
||||
forSubProjects(":common:addons") {
|
||||
val jar = if (tasks.findByName("shadowJar") != null) {
|
||||
(tasks.named("shadowJar").get() as ShadowJar)
|
||||
} else {
|
||||
(tasks.named("jar").get() as Jar)
|
||||
val moveAddons = tasks.register("moveAddons" + task.name) {
|
||||
dependsOn("compileAddons")
|
||||
doLast {
|
||||
dir.parentFile.mkdirs()
|
||||
matchingAddons(dir) {
|
||||
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
|
||||
}.forEach {
|
||||
println("Deleting old addon: " + it.absolutePath)
|
||||
it.delete()
|
||||
}
|
||||
forSubProjects(":common:addons") {
|
||||
val jar = tasks.named("shadowJar").get() as ShadowJar
|
||||
|
||||
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||
val target = File(dir, boot + jar.archiveFileName.get())
|
||||
|
||||
val base = "${jar.archiveBaseName.get()}-${version}"
|
||||
|
||||
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
|
||||
|
||||
jar.archiveFile.orNull?.asFile?.copyTo(target)
|
||||
}
|
||||
|
||||
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||
val target = File(dir, boot + jar.archiveFileName.get())
|
||||
|
||||
val base = "${jar.archiveBaseName.get()}-${version}"
|
||||
|
||||
println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")
|
||||
|
||||
jar.archiveFile.orNull?.asFile?.copyTo(target)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
task.dependsOn(moveAddons)
|
||||
}
|
||||
|
||||
fun matchingAddons(dir: File, matcher: Predicate<File>): Set<File> {
|
||||
|
||||
@@ -3,14 +3,16 @@ import org.gradle.kotlin.dsl.creating
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.getValue
|
||||
import org.gradle.kotlin.dsl.getting
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
|
||||
fun Project.configureDependencies() {
|
||||
val api by configurations.getting
|
||||
val implementation by configurations.getting
|
||||
val testImplementation by configurations.getting
|
||||
val compileOnly by configurations.getting
|
||||
|
||||
val api by configurations.getting
|
||||
val implementation by configurations.getting
|
||||
|
||||
val shaded by configurations.creating
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
@@ -28,9 +30,24 @@ fun Project.configureDependencies() {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { url = uri("https://maven.fabricmc.net/") }
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
|
||||
maven("https://maven.fabricmc.net/") {
|
||||
name = "FabricMC"
|
||||
}
|
||||
maven("https://repo.codemc.org/repository/maven-public") {
|
||||
name = "CodeMC"
|
||||
}
|
||||
maven("https://papermc.io/repo/repository/maven-public/") {
|
||||
name = "PaperMC"
|
||||
}
|
||||
maven("https://files.minecraftforge.net/maven/") {
|
||||
name = "Forge"
|
||||
}
|
||||
maven("https://maven.quiltmc.org/repository/release/") {
|
||||
name = "Quilt"
|
||||
}
|
||||
maven("https://jitpack.io") {
|
||||
name = "JitPack"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.FileWriter
|
||||
import java.net.URL
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardCopyOption
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.BasePluginExtension
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.extra
|
||||
@@ -18,6 +16,7 @@ import org.gradle.kotlin.dsl.named
|
||||
import org.yaml.snakeyaml.DumperOptions
|
||||
import org.yaml.snakeyaml.Yaml
|
||||
|
||||
|
||||
fun Project.configureDistribution() {
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
|
||||
@@ -30,50 +29,45 @@ fun Project.configureDistribution() {
|
||||
}
|
||||
}
|
||||
|
||||
val installAddons = tasks.create("installAddons") {
|
||||
group = "terra"
|
||||
val compileAddons = tasks.create("compileAddons") {
|
||||
forSubProjects(":common:addons") {
|
||||
afterEvaluate {
|
||||
dependsOn(getJarTask())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val installAddons = tasks.create("installAddons") {
|
||||
group = "terra"
|
||||
dependsOn(compileAddons)
|
||||
|
||||
doLast {
|
||||
// The addons are copied into a JAR because of a ShadowJar bug
|
||||
// which expands *all* JARs, even resource ones, into the fat JAR.
|
||||
// To get around this, we copy all addon JARs into a *new* JAR,
|
||||
// then, ShadowJar expands the newly created JAR, putting the original
|
||||
// JARs where they should go.
|
||||
//
|
||||
// https://github.com/johnrengelman/shadow/issues/111
|
||||
val dest = File(buildDir, "/resources/main/addons.jar")
|
||||
dest.parentFile.mkdirs()
|
||||
val dest = tasks.named<ShadowJar>("shadowJar").get().archiveFile.get().asFile.toPath()
|
||||
|
||||
val zip = ZipOutputStream(FileOutputStream(dest))
|
||||
|
||||
forSubProjects(":common:addons") {
|
||||
val jar = getJarTask()
|
||||
|
||||
println("Packaging addon ${jar.archiveFileName.get()} to ${dest.absolutePath}. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
|
||||
|
||||
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||
|
||||
val entry = ZipEntry("addons/$boot${jar.archiveFileName.get()}")
|
||||
zip.putNextEntry(entry)
|
||||
FileInputStream(jar.archiveFile.get().asFile).run {
|
||||
copyTo(zip)
|
||||
close()
|
||||
FileSystems.newFileSystem(dest, mapOf("create" to "false"), null).use { fs ->
|
||||
forSubProjects(":common:addons") {
|
||||
val jar = getJarTask()
|
||||
|
||||
println("Packaging addon ${jar.archiveFileName.get()} to $dest. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
|
||||
|
||||
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||
val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}")
|
||||
|
||||
if (!Files.exists(addonPath)) {
|
||||
Files.createDirectories(addonPath.parent)
|
||||
Files.createFile(addonPath)
|
||||
Files.copy(jar.archiveFile.get().asFile.toPath(), addonPath, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
|
||||
}
|
||||
zip.closeEntry()
|
||||
}
|
||||
zip.close()
|
||||
}
|
||||
}
|
||||
|
||||
val generateResourceManifest = tasks.create("generateResourceManifest") {
|
||||
group = "terra"
|
||||
dependsOn(downloadDefaultPacks)
|
||||
dependsOn(installAddons)
|
||||
doLast {
|
||||
val resources = HashMap<String, MutableList<String>>()
|
||||
val packsDir = File("${project.buildDir}/resources/main/packs/")
|
||||
@@ -118,18 +112,20 @@ fun Project.configureDistribution() {
|
||||
|
||||
tasks["processResources"].dependsOn(generateResourceManifest)
|
||||
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
// Tell shadow to download the packs
|
||||
dependsOn(downloadDefaultPacks)
|
||||
|
||||
configurations = listOf(project.configurations["shaded"])
|
||||
|
||||
archiveClassifier.set("shaded")
|
||||
setVersion(project.version)
|
||||
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
|
||||
relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm")
|
||||
relocate("com.dfsek.paralithic", "com.dfsek.terra.lib.paralithic")
|
||||
relocate("org.json", "com.dfsek.terra.lib.json")
|
||||
relocate("org.yaml", "com.dfsek.terra.lib.yaml")
|
||||
|
||||
finalizedBy(installAddons)
|
||||
}
|
||||
|
||||
configure<BasePluginExtension> {
|
||||
@@ -148,10 +144,4 @@ fun downloadPack(packUrl: URL, project: Project) {
|
||||
file.outputStream().write(packUrl.readBytes())
|
||||
}
|
||||
|
||||
fun Project.getJarTask(): Jar {
|
||||
return if (tasks.findByName("shadowJar") != null) {
|
||||
(tasks.named("shadowJar").get() as ShadowJar)
|
||||
} else {
|
||||
(tasks.named("jar").get() as Jar)
|
||||
}
|
||||
}
|
||||
fun Project.getJarTask() = tasks.named("shadowJar").get() as ShadowJar
|
||||
|
||||
@@ -29,6 +29,12 @@ fun Project.forSubProjects(project: String, action: Action<Project>) {
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.forImmediateSubProjects(project: String, action: Action<Project>) {
|
||||
project(project).childProjects.forEach {
|
||||
action.execute(it.value)
|
||||
}
|
||||
}
|
||||
|
||||
fun preRelease(preRelease: Boolean) {
|
||||
isPrerelease = preRelease
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
object Versions {
|
||||
object Libraries {
|
||||
const val tectonic = "4.2.0"
|
||||
const val paralithic = "0.6.0"
|
||||
const val paralithic = "0.7.0"
|
||||
const val strata = "1.1.1"
|
||||
|
||||
const val cloud = "1.6.2"
|
||||
const val cloud = "1.7.0"
|
||||
|
||||
const val slf4j = "1.7.36"
|
||||
const val log4j_slf4j_impl = "2.14.1"
|
||||
@@ -13,22 +13,45 @@ object Versions {
|
||||
const val apacheText = "1.9"
|
||||
const val jafama = "2.3.2"
|
||||
const val apacheIO = "2.6"
|
||||
const val asm = "9.2"
|
||||
const val fastutil = "8.5.6"
|
||||
}
|
||||
}
|
||||
|
||||
object Fabric {
|
||||
const val fabricLoader = "0.14.8"
|
||||
const val fabricAPI = "0.57.0+1.19"
|
||||
}
|
||||
|
||||
object Quilt {
|
||||
const val quiltLoader = "0.17.0"
|
||||
const val fabricApi = "2.0.0-beta.4+0.57.0-1.19"
|
||||
}
|
||||
|
||||
object Mod {
|
||||
const val mixin = "0.11.2+mixin.0.8.5"
|
||||
|
||||
const val minecraft = "1.19"
|
||||
const val yarn = "$minecraft+build.1"
|
||||
const val fabricLoader = "0.14.2"
|
||||
const val fabricAPI = "0.51.1+1.18.2"
|
||||
const val minecraft = "1.18.2"
|
||||
const val yarn = "$minecraft+build.3"
|
||||
const val permissionsAPI = "0.1-SNAPSHOT"
|
||||
|
||||
const val architecuryLoom = "0.12.0-SNAPSHOT"
|
||||
const val architecturyPlugin = "3.4-SNAPSHOT"
|
||||
|
||||
const val loomQuiltflower = "1.7.1"
|
||||
|
||||
const val lazyDfu = "0.1.2"
|
||||
}
|
||||
|
||||
object Forge {
|
||||
const val forge = "${Mod.minecraft}-41.0.63"
|
||||
const val burningwave = "12.53.0"
|
||||
}
|
||||
|
||||
object Bukkit {
|
||||
const val paper = "1.18-R0.1-SNAPSHOT"
|
||||
const val paper = "1.18.2-R0.1-SNAPSHOT"
|
||||
const val paperLib = "1.0.5"
|
||||
const val minecraft = "1.19"
|
||||
const val reflectionRemapper = "0.1.0-SNAPSHOT"
|
||||
}
|
||||
|
||||
object Sponge {
|
||||
@@ -36,4 +59,11 @@ object Versions {
|
||||
const val mixin = "0.8.2"
|
||||
const val minecraft = "1.17.1"
|
||||
}
|
||||
|
||||
object CLI {
|
||||
const val nbt = "6.1"
|
||||
const val logback = "1.2.9"
|
||||
const val commonsIO = "2.7"
|
||||
const val guava = "31.0.1-jre"
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.dfsek.terra.addon.loader;
|
||||
|
||||
import ca.solostudios.strata.version.Version;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
|
||||
|
||||
public class ApiAddon implements BaseAddon {
|
||||
private final Version version;
|
||||
private final String id;
|
||||
|
||||
public ApiAddon(Version version, String id) {
|
||||
this.version = version;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 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.addon.loader;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
|
||||
public class ApiAddonClassLoader extends URLClassLoader {
|
||||
static {
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
|
||||
public ApiAddonClassLoader(URL[] urls, ClassLoader parent) {
|
||||
super(urls, parent);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -14,6 +14,7 @@ import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
|
||||
|
||||
|
||||
@@ -21,7 +22,8 @@ public class ApiAddonLoader implements BootstrapBaseAddon<BaseAddon> {
|
||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||
|
||||
@Override
|
||||
public Iterable<BaseAddon> loadAddons(Path addonsFolder, ClassLoader parent) {
|
||||
public Iterable<BaseAddon> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:biome-query-api"))
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion;
|
||||
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
class BaseBiomeColumn implements Column<Biome> {
|
||||
private final BiomeExtrusionProvider biomeProvider;
|
||||
private final Biome base;
|
||||
private final int min;
|
||||
private final int max;
|
||||
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final long seed;
|
||||
|
||||
protected BaseBiomeColumn(BiomeExtrusionProvider biomeProvider, Biome base, int min, int max, int x, int z, long seed) {
|
||||
this.biomeProvider = biomeProvider;
|
||||
this.base = base;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinY() {
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome get(int y) {
|
||||
return biomeProvider.extrude(base, x, y, z, seed);
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.ReplaceableBiome;
|
||||
import com.dfsek.terra.addons.biome.extrusion.config.BiomeExtrusionTemplate;
|
||||
import com.dfsek.terra.addons.biome.extrusion.config.ReplaceableBiomeLoader;
|
||||
import com.dfsek.terra.addons.biome.extrusion.config.extrusions.ReplaceExtrusionTemplate;
|
||||
import com.dfsek.terra.addons.biome.extrusion.config.extrusions.SetExtrusionTemplate;
|
||||
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.ConfigPackPostLoadEvent;
|
||||
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.registry.Registry;
|
||||
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 BiomeExtrusionAddon implements AddonInitializer {
|
||||
public static final TypeKey<Supplier<ObjectTemplate<Extrusion>>> EXTRUSION_REGISTRY_KEY = new TypeKey<>() {
|
||||
};
|
||||
|
||||
public static final TypeKey<Supplier<ObjectTemplate<BiomeProvider>>> PROVIDER_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)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<BiomeProvider>>> providerRegistry =
|
||||
event.getPack()
|
||||
.getOrCreateRegistry(PROVIDER_REGISTRY_KEY);
|
||||
providerRegistry.register(addon.key("EXTRUSION"), BiomeExtrusionTemplate::new);
|
||||
})
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Extrusion>>> extrusionRegistry = event.getPack().getOrCreateRegistry(
|
||||
EXTRUSION_REGISTRY_KEY);
|
||||
extrusionRegistry.register(addon.key("SET"), SetExtrusionTemplate::new);
|
||||
extrusionRegistry.register(addon.key("REPLACE"), ReplaceExtrusionTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPostLoadEvent.class)
|
||||
.then(event -> {
|
||||
Registry<Biome> biomeRegistry = event.getPack().getRegistry(Biome.class);
|
||||
event.getPack().applyLoader(ReplaceableBiome.class, new ReplaceableBiomeLoader(biomeRegistry));
|
||||
});
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class BiomeExtrusionProvider implements BiomeProvider {
|
||||
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.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;
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return delegate.getBaseBiome(x, z, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Biome> getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resolution() {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
public BiomeProvider getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.api;
|
||||
|
||||
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);
|
||||
|
||||
Collection<Biome> getBiomes();
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.api;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
final class PresentBiome implements ReplaceableBiome {
|
||||
private final Biome biome;
|
||||
|
||||
PresentBiome(Biome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome get(Biome existing) {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelf() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.api;
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
/**
|
||||
* Basically just a specialised implementation of {@link Optional} for biomes where a biome may be a "self" reference.
|
||||
*/
|
||||
public sealed interface ReplaceableBiome permits PresentBiome, SelfBiome {
|
||||
static ReplaceableBiome of(Biome biome) {
|
||||
return new PresentBiome(biome);
|
||||
}
|
||||
|
||||
static ReplaceableBiome self() {
|
||||
return SelfBiome.INSTANCE;
|
||||
}
|
||||
|
||||
Biome get(Biome existing);
|
||||
|
||||
default Biome get() {
|
||||
if(isSelf()) {
|
||||
throw new IllegalStateException("Cannot get() self biome!");
|
||||
}
|
||||
return get(null);
|
||||
}
|
||||
|
||||
boolean isSelf();
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.api;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
final class SelfBiome implements ReplaceableBiome {
|
||||
public static final SelfBiome INSTANCE = new SelfBiome();
|
||||
|
||||
@Override
|
||||
public Biome get(Biome existing) {
|
||||
return Objects.requireNonNull(existing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelf() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.config;
|
||||
|
||||
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 java.util.List;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.BiomeExtrusionProvider;
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class BiomeExtrusionTemplate implements ObjectTemplate<BiomeProvider> {
|
||||
@Value("provider")
|
||||
private @Meta BiomeProvider provider;
|
||||
|
||||
@Value("resolution")
|
||||
@Default
|
||||
private @Meta int resolution = 4;
|
||||
|
||||
@Value("extrusions")
|
||||
private @Meta List<@Meta Extrusion> extrusions;
|
||||
|
||||
@Override
|
||||
public BiomeProvider get() {
|
||||
return new BiomeExtrusionProvider(provider, extrusions, resolution);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.config;
|
||||
|
||||
import com.dfsek.tectonic.api.depth.DepthTracker;
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.ReplaceableBiome;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
public class ReplaceableBiomeLoader implements TypeLoader<ReplaceableBiome> {
|
||||
private final Registry<Biome> biomeRegistry;
|
||||
|
||||
public ReplaceableBiomeLoader(Registry<Biome> biomeRegistry) {
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplaceableBiome load(@NotNull AnnotatedType t, @NotNull Object c, @NotNull ConfigLoader loader, DepthTracker depthTracker)
|
||||
throws LoadException {
|
||||
if(c.equals("SELF")) return ReplaceableBiome.self();
|
||||
return biomeRegistry
|
||||
.getByID((String) c)
|
||||
.map(ReplaceableBiome::of)
|
||||
.orElseThrow(() -> new LoadException("No such biome: " + c, depthTracker));
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.config.extrusions;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.ReplaceableBiome;
|
||||
import com.dfsek.terra.addons.biome.extrusion.extrusions.ReplaceExtrusion;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
|
||||
public class ReplaceExtrusionTemplate extends SamplerExtrusionTemplate {
|
||||
@Value("to")
|
||||
private @Meta ProbabilityCollection<@Meta ReplaceableBiome> biomes;
|
||||
|
||||
@Value("from")
|
||||
private @Meta String fromTag;
|
||||
|
||||
@Override
|
||||
public Extrusion get() {
|
||||
return new ReplaceExtrusion(sampler, range, biomes, fromTag);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.config.extrusions;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
public abstract class SamplerExtrusionTemplate implements ObjectTemplate<Extrusion> {
|
||||
@Value("sampler")
|
||||
protected @Meta NoiseSampler sampler;
|
||||
|
||||
@Value("range")
|
||||
protected @Meta Range range;
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.config.extrusions;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.Extrusion;
|
||||
import com.dfsek.terra.addons.biome.extrusion.api.ReplaceableBiome;
|
||||
import com.dfsek.terra.addons.biome.extrusion.extrusions.SetExtrusion;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
|
||||
public class SetExtrusionTemplate extends SamplerExtrusionTemplate {
|
||||
@Value("to")
|
||||
private @Meta ProbabilityCollection<@Meta ReplaceableBiome> biomes;
|
||||
|
||||
@Override
|
||||
public Extrusion get() {
|
||||
return new SetExtrusion(sampler, range, biomes);
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.extrusions;
|
||||
|
||||
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.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.world.biome.Biome;
|
||||
|
||||
|
||||
/**
|
||||
* Sets biomes at locations based on a sampler.
|
||||
*/
|
||||
public class ReplaceExtrusion implements Extrusion {
|
||||
private final NoiseSampler sampler;
|
||||
|
||||
private final Range range;
|
||||
|
||||
private final ProbabilityCollection<ReplaceableBiome> biomes;
|
||||
|
||||
private final Predicate<Biome> hasTag;
|
||||
|
||||
public ReplaceExtrusion(NoiseSampler sampler, Range range, ProbabilityCollection<ReplaceableBiome> biomes, String tag) {
|
||||
this.sampler = sampler;
|
||||
this.range = range;
|
||||
this.biomes = biomes;
|
||||
this.hasTag = BiomeQueries.has(tag);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Biome> getBiomes() {
|
||||
return biomes
|
||||
.getContents()
|
||||
.stream()
|
||||
.filter(Predicate.not(ReplaceableBiome::isSelf))
|
||||
.map(ReplaceableBiome::get)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.dfsek.terra.addons.biome.extrusion.extrusions;
|
||||
|
||||
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.world.biome.Biome;
|
||||
|
||||
|
||||
/**
|
||||
* Sets biomes at locations based on a sampler.
|
||||
*/
|
||||
public class SetExtrusion implements Extrusion {
|
||||
private final NoiseSampler sampler;
|
||||
|
||||
private final Range range;
|
||||
|
||||
private final ProbabilityCollection<ReplaceableBiome> biomes;
|
||||
|
||||
public SetExtrusion(NoiseSampler sampler, Range range, ProbabilityCollection<ReplaceableBiome> biomes) {
|
||||
this.sampler = sampler;
|
||||
this.range = range;
|
||||
this.biomes = biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome extrude(Biome original, int x, int y, int z, long seed) {
|
||||
return range.ifInRange(y, () -> biomes.get(sampler, x, y, z, seed).get(original), original);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Biome> getBiomes() {
|
||||
return biomes
|
||||
.getContents()
|
||||
.stream()
|
||||
.filter(Predicate.not(ReplaceableBiome::isSelf))
|
||||
.map(ReplaceableBiome::get)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
schema-version: 1
|
||||
contributors:
|
||||
- Terra contributors
|
||||
id: biome-provider-extrusion
|
||||
version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.extrusion.BiomeExtrusionAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
biome-query-api: "1.+"
|
||||
@@ -1,5 +1,11 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.biome.image.lib.jafama")
|
||||
}
|
||||
+11
-1
@@ -13,6 +13,7 @@ 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.api.world.biome.Biome;
|
||||
@@ -37,7 +38,11 @@ public class ImageBiomeProvider implements BiomeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int z, long seed) {
|
||||
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;
|
||||
Color color = align.getColor(image, x, z);
|
||||
@@ -51,6 +56,11 @@ public class ImageBiomeProvider implements BiomeProvider {
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Optional.of(getBiome(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Biome> getBiomes() {
|
||||
return colorBiomeMap.values();
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.image.ImageBiomeProviderAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-biome-provider-image/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-biome-provider-image
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,12 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.1")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.biome.pipeline.lib.jafama")
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.util.function.IntIntObjConsumer;
|
||||
import com.dfsek.terra.api.util.function.IntObjConsumer;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
class BiomePipelineColumn implements Column<Biome> {
|
||||
private final int min;
|
||||
private final int max;
|
||||
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final Biome biome;
|
||||
|
||||
protected BiomePipelineColumn(BiomeProvider biomeProvider, int min, int max, int x, int z, long seed) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.biome = biomeProvider.getBiome(x, 0, z, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinY() {
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome get(int y) {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forRanges(int resolution, IntIntObjConsumer<Biome> consumer) {
|
||||
consumer.accept(min, max, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(Consumer<Biome> consumer) {
|
||||
for(int y = min; y < max; y++) {
|
||||
consumer.accept(biome);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(IntObjConsumer<Biome> consumer) {
|
||||
for(int y = min; y < max; y++) {
|
||||
consumer.accept(y, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
-22
@@ -7,14 +7,13 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@@ -23,6 +22,7 @@ import com.dfsek.terra.addons.biome.pipeline.api.delegate.BiomeDelegate;
|
||||
import com.dfsek.terra.addons.biome.pipeline.api.stage.Stage;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
@@ -40,16 +40,9 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
this.resolution = resolution;
|
||||
this.mutator = mutator;
|
||||
this.noiseAmp = noiseAmp;
|
||||
holderCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(1024)
|
||||
.build(
|
||||
new CacheLoader<>() {
|
||||
@Override
|
||||
public BiomeHolder load(@NotNull SeededVector key) {
|
||||
return pipeline.getBiomes(key.x, key.z, key.seed);
|
||||
}
|
||||
}
|
||||
);
|
||||
holderCache = Caffeine.newBuilder()
|
||||
.maximumSize(1024)
|
||||
.build(key -> pipeline.getBiomes(key.x, key.z, key.seed));
|
||||
this.pipeline = pipeline;
|
||||
|
||||
Set<BiomeDelegate> biomeSet = new HashSet<>();
|
||||
@@ -81,19 +74,27 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int y, int z, long seed) {
|
||||
return getBiome(x, z, seed);
|
||||
}
|
||||
|
||||
public Biome getBiome(int x, int z, long seed) {
|
||||
x += mutator.noise(seed + 1, x, z) * noiseAmp;
|
||||
z += mutator.noise(seed + 2, x, z) * noiseAmp;
|
||||
|
||||
|
||||
x = FastMath.floorToInt(FastMath.floorDiv(x, resolution));
|
||||
|
||||
z = FastMath.floorToInt(FastMath.floorDiv(z, resolution));
|
||||
|
||||
|
||||
|
||||
x /= resolution;
|
||||
z /= resolution;
|
||||
|
||||
int fdX = FastMath.floorDiv(x, pipeline.getSize());
|
||||
int fdZ = FastMath.floorDiv(z, pipeline.getSize());
|
||||
return holderCache.getUnchecked(new SeededVector(fdX, fdZ, seed)).getBiome(x - fdX * pipeline.getSize(),
|
||||
z - fdZ * pipeline.getSize()).getBiome();
|
||||
return holderCache.get(new SeededVector(fdX, fdZ, seed)).getBiome(x - fdX * pipeline.getSize(),
|
||||
z - fdZ * pipeline.getSize()).getBiome();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Optional.of(getBiome(x, z, seed));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,6 +102,30 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Column<Biome> getColumn(int x, int z, long seed, int min, int max) {
|
||||
return new BiomePipelineColumn(this, min, max, x, z, seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resolution() {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
private record SeededVector(int x, int z, long seed) {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof SeededVector that) {
|
||||
return this.z == that.z && this.x == that.x && this.seed == that.seed;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int code = x;
|
||||
code = 31 * code + z;
|
||||
return 31 * code + ((int) (seed ^ (seed >>> 32)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ final class SelfDelegate implements BiomeDelegate {
|
||||
public static final SelfDelegate INSTANCE = new SelfDelegate();
|
||||
|
||||
private SelfDelegate() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
|
||||
@Description("""
|
||||
The initial size of biome chunks. This value must be at least 2.
|
||||
<b>This is not the final size of biome chunks. Final chunks will be much larger</b>.
|
||||
|
||||
|
||||
It is recommended to keep biome chunks' final size in the range of [50, 300]
|
||||
to prevent performance issues. To calculate the size of biome chunks, simply
|
||||
take initial-size and for each expand stage, multiply the running value by 2
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public abstract class BiomeProviderTemplate implements ObjectTemplate<BiomeProvi
|
||||
@Default
|
||||
@Description("""
|
||||
The resolution at which to sample biomes.
|
||||
|
||||
|
||||
Larger values are quadratically faster, but produce lower quality results.
|
||||
For example, a value of 3 would sample every 3 blocks.""")
|
||||
protected @Meta int resolution = 1;
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.pipeline.BiomePipelineAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-biome-provider-pipeline/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-biome-provider-pipeline
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+7
-1
@@ -8,6 +8,7 @@
|
||||
package com.dfsek.terra.addons.biome.single;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@@ -21,10 +22,15 @@ public class SingleBiomeProvider implements BiomeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int z, long seed) {
|
||||
public Biome getBiome(int x, int y, int z, long seed) {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Biome> getBaseBiome(int x, int z, long seed) {
|
||||
return Optional.of(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Biome> getBiomes() {
|
||||
return Collections.singleton(biome);
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.single.SingleBiomeProviderAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-biome-provider-single/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-biome-provider-single
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -0,0 +1,4 @@
|
||||
# Biome Query API
|
||||
|
||||
This addon contains an API to allow other addons to quickly query
|
||||
Biome data, by baking queries and using Contexts on biomes.
|
||||
@@ -0,0 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.dfsek.terra.addons.biome.query;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.dfsek.terra.addons.biome.query.impl.BiomeTagFlattener;
|
||||
import com.dfsek.terra.addons.biome.query.impl.BiomeTagHolder;
|
||||
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.ConfigPackPostLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
public class BiomeQueryAPIAddon implements AddonInitializer {
|
||||
public static PropertyKey<BiomeTagHolder> BIOME_TAG_KEY = Context.create(BiomeTagHolder.class);
|
||||
@Inject
|
||||
private Platform platform;
|
||||
@Inject
|
||||
private BaseAddon addon;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPostLoadEvent.class)
|
||||
.then(event -> {
|
||||
Collection<Biome> biomes = event
|
||||
.getPack()
|
||||
.getRegistry(Biome.class)
|
||||
.entries();
|
||||
|
||||
BiomeTagFlattener flattener = new BiomeTagFlattener(biomes
|
||||
.stream()
|
||||
.flatMap(biome -> biome.getTags().stream())
|
||||
.toList());
|
||||
|
||||
biomes.forEach(biome -> biome.getContext().put(BIOME_TAG_KEY, new BiomeTagHolder(biome, flattener)));
|
||||
})
|
||||
.global();
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.dfsek.terra.addons.biome.query.api;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.dfsek.terra.addons.biome.query.impl.SingleTagQuery;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
public final class BiomeQueries {
|
||||
private BiomeQueries() {
|
||||
|
||||
}
|
||||
|
||||
public static Predicate<Biome> has(String tag) {
|
||||
return new SingleTagQuery(tag);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.dfsek.terra.addons.biome.query.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class BiomeTagFlattener {
|
||||
private final List<String> tags;
|
||||
|
||||
public BiomeTagFlattener(List<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public int index(String tag) {
|
||||
return tags.indexOf(tag);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return tags.size();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.dfsek.terra.addons.biome.query.impl;
|
||||
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
public class BiomeTagHolder implements Properties {
|
||||
private final boolean[] tags;
|
||||
private final BiomeTagFlattener flattener;
|
||||
|
||||
public BiomeTagHolder(Biome biome, BiomeTagFlattener flattener) {
|
||||
this.tags = new boolean[flattener.size()];
|
||||
this.flattener = flattener;
|
||||
for(String tag : biome.getTags()) {
|
||||
tags[flattener.index(tag)] = true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean get(int index) {
|
||||
return tags[index];
|
||||
}
|
||||
|
||||
public BiomeTagFlattener getFlattener() {
|
||||
return flattener;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.dfsek.terra.addons.biome.query.impl;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.dfsek.terra.addons.biome.query.BiomeQueryAPIAddon;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
|
||||
|
||||
public class SingleTagQuery implements Predicate<Biome> {
|
||||
private final String tag;
|
||||
private int tagIndex = -1;
|
||||
|
||||
public SingleTagQuery(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Biome biome) {
|
||||
if(tagIndex < 0) {
|
||||
tagIndex = biome
|
||||
.getContext()
|
||||
.get(BiomeQueryAPIAddon.BIOME_TAG_KEY)
|
||||
.getFlattener()
|
||||
.index(tag);
|
||||
}
|
||||
return biome
|
||||
.getContext()
|
||||
.get(BiomeQueryAPIAddon.BIOME_TAG_KEY)
|
||||
.get(tagIndex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
schema-version: 1
|
||||
contributors:
|
||||
- Terra contributors
|
||||
id: biome-query-api
|
||||
version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.query.BiomeQueryAPIAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,12 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.1.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.chunkgenerator.lib.jafama")
|
||||
}
|
||||
|
||||
+15
-4
@@ -9,7 +9,9 @@ package com.dfsek.terra.addons.chunkgenerator;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.NoiseChunkGeneratorPackConfigTemplate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseConfigTemplate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.palette.BiomePaletteTemplate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.palette.PaletteInfo;
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.palette.SlantLayer;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.NoiseChunkGenerator3D;
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
@@ -19,6 +21,8 @@ import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
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.properties.Context;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
||||
|
||||
@@ -32,17 +36,22 @@ public class NoiseChunkGenerator3DAddon implements AddonInitializer {
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
PropertyKey<PaletteInfo> paletteInfoPropertyKey = Context.create(PaletteInfo.class);
|
||||
PropertyKey<BiomeNoiseProperties> noisePropertiesPropertyKey = Context.create(BiomeNoiseProperties.class);
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.priority(1000)
|
||||
.then(event -> {
|
||||
NoiseChunkGeneratorPackConfigTemplate config = event.loadTemplate(new NoiseChunkGeneratorPackConfigTemplate());
|
||||
|
||||
event.getPack()
|
||||
.getOrCreateRegistry(ChunkGeneratorProvider.class)
|
||||
.register(addon.key("NOISE_3D"),
|
||||
pack -> new NoiseChunkGenerator3D(platform, config.getElevationBlend(), config.getHorizontalRes(),
|
||||
config.getVerticalRes()));
|
||||
pack -> new NoiseChunkGenerator3D(pack, platform, config.getElevationBlend(),
|
||||
config.getHorizontalRes(),
|
||||
config.getVerticalRes(), noisePropertiesPropertyKey,
|
||||
paletteInfoPropertyKey));
|
||||
event.getPack()
|
||||
.applyLoader(SlantLayer.class, SlantLayer::new);
|
||||
})
|
||||
@@ -53,8 +62,10 @@ public class NoiseChunkGenerator3DAddon implements AddonInitializer {
|
||||
.register(addon, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
if(event.is(Biome.class)) {
|
||||
event.getLoadedObject(Biome.class).getContext().put(event.load(new BiomePaletteTemplate(platform)).get());
|
||||
event.getLoadedObject(Biome.class).getContext().put(event.load(new BiomeNoiseConfigTemplate()).get());
|
||||
event.getLoadedObject(Biome.class).getContext().put(paletteInfoPropertyKey,
|
||||
event.load(new BiomePaletteTemplate(platform)).get());
|
||||
event.getLoadedObject(Biome.class).getContext().put(noisePropertiesPropertyKey,
|
||||
event.load(new BiomeNoiseConfigTemplate()).get());
|
||||
}
|
||||
})
|
||||
.failThrough();
|
||||
|
||||
+1
-1
@@ -39,6 +39,6 @@ public class BiomeNoiseConfigTemplate implements ObjectTemplate<BiomeNoiseProper
|
||||
@Override
|
||||
public BiomeNoiseProperties get() {
|
||||
return new BiomeNoiseProperties(baseSampler, elevationSampler, carvingSampler, blendDistance, blendStep, blendWeight,
|
||||
elevationWeight);
|
||||
elevationWeight, new ThreadLocalNoiseHolder());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,6 +10,6 @@ public record BiomeNoiseProperties(NoiseSampler base,
|
||||
int blendDistance,
|
||||
int blendStep,
|
||||
double blendWeight,
|
||||
double elevationWeight) implements Properties {
|
||||
|
||||
double elevationWeight,
|
||||
ThreadLocalNoiseHolder noiseHolder) implements Properties {
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.config.noise;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class ThreadLocalNoiseHolder {
|
||||
private final ThreadLocal<Holder> holder = ThreadLocal.withInitial(Holder::new);
|
||||
|
||||
public double getNoise(NoiseSampler sampler, int x, int y, int z, long seed) {
|
||||
Holder holder = this.holder.get();
|
||||
|
||||
if(holder.init && holder.y == y && holder.z == z && holder.x == x && holder.seed == seed) {
|
||||
return holder.noise;
|
||||
}
|
||||
|
||||
double noise = sampler.noise(seed, x, y, z);
|
||||
holder.noise = noise;
|
||||
holder.x = x;
|
||||
holder.y = y;
|
||||
holder.z = z;
|
||||
holder.seed = seed;
|
||||
holder.init = true;
|
||||
return noise;
|
||||
}
|
||||
|
||||
private static final class Holder {
|
||||
int x, y, z;
|
||||
boolean init = false;
|
||||
long seed;
|
||||
double noise;
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -59,6 +59,10 @@ public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||
}
|
||||
};
|
||||
|
||||
@Value("carving.update-palette")
|
||||
@Default
|
||||
private @Meta boolean updatePalette = false;
|
||||
|
||||
public BiomePaletteTemplate(Platform platform) { this.platform = platform; }
|
||||
|
||||
@Override
|
||||
@@ -79,6 +83,7 @@ public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||
slantLayers.put(threshold, layer.getPalette());
|
||||
}
|
||||
|
||||
return new PaletteInfo(builder.build(), new SlantHolder(slantLayers, minThreshold), oceanPalette, seaLevel, slantDepth);
|
||||
return new PaletteInfo(builder.build(), SlantHolder.of(slantLayers, minThreshold), oceanPalette, seaLevel, slantDepth,
|
||||
updatePalette);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,5 +17,6 @@ public record PaletteInfo(PaletteHolder paletteHolder,
|
||||
SlantHolder slantHolder,
|
||||
Palette ocean,
|
||||
int seaLevel,
|
||||
int maxSlantDepth) implements Properties {
|
||||
int maxSlantDepth,
|
||||
boolean updatePaletteWhenCarving) implements Properties {
|
||||
}
|
||||
|
||||
+67
-44
@@ -11,6 +11,7 @@ package com.dfsek.terra.addons.chunkgenerator.generation;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.palette.PaletteInfo;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.PaletteUtil;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.LazilyEvaluatedInterpolator;
|
||||
@@ -18,7 +19,9 @@ import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
@@ -37,13 +40,28 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
private final int carverHorizontalResolution;
|
||||
private final int carverVerticalResolution;
|
||||
|
||||
public NoiseChunkGenerator3D(Platform platform, int elevationBlend, int carverHorizontalResolution,
|
||||
int carverVerticalResolution) {
|
||||
private final PropertyKey<PaletteInfo> paletteInfoPropertyKey;
|
||||
private final PropertyKey<BiomeNoiseProperties> noisePropertiesKey;
|
||||
|
||||
public NoiseChunkGenerator3D(ConfigPack pack, Platform platform, int elevationBlend, int carverHorizontalResolution,
|
||||
int carverVerticalResolution,
|
||||
PropertyKey<BiomeNoiseProperties> noisePropertiesKey,
|
||||
PropertyKey<PaletteInfo> paletteInfoPropertyKey) {
|
||||
this.platform = platform;
|
||||
this.air = platform.getWorldHandle().air();
|
||||
this.carverHorizontalResolution = carverHorizontalResolution;
|
||||
this.carverVerticalResolution = carverVerticalResolution;
|
||||
this.samplerCache = new SamplerProvider(platform, elevationBlend);
|
||||
this.paletteInfoPropertyKey = paletteInfoPropertyKey;
|
||||
this.noisePropertiesKey = noisePropertiesKey;
|
||||
int maxBlend = pack
|
||||
.getBiomeProvider()
|
||||
.stream()
|
||||
.map(biome -> biome.getContext().get(noisePropertiesKey))
|
||||
.mapToInt(properties -> properties.blendDistance() * properties.blendStep())
|
||||
.max()
|
||||
.orElse(0);
|
||||
|
||||
this.samplerCache = new SamplerProvider(platform, elevationBlend, noisePropertiesKey, maxBlend);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,64 +69,69 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world,
|
||||
@NotNull BiomeProvider biomeProvider,
|
||||
int chunkX, int chunkZ) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) {
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
|
||||
Sampler3D sampler = samplerCache.getChunk(chunkX, chunkZ, world, biomeProvider);
|
||||
|
||||
long seed = world.getSeed();
|
||||
|
||||
LazilyEvaluatedInterpolator carver = new LazilyEvaluatedInterpolator(biomeProvider,
|
||||
chunkX,
|
||||
chunkZ,
|
||||
world.getMaxHeight(),
|
||||
world.getMinHeight(),
|
||||
carverHorizontalResolution,
|
||||
carverVerticalResolution,
|
||||
seed);
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
int paletteLevel = 0;
|
||||
platform.getProfiler().push("chunk_base_3d");
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
|
||||
Sampler3D sampler = samplerCache.getChunk(chunkX, chunkZ, world, biomeProvider);
|
||||
|
||||
long seed = world.getSeed();
|
||||
|
||||
LazilyEvaluatedInterpolator carver = new LazilyEvaluatedInterpolator(biomeProvider,
|
||||
chunkX,
|
||||
chunkZ,
|
||||
world.getMaxHeight(),
|
||||
noisePropertiesKey, world.getMinHeight(),
|
||||
carverHorizontalResolution,
|
||||
carverVerticalResolution,
|
||||
seed);
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
int paletteLevel = 0;
|
||||
|
||||
int cx = xOrig + x;
|
||||
int cz = zOrig + z;
|
||||
|
||||
BlockState data;
|
||||
Column<Biome> biomeColumn = biomeProvider.getColumn(cx, cz, world);
|
||||
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
|
||||
Biome biome = biomeColumn.get(y);
|
||||
|
||||
int cx = xOrig + x;
|
||||
int cz = zOrig + z;
|
||||
|
||||
Biome biome = biomeProvider.getBiome(cx, cz, seed);
|
||||
|
||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||
PaletteInfo paletteInfo = biome.getContext().get(paletteInfoPropertyKey);
|
||||
|
||||
int sea = paletteInfo.seaLevel();
|
||||
Palette seaPalette = paletteInfo.ocean();
|
||||
|
||||
BlockState data;
|
||||
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
|
||||
if(sampler.sample(x, y, z) > 0) {
|
||||
if(carver.sample(x, y, z) <= 0) {
|
||||
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo, paletteLevel).get(paletteLevel, cx, y, cz,
|
||||
seed);
|
||||
chunk.setBlock(x, y, z, data);
|
||||
}
|
||||
|
||||
if(sampler.sample(x, y, z) > 0) {
|
||||
if(carver.sample(x, y, z) <= 0) {
|
||||
data = PaletteUtil
|
||||
.getPalette(x, y, z, sampler, paletteInfo, paletteLevel)
|
||||
.get(paletteLevel, cx, y, cz, seed);
|
||||
chunk.setBlock(x, y, z, data);
|
||||
paletteLevel++;
|
||||
} else if(y <= sea) {
|
||||
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, y, z + zOrig, seed));
|
||||
} else if(paletteInfo.updatePaletteWhenCarving()) {
|
||||
paletteLevel = 0;
|
||||
} else {
|
||||
paletteLevel = 0;
|
||||
paletteLevel++;
|
||||
}
|
||||
} else if(y <= sea) {
|
||||
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, y, z + zOrig, seed));
|
||||
paletteLevel = 0;
|
||||
} else {
|
||||
paletteLevel = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
platform.getProfiler().pop("chunk_base_3d");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(WorldProperties world, int x, int y, int z, BiomeProvider biomeProvider) {
|
||||
Biome biome = biomeProvider.getBiome(x, z, world.getSeed());
|
||||
Biome biome = biomeProvider.getBiome(x, y, z, world.getSeed());
|
||||
Sampler3D sampler = samplerCache.get(x, z, world, biomeProvider);
|
||||
|
||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||
PaletteInfo paletteInfo = biome.getContext().get(paletteInfoPropertyKey);
|
||||
|
||||
int fdX = FastMath.floorMod(x, 16);
|
||||
int fdZ = FastMath.floorMod(z, 16);
|
||||
@@ -129,7 +152,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public Palette getPalette(int x, int y, int z, WorldProperties world, BiomeProvider biomeProvider) {
|
||||
return biomeProvider.getBiome(x, z, world.getSeed()).getContext().get(PaletteInfo.class).paletteHolder().getPalette(y);
|
||||
return biomeProvider.getBiome(x, y, z, world.getSeed()).getContext().get(paletteInfoPropertyKey).paletteHolder().getPalette(y);
|
||||
}
|
||||
|
||||
public SamplerProvider samplerProvider() {
|
||||
|
||||
+65
-42
@@ -9,11 +9,10 @@ package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.api.util.mutable.MutableInteger;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.util.Column;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
@@ -23,7 +22,6 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
*/
|
||||
public class ChunkInterpolator {
|
||||
private final Interpolator3[][][] interpGrid;
|
||||
private final long seed;
|
||||
|
||||
private final int min;
|
||||
private final int max;
|
||||
@@ -37,10 +35,10 @@ public class ChunkInterpolator {
|
||||
* @param min
|
||||
* @param max
|
||||
*/
|
||||
public ChunkInterpolator(long seed, int chunkX, int chunkZ, BiomeProvider provider, int min, int max) {
|
||||
public ChunkInterpolator(long seed, int chunkX, int chunkZ, BiomeProvider provider, int min, int max,
|
||||
PropertyKey<BiomeNoiseProperties> noisePropertiesKey, int maxBlend) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.seed = seed;
|
||||
|
||||
int xOrigin = chunkX << 4;
|
||||
int zOrigin = chunkZ << 4;
|
||||
@@ -53,28 +51,67 @@ public class ChunkInterpolator {
|
||||
|
||||
double[][][] noiseStorage = new double[5][5][size + 1];
|
||||
|
||||
int maxBlendAndChunk = 17 + 2 * maxBlend;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Column<Biome>[] columns = new Column[maxBlendAndChunk * maxBlendAndChunk];
|
||||
|
||||
for(int x = 0; x < 5; x++) {
|
||||
int scaledX = x << 2;
|
||||
int absoluteX = xOrigin + scaledX;
|
||||
for(int z = 0; z < 5; z++) {
|
||||
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2), seed)
|
||||
.getContext()
|
||||
.get(BiomeNoiseProperties.class);
|
||||
Map<BiomeNoiseProperties, MutableInteger> genMap = new HashMap<>();
|
||||
int scaledZ = z << 2;
|
||||
int absoluteZ = zOrigin + scaledZ;
|
||||
|
||||
int step = generationSettings.blendStep();
|
||||
int blend = generationSettings.blendDistance();
|
||||
int index = (scaledX + maxBlend) + maxBlendAndChunk * (scaledZ + maxBlend);
|
||||
Column<Biome> biomeColumn = columns[index];
|
||||
|
||||
for(int xi = -blend; xi <= blend; xi++) {
|
||||
for(int zi = -blend; zi <= blend; zi++) {
|
||||
genMap.computeIfAbsent(
|
||||
provider.getBiome(xOrigin + (x << 2) + (xi * step), zOrigin + (z << 2) + (zi * step), seed)
|
||||
.getContext()
|
||||
.get(BiomeNoiseProperties.class),
|
||||
g -> new MutableInteger(0)).increment(); // Increment by 1
|
||||
}
|
||||
if(biomeColumn == null) {
|
||||
biomeColumn = provider.getColumn(absoluteX, absoluteZ, seed, min, max);
|
||||
columns[index] = biomeColumn;
|
||||
}
|
||||
|
||||
for(int y = 0; y < size + 1; y++) {
|
||||
noiseStorage[x][z][y] = computeNoise(genMap, (x << 2) + xOrigin, (y << 2) + this.min, (z << 2) + zOrigin);
|
||||
for(int y = 0; y < size; y++) {
|
||||
int scaledY = (y << 2) + min;
|
||||
BiomeNoiseProperties generationSettings = biomeColumn.get(scaledY)
|
||||
.getContext()
|
||||
.get(noisePropertiesKey);
|
||||
|
||||
int step = generationSettings.blendStep();
|
||||
int blend = generationSettings.blendDistance();
|
||||
|
||||
double runningNoise = 0;
|
||||
double runningDiv = 0;
|
||||
|
||||
for(int xi = -blend; xi <= blend; xi++) {
|
||||
for(int zi = -blend; zi <= blend; zi++) {
|
||||
int blendX = (xi * step);
|
||||
int blendZ = (zi * step);
|
||||
|
||||
int localIndex = (scaledX + maxBlend + blendX) + maxBlendAndChunk * (scaledZ + maxBlend + blendZ);
|
||||
Column<Biome> column = columns[localIndex];
|
||||
|
||||
if(column == null) {
|
||||
column = provider.getColumn(absoluteX + blendX, absoluteZ + blendZ, seed, min, max);
|
||||
columns[localIndex] = column;
|
||||
}
|
||||
|
||||
BiomeNoiseProperties properties = column
|
||||
.get(scaledY)
|
||||
.getContext()
|
||||
.get(noisePropertiesKey);
|
||||
double sample = properties.noiseHolder().getNoise(properties.base(), absoluteX, scaledY, absoluteZ, seed);
|
||||
runningNoise += sample * properties.blendWeight();
|
||||
runningDiv += properties.blendWeight();
|
||||
}
|
||||
}
|
||||
|
||||
double noise = runningNoise / runningDiv;
|
||||
|
||||
noiseStorage[x][z][y] = noise;
|
||||
if(y == size - 1) {
|
||||
noiseStorage[x][z][size] = noise;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,24 +137,6 @@ public class ChunkInterpolator {
|
||||
return FastMath.max(FastMath.min(value, high), 0);
|
||||
}
|
||||
|
||||
public double computeNoise(BiomeNoiseProperties generationSettings, double x, double y, double z) {
|
||||
return generationSettings.base().noise(seed, x, y, z);
|
||||
}
|
||||
|
||||
public double computeNoise(Map<BiomeNoiseProperties, MutableInteger> gens, double x, double y, double z) {
|
||||
double n = 0;
|
||||
double div = 0;
|
||||
for(Map.Entry<BiomeNoiseProperties, MutableInteger> entry : gens.entrySet()) {
|
||||
BiomeNoiseProperties gen = entry.getKey();
|
||||
int weight = entry.getValue().get();
|
||||
double noise = computeNoise(gen, x, y, z);
|
||||
|
||||
n += noise * weight;
|
||||
div += gen.blendWeight() * weight;
|
||||
}
|
||||
return n / div;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the noise at a pair of internal chunk coordinates.
|
||||
*
|
||||
@@ -133,6 +152,10 @@ public class ChunkInterpolator {
|
||||
}
|
||||
|
||||
public double getNoise(int x, int y, int z) {
|
||||
return interpGrid[x / 4][(y - min) / 4][z / 4].trilerp((double) (x % 4) / 4, (double) (y % 4) / 4, (double) (z % 4) / 4);
|
||||
return interpGrid[x / 4][(y - min) / 4][z / 4].trilerp(
|
||||
(double) (x & 3) / 4, // x & 3 == x % 4
|
||||
(double) (y & 3) / 4, // x & 3 == x % 4
|
||||
(double) (z & 3) / 4 // x & 3 == x % 4
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -8,13 +8,15 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
public class ElevationInterpolator {
|
||||
private final double[][] values = new double[18][18];
|
||||
|
||||
public ElevationInterpolator(long seed, int chunkX, int chunkZ, BiomeProvider provider, int smooth) {
|
||||
public ElevationInterpolator(long seed, int chunkX, int chunkZ, BiomeProvider provider, int smooth,
|
||||
PropertyKey<BiomeNoiseProperties> noisePropertiesKey) {
|
||||
int xOrigin = chunkX << 4;
|
||||
int zOrigin = chunkZ << 4;
|
||||
|
||||
@@ -23,8 +25,14 @@ public class ElevationInterpolator {
|
||||
// Precompute generators.
|
||||
for(int x = -1 - smooth; x <= 16 + smooth; x++) {
|
||||
for(int z = -1 - smooth; z <= 16 + smooth; z++) {
|
||||
gens[x + 1 + smooth][z + 1 + smooth] = provider.getBiome(xOrigin + x, zOrigin + z, seed).getContext().get(
|
||||
BiomeNoiseProperties.class);
|
||||
int bx = xOrigin + x;
|
||||
int bz = zOrigin + z;
|
||||
gens[x + 1 + smooth][z + 1 + smooth] =
|
||||
provider
|
||||
.getBaseBiome(bx, bz, seed)
|
||||
.orElseGet(() -> provider.getBiome(bx, 0, bz, seed)) // kind of a hack
|
||||
.getContext()
|
||||
.get(noisePropertiesKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-17
@@ -3,16 +3,14 @@ package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import static com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.Interpolator.lerp;
|
||||
|
||||
|
||||
public class LazilyEvaluatedInterpolator {
|
||||
private final Double[][][] samples;
|
||||
|
||||
private final NoiseSampler[][] samplers;
|
||||
private final Double[] samples; //
|
||||
|
||||
private final int chunkX;
|
||||
private final int chunkZ;
|
||||
@@ -21,16 +19,22 @@ public class LazilyEvaluatedInterpolator {
|
||||
private final int verticalRes;
|
||||
|
||||
private final BiomeProvider biomeProvider;
|
||||
private final PropertyKey<BiomeNoiseProperties> noisePropertiesKey;
|
||||
|
||||
private final long seed;
|
||||
private final int min;
|
||||
private final int min, max;
|
||||
|
||||
public LazilyEvaluatedInterpolator(BiomeProvider biomeProvider, int cx, int cz, int max, int min, int horizontalRes, int verticalRes,
|
||||
private final int zMul, yMul;
|
||||
|
||||
public LazilyEvaluatedInterpolator(BiomeProvider biomeProvider, int cx, int cz, int max,
|
||||
PropertyKey<BiomeNoiseProperties> noisePropertiesKey, int min, int horizontalRes, int verticalRes,
|
||||
long seed) {
|
||||
this.noisePropertiesKey = noisePropertiesKey;
|
||||
int hSamples = FastMath.ceilToInt(16.0 / horizontalRes);
|
||||
int vSamples = FastMath.ceilToInt((double) (max - min) / verticalRes);
|
||||
samples = new Double[hSamples + 1][vSamples + 1][hSamples + 1];
|
||||
samplers = new NoiseSampler[hSamples + 1][hSamples + 1];
|
||||
this.zMul = (hSamples + 1);
|
||||
this.yMul = zMul * zMul;
|
||||
samples = new Double[yMul * (vSamples + 1)];
|
||||
this.chunkX = cx << 4;
|
||||
this.chunkZ = cz << 4;
|
||||
this.horizontalRes = horizontalRes;
|
||||
@@ -38,22 +42,25 @@ public class LazilyEvaluatedInterpolator {
|
||||
this.biomeProvider = biomeProvider;
|
||||
this.seed = seed;
|
||||
this.min = min;
|
||||
this.max = max - 1;
|
||||
}
|
||||
|
||||
private double sample(int x, int y, int z, int ox, int oy, int oz) {
|
||||
Double sample = samples[x][y][z];
|
||||
private double sample(int xIndex, int yIndex, int zIndex, int ox, int oy, int oz) {
|
||||
int index = xIndex + (zIndex * zMul) + (yIndex * yMul);
|
||||
Double sample = samples[index];
|
||||
if(sample == null) {
|
||||
int xi = ox + chunkX;
|
||||
int zi = oz + chunkZ;
|
||||
|
||||
NoiseSampler sampler = samplers[x][z];
|
||||
if(sampler == null) {
|
||||
sampler = biomeProvider.getBiome(xi, zi, seed).getContext().get(BiomeNoiseProperties.class).carving();
|
||||
samplers[x][z] = sampler;
|
||||
}
|
||||
int y = FastMath.min(max, oy);
|
||||
|
||||
sample = sampler.noise(seed, xi, oy, zi);
|
||||
samples[x][y][z] = sample;
|
||||
sample = biomeProvider
|
||||
.getBiome(xi, y, zi, seed)
|
||||
.getContext()
|
||||
.get(noisePropertiesKey)
|
||||
.carving()
|
||||
.noise(seed, xi, y, zi);
|
||||
samples[index] = sample;
|
||||
}
|
||||
return sample;
|
||||
}
|
||||
|
||||
+6
-3
@@ -9,8 +9,10 @@ package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.ChunkInterpolator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.ElevationInterpolator;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
|
||||
@@ -18,10 +20,11 @@ public class Sampler3D {
|
||||
private final ChunkInterpolator interpolator;
|
||||
private final ElevationInterpolator elevationInterpolator;
|
||||
|
||||
public Sampler3D(int x, int z, long seed, int minHeight, int maxHeight, BiomeProvider provider, int elevationSmooth) {
|
||||
public Sampler3D(int x, int z, long seed, int minHeight, int maxHeight, BiomeProvider provider, int elevationSmooth,
|
||||
PropertyKey<BiomeNoiseProperties> noisePropertiesKey, int maxBlend) {
|
||||
this.interpolator = new ChunkInterpolator(seed, x, z, provider,
|
||||
minHeight, maxHeight);
|
||||
this.elevationInterpolator = new ElevationInterpolator(seed, x, z, provider, elevationSmooth);
|
||||
minHeight, maxHeight, noisePropertiesKey, maxBlend);
|
||||
this.elevationInterpolator = new ElevationInterpolator(seed, x, z, provider, elevationSmooth, noisePropertiesKey);
|
||||
}
|
||||
|
||||
public double sample(double x, double y, double z) {
|
||||
|
||||
+15
-13
@@ -17,13 +17,13 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
@@ -31,10 +31,17 @@ import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
public class SamplerProvider {
|
||||
private final Cache<WorldContext, Sampler3D> cache;
|
||||
private final int elevationSmooth;
|
||||
private final PropertyKey<BiomeNoiseProperties> noisePropertiesKey;
|
||||
private final int maxBlend;
|
||||
|
||||
public SamplerProvider(Platform platform, int elevationSmooth) {
|
||||
public SamplerProvider(Platform platform, int elevationSmooth, PropertyKey<BiomeNoiseProperties> noisePropertiesKey, int maxBlend) {
|
||||
cache = Caffeine
|
||||
.newBuilder()
|
||||
.maximumSize(platform.getTerraConfig().getSamplerCache())
|
||||
.build();
|
||||
this.elevationSmooth = elevationSmooth;
|
||||
cache = CacheBuilder.newBuilder().maximumSize(platform.getTerraConfig().getSamplerCache()).build();
|
||||
this.noisePropertiesKey = noisePropertiesKey;
|
||||
this.maxBlend = maxBlend;
|
||||
}
|
||||
|
||||
public Sampler3D get(int x, int z, WorldProperties world, BiomeProvider provider) {
|
||||
@@ -45,13 +52,8 @@ public class SamplerProvider {
|
||||
|
||||
public Sampler3D getChunk(int cx, int cz, WorldProperties world, BiomeProvider provider) {
|
||||
WorldContext context = new WorldContext(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight());
|
||||
try {
|
||||
return cache.get(context,
|
||||
() -> new Sampler3D(context.cx, context.cz, context.seed, context.minHeight, context.maxHeight, provider,
|
||||
elevationSmooth));
|
||||
} catch(ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return cache.get(context, c -> new Sampler3D(c.cx, c.cz, c.seed, c.minHeight, c.maxHeight, provider,
|
||||
elevationSmooth, noisePropertiesKey, maxBlend));
|
||||
}
|
||||
|
||||
private record WorldContext(int cx, int cz, long seed, int minHeight, int maxHeight) {
|
||||
|
||||
+31
-1
@@ -8,6 +8,7 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.palette;
|
||||
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
||||
@@ -15,11 +16,19 @@ public class SlantHolder {
|
||||
private final TreeMap<Double, PaletteHolder> layers;
|
||||
private final double minSlope;
|
||||
|
||||
public SlantHolder(TreeMap<Double, PaletteHolder> layers, double minSlope) {
|
||||
private SlantHolder(TreeMap<Double, PaletteHolder> layers, double minSlope) {
|
||||
this.layers = layers;
|
||||
this.minSlope = minSlope;
|
||||
}
|
||||
|
||||
public static SlantHolder of(TreeMap<Double, PaletteHolder> layers, double minSlope) {
|
||||
if(layers.size() == 1) {
|
||||
Entry<Double, PaletteHolder> firstEntry = layers.firstEntry();
|
||||
return new Single(firstEntry.getValue(), minSlope);
|
||||
}
|
||||
return new SlantHolder(layers, minSlope);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return layers.isEmpty();
|
||||
}
|
||||
@@ -31,4 +40,25 @@ public class SlantHolder {
|
||||
public double getMinSlope() {
|
||||
return minSlope;
|
||||
}
|
||||
|
||||
private static final class Single extends SlantHolder {
|
||||
|
||||
private final PaletteHolder layers;
|
||||
|
||||
public Single(PaletteHolder layers, double minSlope) {
|
||||
super(of(minSlope, layers), minSlope);
|
||||
this.layers = layers;
|
||||
}
|
||||
|
||||
private static TreeMap<Double, PaletteHolder> of(double v, PaletteHolder layer) {
|
||||
TreeMap<Double, PaletteHolder> map = new TreeMap<>();
|
||||
map.put(v, layer);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaletteHolder getPalette(double slope) {
|
||||
return layers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.chunkgenerator.NoiseChunkGenerator3DAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-chunk-generator-noise-3d/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-chunk-generator-noise-3d
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+3
-5
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.holder;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -25,11 +23,11 @@ public class PaletteHolderBuilder {
|
||||
|
||||
public PaletteHolder build() {
|
||||
|
||||
int min = FastMath.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0);
|
||||
int max = FastMath.max(paletteMap.keySet().stream().max(Integer::compareTo).orElse(255), 255);
|
||||
int min = Math.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0);
|
||||
int max = Math.max(paletteMap.keySet().stream().max(Integer::compareTo).orElse(255), 255);
|
||||
|
||||
Palette[] palettes = new Palette[paletteMap.lastKey() + 1 - min];
|
||||
for(int y = min; y <= FastMath.max(paletteMap.lastKey(), max); y++) {
|
||||
for(int y = min; y <= Math.max(paletteMap.lastKey(), max); y++) {
|
||||
Palette d = null;
|
||||
for(Map.Entry<Integer, Palette> e : paletteMap.entrySet()) {
|
||||
if(e.getKey() >= y) {
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.BiomeAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-biome/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-biome
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,12 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.feature.distributor.lib.jafama")
|
||||
}
|
||||
+3
-3
@@ -34,12 +34,12 @@ public class PaddedGridDistributor implements Distributor {
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
int cellX = FastMath.floorDiv(x, cellWidth);
|
||||
int cellZ = FastMath.floorDiv(z, cellWidth);
|
||||
|
||||
|
||||
Random random = new Random((murmur64(MathUtil.squash(cellX, cellZ)) ^ seed) + salt);
|
||||
|
||||
|
||||
int pointX = random.nextInt(width) + cellX * cellWidth;
|
||||
int pointZ = random.nextInt(width) + cellZ * cellWidth;
|
||||
|
||||
|
||||
return x == pointX && z == pointZ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.feature.distributor.DistributorAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-distributors/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-distributors
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
config-feature: "0.1.+"
|
||||
generation-stage-feature: "0.1.+"
|
||||
config-feature: "1.+"
|
||||
generation-stage-feature: "1.+"
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.feature.FeatureAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-feature/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-feature
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
generation-stage-feature: "0.1.+"
|
||||
generation-stage-feature: "1.+"
|
||||
@@ -1,5 +1,11 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.flora.lib.jafama")
|
||||
}
|
||||
|
||||
-7
@@ -15,7 +15,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.Direction;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
@@ -90,12 +89,6 @@ public class TerraFlora implements Structure {
|
||||
if(doRotation) {
|
||||
Direction oneFace = new ArrayList<>(faces).get(
|
||||
new Random(location.getX() ^ location.getZ()).nextInt(faces.size())); // Get random face.
|
||||
|
||||
data = data.setIfPresent(Properties.DIRECTION, oneFace.opposite())
|
||||
.setIfPresent(Properties.NORTH, faces.contains(Direction.NORTH))
|
||||
.setIfPresent(Properties.SOUTH, faces.contains(Direction.SOUTH))
|
||||
.setIfPresent(Properties.EAST, faces.contains(Direction.EAST))
|
||||
.setIfPresent(Properties.WEST, faces.contains(Direction.WEST));
|
||||
}
|
||||
world.setBlockState(location.mutable().add(0, i + c, 0).immutable(), data, physics);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.flora.FloraAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-flora/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-flora
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,12 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.1.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.feature.locator.lib.jafama")
|
||||
}
|
||||
|
||||
+12
-8
@@ -11,6 +11,7 @@ import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
|
||||
|
||||
@@ -31,16 +32,19 @@ public class AdjacentPatternLocator implements Locator {
|
||||
}
|
||||
|
||||
private boolean isValid(int y, Column<?> column) {
|
||||
WritableWorld world = column.getWorld();
|
||||
int x = column.getX();
|
||||
int z = column.getZ();
|
||||
if(matchAll) {
|
||||
return pattern.matches(y, column.adjacent(0, -1)) &&
|
||||
pattern.matches(y, column.adjacent(0, 1)) &&
|
||||
pattern.matches(y, column.adjacent(-1, 0)) &&
|
||||
pattern.matches(y, column.adjacent(1, 0));
|
||||
return pattern.matches(world, x, y, z - 1) &&
|
||||
pattern.matches(world, x, y, z + 1) &&
|
||||
pattern.matches(world, x - 1, y, z) &&
|
||||
pattern.matches(world, x + 1, y, z);
|
||||
} else {
|
||||
return pattern.matches(y, column.adjacent(0, -1)) ||
|
||||
pattern.matches(y, column.adjacent(0, 1)) ||
|
||||
pattern.matches(y, column.adjacent(-1, 0)) ||
|
||||
pattern.matches(y, column.adjacent(1, 0));
|
||||
return pattern.matches(world, x, y, z - 1) ||
|
||||
pattern.matches(world, x, y, z + 1) ||
|
||||
pattern.matches(world, x - 1, y, z) ||
|
||||
pattern.matches(world, x + 1, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.feature.locator.locators;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.patterns.Pattern;
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
@@ -25,6 +27,9 @@ public class PatternLocator implements Locator {
|
||||
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
return new BinaryColumn(search, y -> pattern.matches(y, column));
|
||||
int min = FastMath.max(column.getMinY(), search.getMin());
|
||||
int max = FastMath.min(column.getMaxY(), search.getMax());
|
||||
if(min >= max) return BinaryColumn.getNull();
|
||||
return new BinaryColumn(min, max, y -> pattern.matches(y, column));
|
||||
}
|
||||
}
|
||||
|
||||
+14
-3
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.feature.locator.locators;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
@@ -25,13 +23,26 @@ public class SamplerLocator implements Locator {
|
||||
this.samplers = samplers;
|
||||
}
|
||||
|
||||
private static int floorToInt(double value) {
|
||||
int valueInt = (int) value;
|
||||
if(value < 0.0) {
|
||||
if(value == (double) valueInt) {
|
||||
return valueInt;
|
||||
} else {
|
||||
return valueInt == Integer.MIN_VALUE ? valueInt : valueInt - 1;
|
||||
}
|
||||
} else {
|
||||
return valueInt;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
BinaryColumnBuilder results = column.newBinaryColumn();
|
||||
|
||||
long seed = column.getWorld().getSeed();
|
||||
samplers.forEach(sampler -> {
|
||||
int y = FastMath.floorToInt(sampler.noise(seed, column.getX(), column.getZ()));
|
||||
int y = floorToInt(sampler.noise(seed, column.getX(), column.getZ()));
|
||||
if(y >= column.getMaxY() || y < column.getMinY()) return;
|
||||
results.set(y);
|
||||
});
|
||||
|
||||
+6
-1
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.feature.locator.locators;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
@@ -24,7 +26,10 @@ public class SurfaceLocator implements Locator {
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
BinaryColumnBuilder builder = column.newBinaryColumn();
|
||||
for(int y : search) {
|
||||
int max = FastMath.min(search.getMax(), column.getMaxY());
|
||||
int min = FastMath.max(search.getMin(), column.getMinY());
|
||||
if(min >= max) return builder.build();
|
||||
for(int y = min; y < max; y++) {
|
||||
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
||||
builder.set(y);
|
||||
}
|
||||
|
||||
+19
-2
@@ -7,10 +7,13 @@
|
||||
|
||||
package com.dfsek.terra.addons.feature.locator.patterns;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
|
||||
|
||||
@@ -25,8 +28,22 @@ public class MatchPattern implements Pattern {
|
||||
|
||||
@Override
|
||||
public boolean matches(int y, Column<?> column) {
|
||||
for(int i : range) {
|
||||
if(!matches.test(column.getBlock(y + i))) return false;
|
||||
int min = FastMath.max(column.getMinY(), range.getMin() + y);
|
||||
int max = FastMath.min(column.getMaxY(), range.getMax() + y);
|
||||
if(max <= min) return false;
|
||||
for(int i = min; i < max; i++) {
|
||||
if(!matches.test(column.getBlock(i))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(WritableWorld world, int x, int y, int z) {
|
||||
int min = FastMath.max(world.getMinHeight(), range.getMin() + y);
|
||||
int max = FastMath.min(world.getMaxHeight(), range.getMax() + y);
|
||||
if(max <= min) return false;
|
||||
for(int i = min; i < max; i++) {
|
||||
if(!matches.test(world.getBlockState(x, i, z))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+6
@@ -7,12 +7,18 @@
|
||||
|
||||
package com.dfsek.terra.addons.feature.locator.patterns;
|
||||
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
|
||||
|
||||
public interface Pattern {
|
||||
boolean matches(int y, Column<?> column);
|
||||
|
||||
default boolean matches(WritableWorld world, int x, int y, int z) {
|
||||
return matches(y, world.column(x, z));
|
||||
}
|
||||
|
||||
|
||||
default Pattern and(Pattern that) {
|
||||
return (y, column) -> this.matches(y, column) && that.matches(y, column);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.feature.locator.LocatorAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-locators/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-locators
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
config-feature: "0.1.+"
|
||||
generation-stage-feature: "0.1.+"
|
||||
config-feature: "1.+"
|
||||
generation-stage-feature: "1.+"
|
||||
@@ -1,11 +1,16 @@
|
||||
plugins {
|
||||
id("me.champeau.jmh") version "0.6.6"
|
||||
}
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
jmh("org.openjdk.jmh:jmh-core:1.35")
|
||||
jmh("org.openjdk.jmh:jmh-generator-annprocess:1.35")
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
api("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("com.dfsek.paralithic", "com.dfsek.terra.addons.noise.lib.paralithic")
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.noise.lib.jafama")
|
||||
}
|
||||
-108
@@ -1,108 +0,0 @@
|
||||
package com.dfsek.terra.noise_bench;
|
||||
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.cellular.CellularSampler;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import com.dfsek.terra.noise_bench.old.OldCellularSampler;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||
import org.openjdk.jmh.annotations.Fork;
|
||||
import org.openjdk.jmh.annotations.Level;
|
||||
import org.openjdk.jmh.annotations.Measurement;
|
||||
import org.openjdk.jmh.annotations.Mode;
|
||||
import org.openjdk.jmh.annotations.Scope;
|
||||
import org.openjdk.jmh.annotations.Setup;
|
||||
import org.openjdk.jmh.annotations.State;
|
||||
import org.openjdk.jmh.annotations.Warmup;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
|
||||
public class Cellular {
|
||||
private static final long SEED = ThreadLocalRandom.current().nextLong();
|
||||
@State(Scope.Benchmark)
|
||||
public static class OldCellularParameters {
|
||||
public int seed;
|
||||
|
||||
public int x;
|
||||
|
||||
public int y;
|
||||
|
||||
public int z;
|
||||
|
||||
public NoiseSampler sampler = new OldCellularSampler();
|
||||
|
||||
@Setup(Level.Iteration)
|
||||
public void setUp() {
|
||||
Random random = new Random(SEED);
|
||||
|
||||
seed = random.nextInt();
|
||||
x = random.nextInt();
|
||||
y = random.nextInt();
|
||||
z = random.nextInt();
|
||||
}
|
||||
}
|
||||
|
||||
@State(Scope.Benchmark)
|
||||
public static class CellularParameters {
|
||||
public int seed;
|
||||
|
||||
public int x;
|
||||
|
||||
public int y;
|
||||
|
||||
public int z;
|
||||
|
||||
public NoiseSampler sampler = new CellularSampler();
|
||||
|
||||
@Setup(Level.Iteration)
|
||||
public void setUp() {
|
||||
Random random = new Random(SEED);
|
||||
|
||||
seed = random.nextInt();
|
||||
x = random.nextInt();
|
||||
y = random.nextInt();
|
||||
z = random.nextInt();
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark()
|
||||
@Warmup(iterations = 25, time = 200, timeUnit = MILLISECONDS)
|
||||
@Measurement(iterations = 15, time = 200, timeUnit = MILLISECONDS)
|
||||
@Fork(warmups = 2, value = 3)
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
public void old2D(OldCellularParameters parameters, Blackhole blackhole) {
|
||||
blackhole.consume(parameters.sampler.noise(parameters.seed, parameters.x, parameters.y));
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Warmup(iterations = 25, time = 200, timeUnit = MILLISECONDS)
|
||||
@Measurement(iterations = 15, time = 200, timeUnit = MILLISECONDS)
|
||||
@Fork(warmups = 2, value = 3)
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
public void old3D(OldCellularParameters parameters, Blackhole blackhole) {
|
||||
blackhole.consume(parameters.sampler.noise(parameters.seed, parameters.x, parameters.y, parameters.z));
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Warmup(iterations = 25, time = 200, timeUnit = MILLISECONDS)
|
||||
@Measurement(iterations = 15, time = 200, timeUnit = MILLISECONDS)
|
||||
@Fork(warmups = 2, value = 3)
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
public void new2D(CellularParameters parameters, Blackhole blackhole) {
|
||||
blackhole.consume(parameters.sampler.noise(parameters.seed, parameters.x, parameters.y));
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Warmup(iterations = 25, time = 200, timeUnit = MILLISECONDS)
|
||||
@Measurement(iterations = 15, time = 200, timeUnit = MILLISECONDS)
|
||||
@Fork(warmups = 2, value = 3)
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
public void new3D(CellularParameters parameters, Blackhole blackhole) {
|
||||
blackhole.consume(parameters.sampler.noise(parameters.seed, parameters.x, parameters.y, parameters.z));
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -32,6 +32,7 @@ import com.dfsek.terra.addons.noise.config.templates.noise.fractal.RidgedFractal
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ClampNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.NormalNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.PosterizationNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ProbabilityNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ScaleNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.AdditionSampler;
|
||||
@@ -40,7 +41,7 @@ import com.dfsek.terra.addons.noise.samplers.arithmetic.MaxSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.MinSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.MultiplicationSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.SubtractionSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.cellular.CellularSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.CellularSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.random.GaussianNoiseSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.random.PositiveWhiteNoiseSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.random.WhiteNoiseSampler;
|
||||
@@ -90,6 +91,7 @@ public class NoiseAddon implements AddonInitializer {
|
||||
noiseRegistry.register(addon.key("CLAMP"), ClampNormalizerTemplate::new);
|
||||
noiseRegistry.register(addon.key("PROBABILITY"), ProbabilityNormalizerTemplate::new);
|
||||
noiseRegistry.register(addon.key("SCALE"), ScaleNormalizerTemplate::new);
|
||||
noiseRegistry.register(addon.key("POSTERIZATION"), PosterizationNormalizerTemplate::new);
|
||||
|
||||
noiseRegistry.register(addon.key("IMAGE"), ImageSamplerTemplate::new);
|
||||
|
||||
@@ -121,7 +123,6 @@ public class NoiseAddon implements AddonInitializer {
|
||||
|
||||
noiseRegistry.register(addon.key("LINEAR_HEIGHTMAP"), LinearHeightmapSamplerTemplate::new);
|
||||
|
||||
|
||||
noiseRegistry.register(addon.key("ADD"), () -> new BinaryArithmeticTemplate<>(AdditionSampler::new));
|
||||
noiseRegistry.register(addon.key("SUB"), () -> new BinaryArithmeticTemplate<>(SubtractionSampler::new));
|
||||
noiseRegistry.register(addon.key("MUL"), () -> new BinaryArithmeticTemplate<>(MultiplicationSampler::new));
|
||||
|
||||
+14
@@ -13,6 +13,7 @@ import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
|
||||
@@ -45,4 +46,17 @@ public class FunctionTemplate implements ObjectTemplate<FunctionTemplate> {
|
||||
public LinkedHashMap<String, FunctionTemplate> getFunctions() {
|
||||
return functions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
FunctionTemplate that = (FunctionTemplate) o;
|
||||
return args.equals(that.args) && function.equals(that.function) && functions.equals(that.functions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(args, function, functions);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ package com.dfsek.terra.addons.noise.config.templates.noise;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.cellular.CellularSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.CellularSampler;
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.simplex.OpenSimplex2Sampler;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.noise.config.templates.normalizer;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.addons.noise.normalizer.PosterizationNormalizer;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||
public class PosterizationNormalizerTemplate extends NormalizerTemplate<PosterizationNormalizer> {
|
||||
@Value("steps")
|
||||
private @Meta int steps;
|
||||
|
||||
@Override
|
||||
public NoiseSampler get() {
|
||||
return new PosterizationNormalizer(function, steps);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.noise.normalizer;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class PosterizationNormalizer extends Normalizer {
|
||||
private final double stepSize;
|
||||
|
||||
public PosterizationNormalizer(NoiseSampler sampler, int steps) {
|
||||
super(sampler);
|
||||
this.stepSize = 2.0 / (steps - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double normalize(double in) {
|
||||
return FastMath.roundToInt((in + 1) / stepSize) * stepSize - 1;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user