Compare commits

..

5 Commits

Author SHA1 Message Date
Astrash c0aaf6c6e8 Add messages to exceptions 2023-11-28 10:36:30 +11:00
Astrash 1ab3233cba Reformat code 2023-11-25 15:14:16 +11:00
Astrash 59ea5a69d8 Refactor pack loading
- Combine initial load and reload logic together between each platform implementation
- Should prevent pack load errors from blocking other packs from loading.
2023-11-25 15:10:43 +11:00
Astrash 4ba71e9c27 packDirectory -> rootPath 2023-11-25 15:07:45 +11:00
Astrash 5c7441241c Replace Loader with java.nio.files 2023-11-25 13:31:42 +11:00
803 changed files with 5498 additions and 12409 deletions
+3 -4
View File
@@ -1,14 +1,13 @@
# Global owners, automatically request review when pull request is submitted # Global owners, automatically request review when pull request is submitted
* @dfsek @solonovamax @duplexsystem @astrsh @justaureus * @dfsek @solonovamax @duplexsystem @Astrashh @justaureus
# Platforms # Platforms
/platforms/ @dfsek @solonovamax @duplexsystem @justaureus /platforms/ @dfsek @solonovamax @duplexsystem @justaureus
/platforms/bukkit @dfsek @solonovamax @duplexsystem @justaureus @OakLoaf
# Common # Common
/common/ @dfsek @solonovamax @duplexsystem @astrsh /common/ @dfsek @solonovamax @duplexsystem @Astrashh
# Gradle Stuff # Gradle Stuff
/buildSrc/ @dfsek @solonovamax @duplexsystem /buildSrc/ @dfsek @solonovamax @duplexsystem
*.gradle.kts @dfsek @solonovamax @duplexsystem *.gradle.kts @dfsek @solonovamax @duplexsystem
/gradle/ @dfsek @solonovamax @duplexsystem /gradle/ @dfsek @solonovamax @duplexsystem
-47
View File
@@ -1,47 +0,0 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
name: Gradle Build
on: [ pull_request ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4.2.2
- name: Set up JDK 21
uses: actions/setup-java@v4.7.1
with:
java-version: '21'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- uses: burrunan/gradle-cache-action@v3.0.1
name: Build Terra
with:
# Specifies arguments for Gradle execution
# If arguments is missing or empty, then Gradle is not executed
arguments: build
# arguments can be multi-line for better readability
# arguments: |
# --no-paralell
# build
# -x test
# Gradle version to use for execution:
# wrapper (default), current, rc, nightly, release-nightly, or
# versions like 6.6 (see https://services.gradle.org/versions/all)
gradle-version: wrapper
# Properties are passed as -Pname=value
properties: |
kotlin.js.compiler=ir
kotlin.parallel.tasks.in.project=true
-2
View File
@@ -249,5 +249,3 @@ nbdist/
platforms/**/run/** platforms/**/run/**
#Vale Config File
**/.vale.ini
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2025 Polyhedral Development Copyright (c) 2020-2023 Polyhedral Development
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
+4 -6
View File
@@ -1,8 +1,8 @@
preRelease(true) preRelease(true)
versionProjects(":common:api", version("6.6.5")) versionProjects(":common:api", version("6.5.0"))
versionProjects(":common:implementation", version("6.6.5")) versionProjects(":common:implementation", version("6.5.0"))
versionProjects(":platforms", version("6.6.5")) versionProjects(":platforms", version("6.5.0"))
allprojects { allprojects {
@@ -15,7 +15,6 @@ allprojects {
tasks.withType<JavaCompile>().configureEach { tasks.withType<JavaCompile>().configureEach {
options.isFork = true options.isFork = true
options.isIncremental = true options.isIncremental = true
options.release.set(21)
} }
tasks.withType<Test>().configureEach { tasks.withType<Test>().configureEach {
@@ -44,9 +43,8 @@ afterEvaluate {
configureDistribution() configureDistribution()
} }
project(":platforms:bukkit:common").configureDistribution() project(":platforms:bukkit:common").configureDistribution()
project(":platforms:minestom:example").configureDistribution()
forSubProjects(":common:addons") { forSubProjects(":common:addons") {
apply(plugin = "com.gradleup.shadow") apply(plugin = "com.github.johnrengelman.shadow")
tasks.named("build") { tasks.named("build") {
finalizedBy(tasks.named("shadowJar")) finalizedBy(tasks.named("shadowJar"))
+7 -13
View File
@@ -6,27 +6,21 @@ plugins {
repositories { repositories {
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
maven("https://maven.solo-studios.ca/releases") {
name = "Solo Studios"
}
maven("https://maven.solo-studios.ca/snapshots") {
name = "Solo Studios"
}
maven("https://repo.codemc.org/repository/maven-public") { maven("https://repo.codemc.org/repository/maven-public") {
name = "CodeMC" name = "CodeMC"
} }
maven("https://repo.papermc.io/repository/maven-public/") { maven("https://papermc.io/repo/repository/maven-public/") {
name = "PaperMC" name = "PaperMC"
} }
} }
dependencies { dependencies {
//TODO Allow pulling from Versions.kt //TODO Allow pulling from Versions.kt
implementation("com.gradleup.shadow", "shadow-gradle-plugin", "8.3.6") implementation("com.github.johnrengelman", "shadow", "8.1.1")
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "1.5.6")
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin", "2.0.0-beta.17") implementation("org.ow2.asm", "asm", "9.5")
implementation("org.ow2.asm", "asm", "9.8") implementation("org.ow2.asm", "asm-tree", "9.5")
implementation("org.ow2.asm", "asm-tree", "9.8") implementation("com.dfsek.tectonic", "common", "4.2.0")
implementation("com.dfsek.tectonic", "common", "4.2.1") implementation("org.yaml", "snakeyaml", "2.2")
implementation("org.yaml", "snakeyaml", "2.4")
} }
@@ -22,8 +22,8 @@ fun Project.configureCompilation() {
apply<TectonicDocPlugin>() apply<TectonicDocPlugin>()
configure<JavaPluginExtension> { configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_21 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_17
} }
tasks.withType<JavaCompile> { tasks.withType<JavaCompile> {
+8 -26
View File
@@ -30,19 +30,13 @@ fun Project.configureDependencies() {
repositories { repositories {
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
maven("https://maven.solo-studios.ca/releases") {
name = "Solo Studios"
}
maven("https://maven.solo-studios.ca/snapshots") {
name = "Solo Studios"
}
maven("https://maven.fabricmc.net/") { maven("https://maven.fabricmc.net/") {
name = "FabricMC" name = "FabricMC"
} }
maven("https://repo.codemc.org/repository/maven-public") { maven("https://repo.codemc.org/repository/maven-public") {
name = "CodeMC" name = "CodeMC"
} }
maven("https://repo.papermc.io/repository/maven-public/") { maven("https://papermc.io/repo/repository/maven-public/") {
name = "PaperMC" name = "PaperMC"
} }
maven("https://files.minecraftforge.net/maven/") { maven("https://files.minecraftforge.net/maven/") {
@@ -54,29 +48,17 @@ fun Project.configureDependencies() {
maven("https://jitpack.io") { maven("https://jitpack.io") {
name = "JitPack" name = "JitPack"
} }
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") { maven("https://nexuslite.gcnt.net/repos/other/") {
name = "Sonatype Snapshots" name = "GCNT"
}
maven("https://repo.opencollab.dev/maven-releases/") {
name = "OpenCollab Releases"
}
maven("https://repo.opencollab.dev/maven-snapshots/") {
name = "OpenCollab Snapshots"
}
maven("https://storehouse.okaeri.eu/repository/maven-public/") {
name = "Okaeri"
}
maven("https://repo.onarandombox.com/multiverse-releases") {
name = "onarandombox"
} }
} }
dependencies { dependencies {
testImplementation("org.junit.jupiter", "junit-jupiter", Versions.Libraries.Internal.junit) testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
"testRuntimeOnly"("org.junit.platform", "junit-platform-launcher") testImplementation("org.junit.jupiter:junit-jupiter-engine:5.7.0")
compileOnly("org.jetbrains", "annotations", Versions.Libraries.Internal.jetBrainsAnnotations) compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("com.google.guava", "guava", Versions.Libraries.Internal.guava) compileOnly("com.google.guava:guava:30.0-jre")
testImplementation("com.google.guava", "guava", Versions.Libraries.Internal.guava) testImplementation("com.google.guava:guava:30.0-jre")
} }
} }
+24 -39
View File
@@ -4,11 +4,9 @@ import java.io.File
import java.io.FileWriter import java.io.FileWriter
import java.net.URL import java.net.URL
import java.nio.file.FileSystems import java.nio.file.FileSystems
import java.nio.file.Path
import org.gradle.api.DefaultTask import org.gradle.api.DefaultTask
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.plugins.BasePluginExtension import org.gradle.api.plugins.BasePluginExtension
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.extra
@@ -21,38 +19,16 @@ import kotlin.io.path.createDirectories
import kotlin.io.path.createFile import kotlin.io.path.createFile
import kotlin.io.path.exists import kotlin.io.path.exists
private fun Project.installAddonsInto(dest: Path) {
FileSystems.newFileSystem(dest, mapOf("create" to "false"), null).use { fs ->
forSubProjects(":common:addons") {
val jar = getJarTask()
logger.info("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 (!addonPath.exists()) {
addonPath.parent.createDirectories()
addonPath.createFile()
jar.archiveFile.get().asFile.toPath().copyTo(addonPath, overwrite = true)
}
}
}
}
fun Project.configureDistribution() { fun Project.configureDistribution() {
apply(plugin = "com.gradleup.shadow") apply(plugin = "com.github.johnrengelman.shadow")
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") { val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
group = "terra" group = "terra"
doFirst { doFirst {
try { file("${buildDir}/resources/main/packs/").deleteRecursively()
file("${buildDir}/resources/main/packs/").deleteRecursively() val defaultPackUrl = URL("https://github.com/PolyhedralDev/TerraOverworldConfig/releases/download/latest/default.zip")
val defaultPackUrl = downloadPack(defaultPackUrl, project)
URL("https://github.com/PolyhedralDev/TerraOverworldConfig/releases/download/" + Versions.Terra.overworldConfig + "/default.zip")
downloadPack(defaultPackUrl, project)
} catch (_:Exception) {}
} }
} }
@@ -71,17 +47,25 @@ fun Project.configureDistribution() {
doLast { doLast {
// https://github.com/johnrengelman/shadow/issues/111 // https://github.com/johnrengelman/shadow/issues/111
val dest = tasks.named<ShadowJar>("shadowJar").get().archiveFile.get().path val dest = tasks.named<ShadowJar>("shadowJar").get().archiveFile.get().path
installAddonsInto(dest)
}
} FileSystems.newFileSystem(dest, mapOf("create" to "false"), null).use { fs ->
forSubProjects(":common:addons") {
tasks.create("installAddonsIntoDefaultJar") { val jar = getJarTask()
group = "terra"
dependsOn(compileAddons) logger.info("Packaging addon ${jar.archiveFileName.get()} to $dest. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
doLast { val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val dest = tasks.named<Jar>("jar").get().archiveFile.get().path val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}")
installAddonsInto(dest)
if (!addonPath.exists()) {
addonPath.parent.createDirectories()
addonPath.createFile()
jar.archiveFile.get().asFile.toPath().copyTo(addonPath, overwrite = true)
}
}
}
} }
} }
@@ -148,6 +132,7 @@ fun Project.configureDistribution() {
version = project.version version = project.version
relocate("org.apache.commons", "com.dfsek.terra.lib.commons") relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm") 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.json", "com.dfsek.terra.lib.json")
relocate("org.yaml", "com.dfsek.terra.lib.yaml") relocate("org.yaml", "com.dfsek.terra.lib.yaml")
+36 -58
View File
@@ -1,35 +1,26 @@
object Versions { object Versions {
object Terra {
const val overworldConfig = "v1.5.2"
}
object Libraries { object Libraries {
const val tectonic = "4.2.1" const val tectonic = "4.2.1"
const val paralithic = "0.8.1" const val paralithic = "0.7.1"
const val strata = "1.3.2" const val strata = "1.3.2"
const val cloud = "2.0.0" const val cloud = "1.8.4"
const val caffeine = "3.2.1" const val slf4j = "2.0.9"
const val log4j_slf4j_impl = "2.20.0"
const val slf4j = "2.0.17"
object Internal { object Internal {
const val shadow = "8.3.6" const val shadow = "8.1.1"
const val apacheText = "1.13.1" const val apacheText = "1.10.0"
const val apacheIO = "2.19.0" const val apacheIO = "2.14.0"
const val guava = "33.4.8-jre" const val guava = "32.1.3-jre"
const val asm = "9.8" const val asm = "9.5"
const val snakeYml = "2.4" const val snakeYml = "2.2"
const val jetBrainsAnnotations = "26.0.2"
const val junit = "5.13.1"
const val nbt = "6.1"
} }
} }
object Fabric { object Fabric {
const val fabricAPI = "0.129.0+${Mod.minecraft}" const val fabricAPI = "0.90.0+${Mod.minecraft}"
const val cloud = "2.0.0-beta.11"
} }
// //
// object Quilt { // object Quilt {
@@ -38,37 +29,35 @@ object Versions {
// } // }
object Mod { object Mod {
const val mixin = "0.15.5+mixin.0.8.7" const val mixin = "0.12.5+mixin.0.8.5"
const val mixinExtras = "0.4.1"
const val minecraft = "1.21.8" const val minecraft = "1.20.2"
const val yarn = "$minecraft+build.1" const val yarn = "$minecraft+build.4"
const val fabricLoader = "0.16.14" const val fabricLoader = "0.14.23"
const val architecuryLoom = "1.10.431" const val architecuryLoom = "1.3.357"
const val architecturyPlugin = "3.4.161" const val architecturyPlugin = "3.4.146"
const val loomVineflower = "1.11.0"
}
object Forge {
const val forge = "${Mod.minecraft}-48.0.13"
const val burningwave = "12.63.0"
} }
//
// object Forge {
// const val forge = "${Mod.minecraft}-48.0.13"
// const val burningwave = "12.63.0"
// }
object Bukkit { object Bukkit {
const val minecraft = "1.21.8-R0.1" const val paper = "1.18.2-R0.1-SNAPSHOT"
const val paperBuild = "$minecraft-20250717.233435-4" const val paperLib = "1.0.5"
const val paper = paperBuild const val foliaLib = "0.2.5"
const val paperLib = "1.0.8" const val minecraft = "1.20.2"
const val reflectionRemapper = "0.1.2" const val reflectionRemapper = "0.1.0-SNAPSHOT"
const val paperDevBundle = paperBuild const val paperDevBundle = "1.20.2-R0.1-SNAPSHOT"
const val runPaper = "2.3.1" const val runPaper = "2.2.0"
const val paperWeight = "2.0.0-beta.17" const val paperWeight = "1.5.6"
const val cloud = "2.0.0-beta.11"
const val multiverse = "5.0.2"
} }
// //
// object Sponge { // object Sponge {
// const val sponge = "9.0.0-SNAPSHOT" // const val sponge = "9.0.0-SNAPSHOT"
// const val mixin = "0.8.2" // const val mixin = "0.8.2"
@@ -76,18 +65,7 @@ object Versions {
// } // }
// //
object CLI { object CLI {
const val logback = "1.5.18" const val nbt = "6.1"
const val picocli = "4.7.7" const val logback = "1.4.11"
} }
}
object Allay {
const val api = "0.4.1"
const val gson = "2.13.1"
const val mappings = "3626653"
const val mappingsGenerator = "366618e"
}
object Minestom {
const val minestom = "1_21_6-c3ccee696b"
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2025 Polyhedral Development Copyright (c) 2020-2023 Polyhedral Development
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,9 +1,9 @@
package com.dfsek.terra.addons.biome.extrusion.api; package com.dfsek.terra.addons.biome.extrusion.api;
import com.dfsek.terra.api.world.biome.Biome;
import java.util.Collection; import java.util.Collection;
import com.dfsek.terra.api.world.biome.Biome;
public interface Extrusion { public interface Extrusion {
Biome extrude(Biome original, int x, int y, int z, long seed); Biome extrude(Biome original, int x, int y, int z, long seed);
@@ -1,9 +1,5 @@
package com.dfsek.terra.addons.biome.extrusion.extrusions; 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.Extrusion;
import com.dfsek.terra.addons.biome.extrusion.api.ReplaceableBiome; import com.dfsek.terra.addons.biome.extrusion.api.ReplaceableBiome;
import com.dfsek.terra.addons.biome.query.api.BiomeQueries; import com.dfsek.terra.addons.biome.query.api.BiomeQueries;
@@ -12,6 +8,10 @@ import com.dfsek.terra.api.util.Range;
import com.dfsek.terra.api.util.collection.ProbabilityCollection; import com.dfsek.terra.api.util.collection.ProbabilityCollection;
import com.dfsek.terra.api.world.biome.Biome; import com.dfsek.terra.api.world.biome.Biome;
import java.util.Collection;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/** /**
* Sets biomes at locations based on a sampler. * Sets biomes at locations based on a sampler.
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2025 Polyhedral Development Copyright (c) 2020-2023 Polyhedral Development
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2025 Polyhedral Development Copyright (c) 2020-2023 Polyhedral Development
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2025 Polyhedral Development Copyright (c) 2020-2023 Polyhedral Development
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,7 +1,5 @@
package com.dfsek.terra.addons.biome.pipeline.v2; package com.dfsek.terra.addons.biome.pipeline.v2;
import com.dfsek.terra.api.util.cache.SeededVector2Key;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache; import com.github.benmanes.caffeine.cache.LoadingCache;
@@ -13,6 +11,7 @@ import java.util.stream.StreamSupport;
import com.dfsek.terra.addons.biome.pipeline.v2.api.BiomeChunk; import com.dfsek.terra.addons.biome.pipeline.v2.api.BiomeChunk;
import com.dfsek.terra.addons.biome.pipeline.v2.api.Pipeline; import com.dfsek.terra.addons.biome.pipeline.v2.api.Pipeline;
import com.dfsek.terra.addons.biome.pipeline.v2.api.SeededVector;
import com.dfsek.terra.addons.biome.pipeline.v2.api.Stage; import com.dfsek.terra.addons.biome.pipeline.v2.api.Stage;
import com.dfsek.terra.addons.biome.pipeline.v2.api.biome.PipelineBiome; import com.dfsek.terra.addons.biome.pipeline.v2.api.biome.PipelineBiome;
import com.dfsek.terra.api.noise.NoiseSampler; import com.dfsek.terra.api.noise.NoiseSampler;
@@ -24,7 +23,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
public class PipelineBiomeProvider implements BiomeProvider { public class PipelineBiomeProvider implements BiomeProvider {
private final LoadingCache<SeededVector2Key, BiomeChunk> biomeChunkCache; private final LoadingCache<SeededVector, BiomeChunk> biomeChunkCache;
private final int chunkSize; private final int chunkSize;
private final int resolution; private final int resolution;
private final NoiseSampler mutator; private final NoiseSampler mutator;
@@ -91,7 +90,7 @@ public class PipelineBiomeProvider implements BiomeProvider {
int xInChunk = x - chunkWorldX; int xInChunk = x - chunkWorldX;
int zInChunk = z - chunkWorldZ; int zInChunk = z - chunkWorldZ;
return biomeChunkCache.get(new SeededVector2Key(chunkWorldX, chunkWorldZ, seed)).get(xInChunk, zInChunk).getBiome(); return biomeChunkCache.get(new SeededVector(seed, chunkWorldX, chunkWorldZ)).get(xInChunk, zInChunk).getBiome();
} }
@Override @Override
@@ -1,12 +1,10 @@
package com.dfsek.terra.addons.biome.pipeline.v2.api; package com.dfsek.terra.addons.biome.pipeline.v2.api;
import com.dfsek.terra.api.util.cache.SeededVector2Key;
import java.util.List; import java.util.List;
public interface Pipeline { public interface Pipeline {
BiomeChunk generateChunk(SeededVector2Key worldCoordinates); BiomeChunk generateChunk(SeededVector worldCoordinates);
int getChunkSize(); int getChunkSize();
@@ -0,0 +1,19 @@
package com.dfsek.terra.addons.biome.pipeline.v2.api;
public record SeededVector(long seed, int x, int z) {
@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,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -29,7 +29,7 @@ public class BiomePipelineTemplate implements ObjectTemplate<BiomeProvider> {
@Default @Default
@Description(""" @Description("""
The resolution at which to sample biomes. The resolution at which to sample biomes.
Larger values are quadratically faster, but produce lower quality results. Larger values are quadratically faster, but produce lower quality results.
For example, a value of 3 would sample every 3 blocks.""") For example, a value of 3 would sample every 3 blocks.""")
protected @Meta int resolution = 1; protected @Meta int resolution = 1;
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -4,33 +4,32 @@ import java.util.List;
import com.dfsek.terra.addons.biome.pipeline.v2.api.BiomeChunk; import com.dfsek.terra.addons.biome.pipeline.v2.api.BiomeChunk;
import com.dfsek.terra.addons.biome.pipeline.v2.api.Expander; import com.dfsek.terra.addons.biome.pipeline.v2.api.Expander;
import com.dfsek.terra.addons.biome.pipeline.v2.api.SeededVector;
import com.dfsek.terra.addons.biome.pipeline.v2.api.Stage; import com.dfsek.terra.addons.biome.pipeline.v2.api.Stage;
import com.dfsek.terra.addons.biome.pipeline.v2.api.biome.PipelineBiome; import com.dfsek.terra.addons.biome.pipeline.v2.api.biome.PipelineBiome;
import com.dfsek.terra.api.util.cache.SeededVector2Key;
public class BiomeChunkImpl implements BiomeChunk { public class BiomeChunkImpl implements BiomeChunk {
private final SeededVector2Key worldOrigin; private final SeededVector worldOrigin;
private final int chunkOriginArrayIndex; private final int chunkOriginArrayIndex;
private final int worldCoordinateScale; private final int worldCoordinateScale;
private final int size; private PipelineBiome[][] biomes;
private PipelineBiome[] biomes;
public BiomeChunkImpl(SeededVector2Key worldOrigin, PipelineImpl pipeline) { public BiomeChunkImpl(SeededVector worldOrigin, PipelineImpl pipeline) {
this.worldOrigin = worldOrigin; this.worldOrigin = worldOrigin;
this.chunkOriginArrayIndex = pipeline.getChunkOriginArrayIndex(); this.chunkOriginArrayIndex = pipeline.getChunkOriginArrayIndex();
this.worldCoordinateScale = pipeline.getResolution(); this.worldCoordinateScale = pipeline.getResolution();
this.size = pipeline.getArraySize(); int size = pipeline.getArraySize();
int expanderCount = pipeline.getExpanderCount(); int expanderCount = pipeline.getExpanderCount();
int expansionsApplied = 0; int expansionsApplied = 0;
// Allocate working arrays // Allocate working arrays
this.biomes = new PipelineBiome[size * size]; this.biomes = new PipelineBiome[size][size];
PipelineBiome[] lookupArray = new PipelineBiome[size * size]; PipelineBiome[][] lookupArray = new PipelineBiome[size][size];
// A second lookup array is required such that stage application doesn't affect lookups, otherwise application may cascade // A second lookup array is required such that stage application doesn't affect lookups, otherwise application may cascade
// Construct working grid // Construct working grid
@@ -44,7 +43,7 @@ public class BiomeChunkImpl implements BiomeChunk {
for(int gridZ = 0; gridZ < gridSize; gridZ++) { for(int gridZ = 0; gridZ < gridSize; gridZ++) {
int xIndex = gridOrigin + gridX * gridInterval; int xIndex = gridOrigin + gridX * gridInterval;
int zIndex = gridOrigin + gridZ * gridInterval; int zIndex = gridOrigin + gridZ * gridInterval;
biomes[(xIndex * size) + zIndex] = pipeline.getSource().get(worldOrigin.seed, xIndexToWorldCoordinate(xIndex), biomes[xIndex][zIndex] = pipeline.getSource().get(worldOrigin.seed(), xIndexToWorldCoordinate(xIndex),
zIndexToWorldCoordinate(zIndex)); zIndexToWorldCoordinate(zIndex));
} }
} }
@@ -66,7 +65,7 @@ public class BiomeChunkImpl implements BiomeChunk {
// Cycle arrays, the previously populated array is swapped to be used for lookups, and the result of the stage application // Cycle arrays, the previously populated array is swapped to be used for lookups, and the result of the stage application
// overwrites the previous lookup array. This saves having to allocate a new array copy each time // overwrites the previous lookup array. This saves having to allocate a new array copy each time
PipelineBiome[] tempArray = biomes; PipelineBiome[][] tempArray = biomes;
biomes = lookupArray; biomes = lookupArray;
lookupArray = tempArray; lookupArray = tempArray;
@@ -75,8 +74,7 @@ public class BiomeChunkImpl implements BiomeChunk {
for(int gridX = 0; gridX < gridSize; gridX = gridX + 1) { for(int gridX = 0; gridX < gridSize; gridX = gridX + 1) {
int xIndex = gridOrigin + gridX * gridInterval; int xIndex = gridOrigin + gridX * gridInterval;
int zIndex = gridOrigin + gridZ * gridInterval; int zIndex = gridOrigin + gridZ * gridInterval;
biomes[(xIndex * size) + zIndex] = stage.apply( biomes[xIndex][zIndex] = stage.apply(new ViewPoint(this, gridInterval, gridX, gridZ, xIndex, zIndex, lookupArray));
new ViewPoint(this, gridInterval, gridX, gridZ, xIndex, zIndex, lookupArray, size));
} }
} }
} }
@@ -135,18 +133,18 @@ public class BiomeChunkImpl implements BiomeChunk {
public PipelineBiome get(int xInChunk, int zInChunk) { public PipelineBiome get(int xInChunk, int zInChunk) {
int xIndex = xInChunk + chunkOriginArrayIndex; int xIndex = xInChunk + chunkOriginArrayIndex;
int zIndex = zInChunk + chunkOriginArrayIndex; int zIndex = zInChunk + chunkOriginArrayIndex;
return biomes[(xIndex * size) + zIndex]; return biomes[xIndex][zIndex];
} }
private int xIndexToWorldCoordinate(int xIndex) { private int xIndexToWorldCoordinate(int xIndex) {
return (worldOrigin.x + xIndex - chunkOriginArrayIndex) * worldCoordinateScale; return (worldOrigin.x() + xIndex - chunkOriginArrayIndex) * worldCoordinateScale;
} }
private int zIndexToWorldCoordinate(int zIndex) { private int zIndexToWorldCoordinate(int zIndex) {
return (worldOrigin.z + zIndex - chunkOriginArrayIndex) * worldCoordinateScale; return (worldOrigin.z() + zIndex - chunkOriginArrayIndex) * worldCoordinateScale;
} }
private SeededVector2Key getOrigin() { private SeededVector getOrigin() {
return worldOrigin; return worldOrigin;
} }
@@ -161,11 +159,10 @@ public class BiomeChunkImpl implements BiomeChunk {
private final int gridZ; private final int gridZ;
private final int xIndex; private final int xIndex;
private final int zIndex; private final int zIndex;
private final PipelineBiome[] lookupArray; private final PipelineBiome[][] lookupArray;
private final int size;
private ViewPoint(BiomeChunkImpl chunk, int gridInterval, int gridX, int gridZ, int xIndex, int zIndex, private ViewPoint(BiomeChunkImpl chunk, int gridInterval, int gridX, int gridZ, int xIndex, int zIndex,
PipelineBiome[] lookupArray, int size) { PipelineBiome[][] lookupArray) {
this.chunk = chunk; this.chunk = chunk;
this.gridInterval = gridInterval; this.gridInterval = gridInterval;
this.gridX = gridX; this.gridX = gridX;
@@ -173,14 +170,13 @@ public class BiomeChunkImpl implements BiomeChunk {
this.xIndex = xIndex; this.xIndex = xIndex;
this.zIndex = zIndex; this.zIndex = zIndex;
this.lookupArray = lookupArray; this.lookupArray = lookupArray;
this.size = size; this.biome = lookupArray[xIndex][zIndex];
this.biome = lookupArray[(this.xIndex * this.size) + this.zIndex];
} }
public PipelineBiome getRelativeBiome(int x, int z) { public PipelineBiome getRelativeBiome(int x, int z) {
int lookupXIndex = this.xIndex + x * gridInterval; int lookupXIndex = this.xIndex + x * gridInterval;
int lookupZIndex = this.zIndex + z * gridInterval; int lookupZIndex = this.zIndex + z * gridInterval;
return lookupArray[(lookupXIndex * this.size) + lookupZIndex]; return lookupArray[lookupXIndex][lookupZIndex];
} }
public PipelineBiome getBiome() { public PipelineBiome getBiome() {
@@ -216,7 +212,7 @@ public class BiomeChunkImpl implements BiomeChunk {
} }
public long worldSeed() { public long worldSeed() {
return chunk.getOrigin().seed; return chunk.getOrigin().seed();
} }
} }
} }
@@ -1,7 +1,5 @@
package com.dfsek.terra.addons.biome.pipeline.v2.pipeline; package com.dfsek.terra.addons.biome.pipeline.v2.pipeline;
import com.dfsek.terra.api.util.cache.SeededVector2Key;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -10,6 +8,7 @@ import java.util.List;
import com.dfsek.terra.addons.biome.pipeline.v2.api.BiomeChunk; import com.dfsek.terra.addons.biome.pipeline.v2.api.BiomeChunk;
import com.dfsek.terra.addons.biome.pipeline.v2.api.Expander; import com.dfsek.terra.addons.biome.pipeline.v2.api.Expander;
import com.dfsek.terra.addons.biome.pipeline.v2.api.Pipeline; import com.dfsek.terra.addons.biome.pipeline.v2.api.Pipeline;
import com.dfsek.terra.addons.biome.pipeline.v2.api.SeededVector;
import com.dfsek.terra.addons.biome.pipeline.v2.api.Source; import com.dfsek.terra.addons.biome.pipeline.v2.api.Source;
import com.dfsek.terra.addons.biome.pipeline.v2.api.Stage; import com.dfsek.terra.addons.biome.pipeline.v2.api.Stage;
@@ -56,7 +55,7 @@ public class PipelineImpl implements Pipeline {
} }
@Override @Override
public BiomeChunk generateChunk(SeededVector2Key worldCoordinates) { public BiomeChunk generateChunk(SeededVector worldCoordinates) {
return new BiomeChunkImpl(worldCoordinates, this); return new BiomeChunkImpl(worldCoordinates, this);
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2025 Polyhedral Development Copyright (c) 2020-2023 Polyhedral Development
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -28,7 +28,7 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
@Description(""" @Description("""
The initial size of biome chunks. This value must be at least 2. 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>. <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] 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 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 take initial-size and for each expand stage, multiply the running value by 2
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -22,7 +22,7 @@ public abstract class BiomeProviderTemplate implements ObjectTemplate<BiomeProvi
@Default @Default
@Description(""" @Description("""
The resolution at which to sample biomes. The resolution at which to sample biomes.
Larger values are quadratically faster, but produce lower quality results. Larger values are quadratically faster, but produce lower quality results.
For example, a value of 3 would sample every 3 blocks.""") For example, a value of 3 would sample every 3 blocks.""")
protected @Meta int resolution = 1; protected @Meta int resolution = 1;
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2025 Polyhedral Development Copyright (c) 2020-2023 Polyhedral Development
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2020-2025 Polyhedral Development Copyright (c) 2020-2023 Polyhedral Development
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -13,7 +13,6 @@ 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.BiomePaletteTemplate;
import com.dfsek.terra.addons.chunkgenerator.config.palette.slant.SlantLayerTemplate; import com.dfsek.terra.addons.chunkgenerator.config.palette.slant.SlantLayerTemplate;
import com.dfsek.terra.addons.chunkgenerator.generation.NoiseChunkGenerator3D; import com.dfsek.terra.addons.chunkgenerator.generation.NoiseChunkGenerator3D;
import com.dfsek.terra.addons.chunkgenerator.generation.math.SlantCalculationMethod;
import com.dfsek.terra.addons.chunkgenerator.palette.BiomePaletteInfo; import com.dfsek.terra.addons.chunkgenerator.palette.BiomePaletteInfo;
import com.dfsek.terra.addons.chunkgenerator.palette.slant.SlantHolder; import com.dfsek.terra.addons.chunkgenerator.palette.slant.SlantHolder;
import com.dfsek.terra.addons.manifest.api.AddonInitializer; import com.dfsek.terra.addons.manifest.api.AddonInitializer;
@@ -46,8 +45,8 @@ public class NoiseChunkGenerator3DAddon implements AddonInitializer {
.priority(1000) .priority(1000)
.then(event -> { .then(event -> {
event.getPack().applyLoader(SlantCalculationMethod.class, event.getPack().applyLoader(SlantHolder.CalculationMethod.class,
(type, o, loader, depthTracker) -> SlantCalculationMethod.valueOf((String) o)); (type, o, loader, depthTracker) -> SlantHolder.CalculationMethod.valueOf((String) o));
NoiseChunkGeneratorPackConfigTemplate config = event.loadTemplate(new NoiseChunkGeneratorPackConfigTemplate()); NoiseChunkGeneratorPackConfigTemplate config = event.loadTemplate(new NoiseChunkGeneratorPackConfigTemplate());
event.getPack().getContext().put(config); event.getPack().getContext().put(config);
@@ -58,8 +57,7 @@ public class NoiseChunkGenerator3DAddon implements AddonInitializer {
pack -> new NoiseChunkGenerator3D(pack, platform, config.getElevationBlend(), pack -> new NoiseChunkGenerator3D(pack, platform, config.getElevationBlend(),
config.getHorizontalRes(), config.getHorizontalRes(),
config.getVerticalRes(), noisePropertiesPropertyKey, config.getVerticalRes(), noisePropertiesPropertyKey,
paletteInfoPropertyKey, config.getSlantCalculationMethod(), paletteInfoPropertyKey));
config.isSlantPalettesEnabled()));
event.getPack() event.getPack()
.applyLoader(SlantHolder.Layer.class, SlantLayerTemplate::new); .applyLoader(SlantHolder.Layer.class, SlantLayerTemplate::new);
}) })
@@ -4,7 +4,7 @@ import com.dfsek.tectonic.api.config.template.ConfigTemplate;
import com.dfsek.tectonic.api.config.template.annotations.Default; 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.annotations.Value;
import com.dfsek.terra.addons.chunkgenerator.generation.math.SlantCalculationMethod; import com.dfsek.terra.addons.chunkgenerator.palette.slant.SlantHolder;
import com.dfsek.terra.api.config.meta.Meta; import com.dfsek.terra.api.config.meta.Meta;
import com.dfsek.terra.api.properties.Properties; import com.dfsek.terra.api.properties.Properties;
@@ -24,11 +24,7 @@ public class NoiseChunkGeneratorPackConfigTemplate implements ConfigTemplate, Pr
@Value("slant.calculation-method") @Value("slant.calculation-method")
@Default @Default
private @Meta SlantCalculationMethod slantCalculationMethod = SlantCalculationMethod.Derivative; private SlantHolder.@Meta CalculationMethod slantCalculationMethod = SlantHolder.CalculationMethod.Derivative;
@Value("slant.disable-palettes")
@Default
private @Meta boolean disableSlantPalettes = false;
public int getElevationBlend() { public int getElevationBlend() {
return elevationBlend; return elevationBlend;
@@ -42,11 +38,7 @@ public class NoiseChunkGeneratorPackConfigTemplate implements ConfigTemplate, Pr
return verticalRes; return verticalRes;
} }
public SlantCalculationMethod getSlantCalculationMethod() { public SlantHolder.CalculationMethod getSlantCalculationMethod() {
return slantCalculationMethod; return slantCalculationMethod;
} }
public boolean isSlantPalettesEnabled() {
return !disableSlantPalettes;
}
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -16,7 +16,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.dfsek.terra.addons.chunkgenerator.generation.math.SlantCalculationMethod;
import com.dfsek.terra.addons.chunkgenerator.palette.BiomePaletteInfo; import com.dfsek.terra.addons.chunkgenerator.palette.BiomePaletteInfo;
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder; import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
import com.dfsek.terra.addons.chunkgenerator.palette.slant.SlantHolder; import com.dfsek.terra.addons.chunkgenerator.palette.slant.SlantHolder;
@@ -28,7 +27,7 @@ import com.dfsek.terra.api.world.chunk.generation.util.Palette;
public class BiomePaletteTemplate implements ObjectTemplate<BiomePaletteInfo> { public class BiomePaletteTemplate implements ObjectTemplate<BiomePaletteInfo> {
private final Platform platform; private final Platform platform;
private final SlantCalculationMethod slantCalculationMethod; private final SlantHolder.CalculationMethod slantCalculationMethod;
@Value("slant") @Value("slant")
@Default @Default
@Description("The slant palettes to use in this biome.") @Description("The slant palettes to use in this biome.")
@@ -57,7 +56,7 @@ public class BiomePaletteTemplate implements ObjectTemplate<BiomePaletteInfo> {
@Default @Default
private @Meta boolean updatePalette = false; private @Meta boolean updatePalette = false;
public BiomePaletteTemplate(Platform platform, SlantCalculationMethod slantCalculationMethod) { public BiomePaletteTemplate(Platform platform, SlantHolder.CalculationMethod slantCalculationMethod) {
this.platform = platform; this.platform = platform;
this.slantCalculationMethod = slantCalculationMethod; this.slantCalculationMethod = slantCalculationMethod;
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -11,12 +11,11 @@ package com.dfsek.terra.addons.chunkgenerator.generation;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties; import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
import com.dfsek.terra.addons.chunkgenerator.generation.math.SlantCalculationMethod; import com.dfsek.terra.addons.chunkgenerator.generation.math.PaletteUtil;
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.LazilyEvaluatedInterpolator; import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.LazilyEvaluatedInterpolator;
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D; import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider; import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider;
import com.dfsek.terra.addons.chunkgenerator.palette.BiomePaletteInfo; import com.dfsek.terra.addons.chunkgenerator.palette.BiomePaletteInfo;
import com.dfsek.terra.addons.chunkgenerator.palette.slant.SlantHolder;
import com.dfsek.terra.api.Platform; import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.config.ConfigPack; import com.dfsek.terra.api.config.ConfigPack;
@@ -43,23 +42,16 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
private final PropertyKey<BiomePaletteInfo> paletteInfoPropertyKey; private final PropertyKey<BiomePaletteInfo> paletteInfoPropertyKey;
private final PropertyKey<BiomeNoiseProperties> noisePropertiesKey; private final PropertyKey<BiomeNoiseProperties> noisePropertiesKey;
private final SlantCalculationMethod slantCalculationMethod;
private final boolean useSlantPalettes;
public NoiseChunkGenerator3D(ConfigPack pack, Platform platform, int elevationBlend, int carverHorizontalResolution, public NoiseChunkGenerator3D(ConfigPack pack, Platform platform, int elevationBlend, int carverHorizontalResolution,
int carverVerticalResolution, int carverVerticalResolution,
PropertyKey<BiomeNoiseProperties> noisePropertiesKey, PropertyKey<BiomeNoiseProperties> noisePropertiesKey,
PropertyKey<BiomePaletteInfo> paletteInfoPropertyKey, PropertyKey<BiomePaletteInfo> paletteInfoPropertyKey) {
SlantCalculationMethod slantCalculationMethod, boolean useSlantPalettes) {
this.platform = platform; this.platform = platform;
this.air = platform.getWorldHandle().air(); this.air = platform.getWorldHandle().air();
this.carverHorizontalResolution = carverHorizontalResolution; this.carverHorizontalResolution = carverHorizontalResolution;
this.carverVerticalResolution = carverVerticalResolution; this.carverVerticalResolution = carverVerticalResolution;
this.paletteInfoPropertyKey = paletteInfoPropertyKey; this.paletteInfoPropertyKey = paletteInfoPropertyKey;
this.noisePropertiesKey = noisePropertiesKey; this.noisePropertiesKey = noisePropertiesKey;
this.slantCalculationMethod = slantCalculationMethod;
this.useSlantPalettes = useSlantPalettes;
int maxBlend = pack int maxBlend = pack
.getBiomeProvider() .getBiomeProvider()
.stream() .stream()
@@ -71,17 +63,6 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
this.samplerCache = new SamplerProvider(platform, elevationBlend, noisePropertiesKey, maxBlend); this.samplerCache = new SamplerProvider(platform, elevationBlend, noisePropertiesKey, maxBlend);
} }
private Palette paletteAt(int x, int y, int z, Sampler3D sampler, BiomePaletteInfo paletteInfo, int depth) {
SlantHolder slantHolder = paletteInfo.slantHolder();
if(useSlantPalettes && slantHolder.isAboveDepth(depth)) {
double slant = slantCalculationMethod.slant(sampler, x, y, z);
if(slantHolder.isInSlantThreshold(slant)) {
return slantHolder.getPalette(slant).getPalette(y);
}
}
return paletteInfo.paletteHolder().getPalette(y);
}
@Override @Override
@SuppressWarnings("try") @SuppressWarnings("try")
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world, public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world,
@@ -122,7 +103,8 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
if(sampler.sample(x, y, z) > 0) { if(sampler.sample(x, y, z) > 0) {
if(carver.sample(x, y, z) <= 0) { if(carver.sample(x, y, z) <= 0) {
data = paletteAt(x, y, z, sampler, paletteInfo, paletteLevel) data = PaletteUtil
.getPalette(x, y, z, sampler, paletteInfo, paletteLevel)
.get(paletteLevel, cx, y, cz, seed); .get(paletteLevel, cx, y, cz, seed);
chunk.setBlock(x, y, z, data); chunk.setBlock(x, y, z, data);
paletteLevel++; paletteLevel++;
@@ -153,7 +135,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
int fdX = Math.floorMod(x, 16); int fdX = Math.floorMod(x, 16);
int fdZ = Math.floorMod(z, 16); int fdZ = Math.floorMod(z, 16);
Palette palette = paletteAt(fdX, y, fdZ, sampler, paletteInfo, 0); Palette palette = PaletteUtil.getPalette(fdX, y, fdZ, sampler, paletteInfo, 0);
double noise = sampler.sample(fdX, y, fdZ); double noise = sampler.sample(fdX, y, fdZ);
if(noise > 0) { if(noise > 0) {
int level = 0; int level = 0;
@@ -175,8 +157,11 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
public double getSlant(int x, int y, int z, WorldProperties world, BiomeProvider biomeProvider) { public double getSlant(int x, int y, int z, WorldProperties world, BiomeProvider biomeProvider) {
int fdX = Math.floorMod(x, 16); int fdX = Math.floorMod(x, 16);
int fdZ = Math.floorMod(z, 16); int fdZ = Math.floorMod(z, 16);
Sampler3D sampler = samplerCache.get(x, z, world, biomeProvider); return biomeProvider.getBiome(x, y, z, world.getSeed())
return slantCalculationMethod.slant(sampler, fdX, y, fdZ); .getContext()
.get(paletteInfoPropertyKey)
.slantHolder()
.calculateSlant(samplerCache.get(x, z, world, biomeProvider), fdX, y, fdZ);
} }
public SamplerProvider samplerProvider() { public SamplerProvider samplerProvider() {
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2020-2023 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.chunkgenerator.generation.math;
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
import com.dfsek.terra.addons.chunkgenerator.palette.BiomePaletteInfo;
import com.dfsek.terra.addons.chunkgenerator.palette.slant.SlantHolder;
import com.dfsek.terra.api.world.chunk.generation.util.Palette;
public final class PaletteUtil {
public static Palette getPalette(int x, int y, int z, Sampler3D sampler, BiomePaletteInfo paletteInfo, int depth) {
SlantHolder slantHolder = paletteInfo.slantHolder();
if(slantHolder.isAboveDepth(depth)) {
double slant = slantHolder.calculateSlant(sampler, x, y, z);
if(slantHolder.isInSlantThreshold(slant)) {
return slantHolder.getPalette(slant).getPalette(y);
}
}
return paletteInfo.paletteHolder().getPalette(y);
}
}
@@ -1,69 +0,0 @@
package com.dfsek.terra.addons.chunkgenerator.generation.math;
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
import com.dfsek.terra.api.util.vector.Vector3;
public enum SlantCalculationMethod {
DotProduct {
private static final Vector3 DOT_PRODUCT_DIRECTION = Vector3.of(0, 1, 0);
private static final Vector3[] DOT_PRODUCT_SAMPLE_POINTS = {
Vector3.of(0, 0, -DERIVATIVE_DIST),
Vector3.of(0, 0, DERIVATIVE_DIST),
Vector3.of(0, -DERIVATIVE_DIST, 0),
Vector3.of(0, DERIVATIVE_DIST, 0),
Vector3.of(-DERIVATIVE_DIST, 0, 0),
Vector3.of(DERIVATIVE_DIST, 0, 0)
};
@Override
public double slant(Sampler3D sampler, double x, double y, double z) {
Vector3.Mutable normalApproximation = Vector3.Mutable.of(0, 0, 0);
for(Vector3 point : DOT_PRODUCT_SAMPLE_POINTS) {
var scalar = -sampler.sample(x + point.getX(), y + point.getY(), z + point.getZ());
normalApproximation.add(point.mutable().multiply(scalar));
}
return DOT_PRODUCT_DIRECTION.dot(normalApproximation.normalize());
}
@Override
public boolean floorToThreshold() {
return false;
}
},
Derivative {
@Override
public double slant(Sampler3D sampler, double x, double y, double z) {
double baseSample = sampler.sample(x, y, z);
double xVal1 = (sampler.sample(x + DERIVATIVE_DIST, y, z) - baseSample) / DERIVATIVE_DIST;
double xVal2 = (sampler.sample(x - DERIVATIVE_DIST, y, z) - baseSample) / DERIVATIVE_DIST;
double zVal1 = (sampler.sample(x, y, z + DERIVATIVE_DIST) - baseSample) / DERIVATIVE_DIST;
double zVal2 = (sampler.sample(x, y, z - DERIVATIVE_DIST) - baseSample) / DERIVATIVE_DIST;
double yVal1 = (sampler.sample(x, y + DERIVATIVE_DIST, z) - baseSample) / DERIVATIVE_DIST;
double yVal2 = (sampler.sample(x, y - DERIVATIVE_DIST, z) - baseSample) / DERIVATIVE_DIST;
return Math.sqrt(
((xVal2 - xVal1) * (xVal2 - xVal1)) + ((zVal2 - zVal1) * (zVal2 - zVal1)) + ((yVal2 - yVal1) * (yVal2 - yVal1)));
}
@Override
public boolean floorToThreshold() {
return true;
}
};
private static final double DERIVATIVE_DIST = 0.55;
public abstract double slant(Sampler3D sampler, double x, double y, double z);
/*
* Controls whether palettes should be applied before or after their respective thresholds.
*
* If true, slant values will map to the palette of the next floor threshold, otherwise they
* will map to the ceiling.
*/
public abstract boolean floorToThreshold();
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020-2025 Polyhedral Development * Copyright (c) 2020-2023 Polyhedral Development
* *
* The Terra Core Addons are licensed under the terms of the MIT License. For more details, * 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. * reference the LICENSE file in this module's root directory.
@@ -14,7 +14,6 @@ import java.util.TreeMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.dfsek.terra.addons.chunkgenerator.generation.math.SlantCalculationMethod;
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder; import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
@@ -22,7 +21,7 @@ public class MultipleSlantHolder extends SlantHolderImpl {
private final NavigableMap<Double, PaletteHolder> layers; private final NavigableMap<Double, PaletteHolder> layers;
private final double slantThreshold; private final double slantThreshold;
MultipleSlantHolder(List<SlantHolder.Layer> slant, int slantDepth, SlantCalculationMethod calculationMethod) { MultipleSlantHolder(List<SlantHolder.Layer> slant, int slantDepth, CalculationMethod calculationMethod) {
super(slantDepth, calculationMethod); super(slantDepth, calculationMethod);
NavigableMap<Double, PaletteHolder> layers = new TreeMap<>( NavigableMap<Double, PaletteHolder> layers = new TreeMap<>(
slant.stream().collect(Collectors.toMap(SlantHolder.Layer::threshold, SlantHolder.Layer::palette))); slant.stream().collect(Collectors.toMap(SlantHolder.Layer::threshold, SlantHolder.Layer::palette)));
@@ -1,6 +1,5 @@
package com.dfsek.terra.addons.chunkgenerator.palette.slant; package com.dfsek.terra.addons.chunkgenerator.palette.slant;
import com.dfsek.terra.addons.chunkgenerator.generation.math.SlantCalculationMethod;
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder; import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
@@ -8,7 +7,7 @@ final class SingleSlantHolder extends SlantHolderImpl {
private final SlantHolder.Layer layer; private final SlantHolder.Layer layer;
public SingleSlantHolder(SlantHolder.Layer layer, int slantDepth, SlantCalculationMethod calculationMethod) { public SingleSlantHolder(SlantHolder.Layer layer, int slantDepth, CalculationMethod calculationMethod) {
super(slantDepth, calculationMethod); super(slantDepth, calculationMethod);
this.layer = layer; this.layer = layer;
} }
@@ -2,13 +2,19 @@ package com.dfsek.terra.addons.chunkgenerator.palette.slant;
import java.util.List; import java.util.List;
import com.dfsek.terra.addons.chunkgenerator.generation.math.SlantCalculationMethod; import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder; import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
import com.dfsek.terra.api.util.vector.Vector3;
public interface SlantHolder { public interface SlantHolder {
SlantHolder EMPTY = new SlantHolder() { SlantHolder EMPTY = new SlantHolder() {
@Override
public double calculateSlant(Sampler3D sampler, double x, double y, double z) {
throw new UnsupportedOperationException("Empty holder should not calculate slant");
}
@Override @Override
public boolean isAboveDepth(int depth) { public boolean isAboveDepth(int depth) {
return false; return false;
@@ -25,7 +31,7 @@ public interface SlantHolder {
} }
}; };
static SlantHolder of(List<SlantHolder.Layer> layers, int slantDepth, SlantCalculationMethod calculationMethod) { static SlantHolder of(List<SlantHolder.Layer> layers, int slantDepth, CalculationMethod calculationMethod) {
if(layers.isEmpty()) { if(layers.isEmpty()) {
return EMPTY; return EMPTY;
} else if(layers.size() == 1) { } else if(layers.size() == 1) {
@@ -34,6 +40,8 @@ public interface SlantHolder {
return new MultipleSlantHolder(layers, slantDepth, calculationMethod); return new MultipleSlantHolder(layers, slantDepth, calculationMethod);
} }
double calculateSlant(Sampler3D sampler, double x, double y, double z);
boolean isAboveDepth(int depth); boolean isAboveDepth(int depth);
boolean isInSlantThreshold(double slant); boolean isInSlantThreshold(double slant);
@@ -41,6 +49,71 @@ public interface SlantHolder {
PaletteHolder getPalette(double slant); PaletteHolder getPalette(double slant);
enum CalculationMethod {
DotProduct {
private static final Vector3 DOT_PRODUCT_DIRECTION = Vector3.of(0, 1, 0);
private static final Vector3[] DOT_PRODUCT_SAMPLE_POINTS = {
Vector3.of(0, 0, -DERIVATIVE_DIST),
Vector3.of(0, 0, DERIVATIVE_DIST),
Vector3.of(0, -DERIVATIVE_DIST, 0),
Vector3.of(0, DERIVATIVE_DIST, 0),
Vector3.of(-DERIVATIVE_DIST, 0, 0),
Vector3.of(DERIVATIVE_DIST, 0, 0)
};
@Override
public double slant(Sampler3D sampler, double x, double y, double z) {
Vector3.Mutable normalApproximation = Vector3.Mutable.of(0, 0, 0);
for(Vector3 point : DOT_PRODUCT_SAMPLE_POINTS) {
var scalar = -sampler.sample(x + point.getX(), y + point.getY(), z + point.getZ());
normalApproximation.add(point.mutable().multiply(scalar));
}
return DOT_PRODUCT_DIRECTION.dot(normalApproximation.normalize());
}
@Override
public boolean floorToThreshold() {
return false;
}
},
Derivative {
@Override
public double slant(Sampler3D sampler, double x, double y, double z) {
double baseSample = sampler.sample(x, y, z);
double xVal1 = (sampler.sample(x + DERIVATIVE_DIST, y, z) - baseSample) / DERIVATIVE_DIST;
double xVal2 = (sampler.sample(x - DERIVATIVE_DIST, y, z) - baseSample) / DERIVATIVE_DIST;
double zVal1 = (sampler.sample(x, y, z + DERIVATIVE_DIST) - baseSample) / DERIVATIVE_DIST;
double zVal2 = (sampler.sample(x, y, z - DERIVATIVE_DIST) - baseSample) / DERIVATIVE_DIST;
double yVal1 = (sampler.sample(x, y + DERIVATIVE_DIST, z) - baseSample) / DERIVATIVE_DIST;
double yVal2 = (sampler.sample(x, y - DERIVATIVE_DIST, z) - baseSample) / DERIVATIVE_DIST;
return Math.sqrt(
((xVal2 - xVal1) * (xVal2 - xVal1)) + ((zVal2 - zVal1) * (zVal2 - zVal1)) + ((yVal2 - yVal1) * (yVal2 - yVal1)));
}
@Override
public boolean floorToThreshold() {
return true;
}
};
private static final double DERIVATIVE_DIST = 0.55;
public abstract double slant(Sampler3D sampler, double x, double y, double z);
/*
* Controls whether palettes should be applied before or after their respective thresholds.
*
* If true, slant values will map to the palette of the next floor threshold, otherwise they
* will map to the ceiling.
*/
public abstract boolean floorToThreshold();
}
record Layer(PaletteHolder palette, double threshold) { record Layer(PaletteHolder palette, double threshold) {
} }
} }
@@ -1,19 +1,26 @@
package com.dfsek.terra.addons.chunkgenerator.palette.slant; package com.dfsek.terra.addons.chunkgenerator.palette.slant;
import com.dfsek.terra.addons.chunkgenerator.generation.math.SlantCalculationMethod; import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
public abstract class SlantHolderImpl implements SlantHolder { public abstract class SlantHolderImpl implements SlantHolder {
protected final boolean floorToThreshold; protected final boolean floorToThreshold;
private final SlantHolder.CalculationMethod calculationMethod;
private final int slantDepth; private final int slantDepth;
protected SlantHolderImpl(int slantDepth, SlantCalculationMethod calculationMethod) { protected SlantHolderImpl(int slantDepth, CalculationMethod calculationMethod) {
this.floorToThreshold = calculationMethod.floorToThreshold(); this.floorToThreshold = calculationMethod.floorToThreshold();
this.calculationMethod = calculationMethod;
this.slantDepth = slantDepth; this.slantDepth = slantDepth;
} }
protected abstract double getSlantThreshold(); protected abstract double getSlantThreshold();
@Override
public final double calculateSlant(Sampler3D sampler, double x, double y, double z) {
return calculationMethod.slant(sampler, x, y, z);
}
@Override @Override
public final boolean isAboveDepth(int depth) { public final boolean isAboveDepth(int depth) {
return depth <= slantDepth; return depth <= slantDepth;
@@ -1,7 +1,7 @@
package com.dfsek.terra.addons.commands.addons; package com.dfsek.terra.addons.commands.addons;
import org.incendo.cloud.CommandManager; import cloud.commandframework.ArgumentDescription;
import org.incendo.cloud.description.Description; import cloud.commandframework.CommandManager;
import com.dfsek.terra.addons.manifest.api.AddonInitializer; import com.dfsek.terra.addons.manifest.api.AddonInitializer;
import com.dfsek.terra.api.Platform; import com.dfsek.terra.api.Platform;
@@ -30,7 +30,7 @@ public class AddonsCommandAddon implements AddonInitializer {
CommandManager<CommandSender> manager = event.getCommandManager(); CommandManager<CommandSender> manager = event.getCommandManager();
manager.command( manager.command(
manager.commandBuilder("addons", Description.of("List installed Terra addons")) manager.commandBuilder("addons", ArgumentDescription.of("List installed Terra addons"))
.permission("terra.addons") .permission("terra.addons")
.handler(context -> { .handler(context -> {
StringBuilder addons = new StringBuilder("Installed addons:\n"); StringBuilder addons = new StringBuilder("Installed addons:\n");
@@ -41,7 +41,7 @@ public class AddonsCommandAddon implements AddonInitializer {
.append('@') .append('@')
.append(addon.getVersion().getFormatted()) .append(addon.getVersion().getFormatted())
.append('\n')); .append('\n'));
context.sender().sendMessage(addons.toString()); context.getSender().sendMessage(addons.toString());
}) })
) )
.command( .command(
@@ -61,7 +61,7 @@ public class AddonsCommandAddon implements AddonInitializer {
.append('@') .append('@')
.append(versions.getFormatted()) .append(versions.getFormatted())
.append('\n')); .append('\n'));
context.sender().sendMessage(addonInfo.toString()); context.getSender().sendMessage(addonInfo.toString());
}) })
); );
}); });
@@ -1,7 +1,7 @@
package com.dfsek.terra.addons.commands.packs; package com.dfsek.terra.addons.commands.packs;
import org.incendo.cloud.CommandManager; import cloud.commandframework.ArgumentDescription;
import org.incendo.cloud.description.Description; import cloud.commandframework.CommandManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -35,7 +35,7 @@ public class PacksCommandAddon implements AddonInitializer {
CommandManager<CommandSender> manager = event.getCommandManager(); CommandManager<CommandSender> manager = event.getCommandManager();
manager.command( manager.command(
manager.commandBuilder("packs", Description.of("List installed config packs")) manager.commandBuilder("packs", ArgumentDescription.of("List installed config packs"))
.permission("terra.packs") .permission("terra.packs")
.handler(context -> { .handler(context -> {
StringBuilder packs = new StringBuilder("Installed packs:\n"); StringBuilder packs = new StringBuilder("Installed packs:\n");
@@ -43,12 +43,12 @@ public class PacksCommandAddon implements AddonInitializer {
.append(pack.getID()) .append(pack.getID())
.append('@') .append('@')
.append(pack.getVersion().getFormatted())); .append(pack.getVersion().getFormatted()));
context.sender().sendMessage(packs.toString()); context.getSender().sendMessage(packs.toString());
}) })
) )
.command( .command(
manager.commandBuilder("packs") manager.commandBuilder("packs")
.literal("info", Description.of("Get information about a pack")) .literal("info", ArgumentDescription.of("Get information about a pack"))
.permission("terra.packs.info") .permission("terra.packs.info")
.argument(RegistryArgument.of("pack", platform.getConfigRegistry())) .argument(RegistryArgument.of("pack", platform.getConfigRegistry()))
.handler(context -> { .handler(context -> {
@@ -65,21 +65,21 @@ public class PacksCommandAddon implements AddonInitializer {
.append('@') .append('@')
.append(versions.getFormatted()) .append(versions.getFormatted())
.append('\n')); .append('\n'));
context.sender().sendMessage(packInfo.toString()); context.getSender().sendMessage(packInfo.toString());
})) }))
.command( .command(
manager.commandBuilder("packs") manager.commandBuilder("packs")
.literal("reload", Description.of("Reload config packs")) .literal("reload", ArgumentDescription.of("Reload config packs"))
.permission("terra.packs.reload") .permission("terra.packs.reload")
.handler(context -> { .handler(context -> {
context.sender().sendMessage("Reloading Terra..."); context.getSender().sendMessage("Reloading Terra...");
logger.info("Reloading Terra..."); logger.info("Reloading Terra...");
if(platform.reload()) { if(platform.reload()) {
logger.info("Terra reloaded successfully."); logger.info("Terra reloaded successfully.");
context.sender().sendMessage("Terra reloaded successfully."); context.getSender().sendMessage("Terra reloaded successfully.");
} else { } else {
logger.error("Terra failed to reload."); logger.error("Terra failed to reload.");
context.sender().sendMessage( context.getSender().sendMessage(
"Terra failed to reload. See logs for more information."); "Terra failed to reload. See logs for more information.");
} }
})); }));
@@ -1,7 +1,7 @@
package com.dfsek.terra.addons.commands.profiler; package com.dfsek.terra.addons.commands.profiler;
import org.incendo.cloud.CommandManager; import cloud.commandframework.ArgumentDescription;
import org.incendo.cloud.description.Description; import cloud.commandframework.CommandManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -33,24 +33,24 @@ public class ProfilerCommandAddon implements AddonInitializer {
CommandManager<CommandSender> manager = event.getCommandManager(); CommandManager<CommandSender> manager = event.getCommandManager();
manager manager
.command( .command(
manager.commandBuilder("profiler", Description.of("Access the profiler")) manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
.literal("start", Description.of("Start profiling"), "st") .literal("start", ArgumentDescription.of("Start profiling"), "st")
.permission("terra.profiler.start") .permission("terra.profiler.start")
.handler(context -> { .handler(context -> {
platform.getProfiler().start(); platform.getProfiler().start();
context.sender().sendMessage("Profiling started."); context.getSender().sendMessage("Profiling started.");
})) }))
.command( .command(
manager.commandBuilder("profiler", Description.of("Access the profiler")) manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
.literal("stop", Description.of("Stop profiling"), "s") .literal("stop", ArgumentDescription.of("Stop profiling"), "s")
.permission("terra.profiler.stop") .permission("terra.profiler.stop")
.handler(context -> { .handler(context -> {
platform.getProfiler().stop(); platform.getProfiler().stop();
context.sender().sendMessage("Profiling stopped."); context.getSender().sendMessage("Profiling stopped.");
})) }))
.command( .command(
manager.commandBuilder("profiler", Description.of("Access the profiler")) manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
.literal("query", Description.of("Query profiler results"), "q") .literal("query", ArgumentDescription.of("Query profiler results"), "q")
.permission("terra.profiler.query") .permission("terra.profiler.query")
.handler(context -> { .handler(context -> {
StringBuilder data = new StringBuilder("Terra Profiler data: \n"); StringBuilder data = new StringBuilder("Terra Profiler data: \n");
@@ -59,15 +59,15 @@ public class ProfilerCommandAddon implements AddonInitializer {
.append(timings.toString()) .append(timings.toString())
.append('\n')); .append('\n'));
logger.info(data.toString()); logger.info(data.toString());
context.sender().sendMessage("Profiling data dumped to console."); context.getSender().sendMessage("Profiling data dumped to console.");
})) }))
.command( .command(
manager.commandBuilder("profiler", Description.of("Access the profiler")) manager.commandBuilder("profiler", ArgumentDescription.of("Access the profiler"))
.literal("reset", Description.of("Reset the profiler"), "r") .literal("reset", ArgumentDescription.of("Reset the profiler"), "r")
.permission("terra.profiler.reset") .permission("terra.profiler.reset")
.handler(context -> { .handler(context -> {
platform.getProfiler().reset(); platform.getProfiler().reset();
context.sender().sendMessage("Profiler reset."); context.getSender().sendMessage("Profiler reset.");
})); }));
}); });
} }

Some files were not shown because too many files have changed in this diff Show More