mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-05-20 08:40:26 +00:00
Compare commits
108 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a9248435a2 | |||
| b4cdb7f16c | |||
| 675a4465d7 | |||
| 839013d89a | |||
| 8e933a1bb4 | |||
| 10308959a1 | |||
| 68ac277471 | |||
| b93ff99b2e | |||
| 285367f616 | |||
| e3dd42c856 | |||
| a54b48f68a | |||
| de2d37cdf5 | |||
| 75b72a500d | |||
| 7da0580eda | |||
| 6883151809 | |||
| 00e9ab4263 | |||
| 2acfada4f8 | |||
| 4c2ece3eb7 | |||
| 59318d75fc | |||
| d9eef2e5d5 | |||
| 2f189d94ac | |||
| 223db88462 | |||
| f2d9511f01 | |||
| ef1f1c0af0 | |||
| da28244f81 | |||
| 77ba13ce93 | |||
| eb8bafe5d8 | |||
| 411ef10c0c | |||
| 01d4174092 | |||
| d072e72590 | |||
| 38e4e9bc94 | |||
| 126ddaf9c7 | |||
| 4bf5be5734 | |||
| c8a4f8be6a | |||
| 049c5cc83a | |||
| ef1f2e882d | |||
| e94d90050a | |||
| 8977e82b73 | |||
| dfff178bfe | |||
| 4f00dadc22 | |||
| 7b439f005e | |||
| 5c165cd40d | |||
| 43a84cca3d | |||
| a4d87a428c | |||
| 414c0b8a38 | |||
| a11e02a84a | |||
| 1a08414822 | |||
| 0b6b66b7e6 | |||
| 278ab648dd | |||
| fe101f1221 | |||
| b6b6cb185d | |||
| ee373bbe4b | |||
| 49857f6b91 | |||
| 8655f7811a | |||
| ce47cd9316 | |||
| c4c71ac9ef | |||
| eaebc445f6 | |||
| 3ec15960cf | |||
| 5275c40c6a | |||
| 68ef5a5a32 | |||
| 63bfa6bf14 | |||
| bce25b8702 | |||
| c88fbc0321 | |||
| 0d1e7fd686 | |||
| bd2ec52832 | |||
| c3b9902c5f | |||
| 69a5cfecd1 | |||
| 304ae3075b | |||
| 0550f36447 | |||
| b82e84d447 | |||
| 7a59aeb80c | |||
| 0228facd71 | |||
| af90088505 | |||
| 2ddf620fb8 | |||
| 0c3d4f4f4e | |||
| e339b26657 | |||
| cee42ac467 | |||
| a2b061ce0d | |||
| 7d2c2bb141 | |||
| 8cd31ead99 | |||
| 3a8fb37cd6 | |||
| 2abf809d0f | |||
| cc9c7870ba | |||
| 2fe04d7f6b | |||
| 977316c57f | |||
| d2c5f711ef | |||
| b8baa05922 | |||
| 98b332fe54 | |||
| 6e61154cc5 | |||
| 0a5450a345 | |||
| 83baf377e0 | |||
| ffc884384c | |||
| 0c302456a2 | |||
| 41e7ad35bd | |||
| 82b474ead2 | |||
| d544e16885 | |||
| 4396623420 | |||
| d2795bfdb6 | |||
| 42fb3642f9 | |||
| e445fd986d | |||
| d7bb818f51 | |||
| eef0e04682 | |||
| 9c857bf86b | |||
| d440dacf30 | |||
| ffbc253477 | |||
| b4ed874043 | |||
| f1845b1ecd | |||
| f2946d85aa |
@@ -21,8 +21,8 @@ assignees: ""
|
||||
- You must be on the LATEST version of Terra to receive any support. There is no support for older versions of Terra.
|
||||
- Make sure that this is not a *specific* compatibility issue with another terrain generation mod.
|
||||
Do not request *specific* compatibility with mods or plugins (e.g. "Compatibility with TechCraft v7").
|
||||
That should be implemented in an addon, **not** in the platform project.
|
||||
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from parent biomes") will be considered in the platform project.
|
||||
That should be implemented in an addon, **not** in the main project.
|
||||
*General* compatibility (e.g. "Ability to pull Vanilla/Modded features from parent biomes") will be considered in the main project.
|
||||
- Make sure that there are no already existing issues open with your problem. If you open a duplicate, it will be closed as such.
|
||||
- Make sure that it is actually Terra causing the issue, and not another mod/plugin.
|
||||
You can do this by testing to see if you can recreate the issue without Terra installed.
|
||||
|
||||
+7
-3
@@ -39,14 +39,18 @@ allprojects {
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
forSubProjects(":platforms") {
|
||||
forImmediateSubProjects(":platforms") {
|
||||
configureDistribution()
|
||||
}
|
||||
forSubProjects(":common:addons") {
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
|
||||
tasks.named("build") {
|
||||
finalizedBy(tasks.named("shadowJar"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"compileOnly"(project(":common:api"))
|
||||
"shadedImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
"testImplementation"("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
"testImplementation"(project(":common:api"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,7 @@ fun Project.addonDir(dir: File, task: Task) {
|
||||
it.delete()
|
||||
}
|
||||
forSubProjects(":common:addons") {
|
||||
val jar = if (tasks.findByName("shadowJar") != null) {
|
||||
(tasks.named("shadowJar").get() as ShadowJar)
|
||||
} else {
|
||||
(tasks.named("jar").get() as Jar)
|
||||
}
|
||||
val jar = tasks.named("shadowJar").get() as ShadowJar
|
||||
|
||||
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||
val target = File(dir, boot + jar.archiveFileName.get())
|
||||
|
||||
@@ -3,14 +3,16 @@ import org.gradle.kotlin.dsl.creating
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.getValue
|
||||
import org.gradle.kotlin.dsl.getting
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
|
||||
fun Project.configureDependencies() {
|
||||
val api by configurations.getting
|
||||
val implementation by configurations.getting
|
||||
val testImplementation by configurations.getting
|
||||
val compileOnly by configurations.getting
|
||||
|
||||
val api by configurations.getting
|
||||
val implementation by configurations.getting
|
||||
|
||||
val shaded by configurations.creating
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
@@ -28,9 +30,10 @@ fun Project.configureDependencies() {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { url = uri("https://maven.fabricmc.net/") }
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
|
||||
maven("https://maven.fabricmc.net/")
|
||||
maven("https://repo.codemc.org/repository/maven-public")
|
||||
maven("https://repo.codemc.io/repository/nms/")
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
import java.io.FileWriter
|
||||
import java.net.URL
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardCopyOption
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.BasePluginExtension
|
||||
@@ -39,41 +38,32 @@ fun Project.configureDistribution() {
|
||||
}
|
||||
|
||||
doLast {
|
||||
// The addons are copied into a JAR because of a ShadowJar bug
|
||||
// which expands *all* JARs, even resource ones, into the fat JAR.
|
||||
// To get around this, we copy all addon JARs into a *new* JAR,
|
||||
// then, ShadowJar expands the newly created JAR, putting the original
|
||||
// JARs where they should go.
|
||||
//
|
||||
// https://github.com/johnrengelman/shadow/issues/111
|
||||
val dest = File(buildDir, "/resources/main/addons.jar")
|
||||
dest.parentFile.mkdirs()
|
||||
val dest = tasks.named<ShadowJar>("shadowJar").get().archiveFile.get().asFile.toPath()
|
||||
|
||||
val zip = ZipOutputStream(FileOutputStream(dest))
|
||||
|
||||
forSubProjects(":common:addons") {
|
||||
val jar = getJarTask()
|
||||
|
||||
println("Packaging addon ${jar.archiveFileName.get()} to ${dest.absolutePath}. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
|
||||
|
||||
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||
|
||||
val entry = ZipEntry("addons/$boot${jar.archiveFileName.get()}")
|
||||
zip.putNextEntry(entry)
|
||||
FileInputStream(jar.archiveFile.get().asFile).run {
|
||||
copyTo(zip)
|
||||
close()
|
||||
FileSystems.newFileSystem(dest, mapOf("create" to "false"), null).use { fs ->
|
||||
forSubProjects(":common:addons") {
|
||||
val jar = getJarTask()
|
||||
|
||||
println("Packaging addon ${jar.archiveFileName.get()} to $dest. size: ${jar.archiveFile.get().asFile.length() / 1024}KB")
|
||||
|
||||
val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
|
||||
val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}");
|
||||
|
||||
if(!Files.exists(addonPath)) {
|
||||
Files.createDirectories(addonPath.parent)
|
||||
Files.createFile(addonPath)
|
||||
Files.copy(jar.archiveFile.get().asFile.toPath(), addonPath, StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
|
||||
}
|
||||
zip.closeEntry()
|
||||
}
|
||||
zip.close()
|
||||
}
|
||||
}
|
||||
|
||||
val generateResourceManifest = tasks.create("generateResourceManifest") {
|
||||
group = "terra"
|
||||
dependsOn(downloadDefaultPacks)
|
||||
dependsOn(installAddons)
|
||||
doLast {
|
||||
val resources = HashMap<String, MutableList<String>>()
|
||||
val packsDir = File("${project.buildDir}/resources/main/packs/")
|
||||
@@ -118,18 +108,20 @@ fun Project.configureDistribution() {
|
||||
|
||||
tasks["processResources"].dependsOn(generateResourceManifest)
|
||||
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
// Tell shadow to download the packs
|
||||
dependsOn(downloadDefaultPacks)
|
||||
|
||||
configurations = listOf(project.configurations["shaded"])
|
||||
|
||||
archiveClassifier.set("shaded")
|
||||
setVersion(project.version)
|
||||
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
|
||||
relocate("org.objectweb.asm", "com.dfsek.terra.lib.asm")
|
||||
relocate("com.dfsek.paralithic", "com.dfsek.terra.lib.paralithic")
|
||||
relocate("org.json", "com.dfsek.terra.lib.json")
|
||||
relocate("org.yaml", "com.dfsek.terra.lib.yaml")
|
||||
|
||||
finalizedBy(installAddons)
|
||||
}
|
||||
|
||||
configure<BasePluginExtension> {
|
||||
@@ -148,10 +140,4 @@ fun downloadPack(packUrl: URL, project: Project) {
|
||||
file.outputStream().write(packUrl.readBytes())
|
||||
}
|
||||
|
||||
fun Project.getJarTask(): Jar {
|
||||
return if (tasks.findByName("shadowJar") != null) {
|
||||
(tasks.named("shadowJar").get() as ShadowJar)
|
||||
} else {
|
||||
(tasks.named("jar").get() as Jar)
|
||||
}
|
||||
}
|
||||
fun Project.getJarTask() = tasks.named("shadowJar").get() as ShadowJar
|
||||
|
||||
@@ -29,6 +29,12 @@ fun Project.forSubProjects(project: String, action: Action<Project>) {
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.forImmediateSubProjects(project: String, action: Action<Project>) {
|
||||
project(project).childProjects.forEach {
|
||||
action.execute(it.value)
|
||||
}
|
||||
}
|
||||
|
||||
fun preRelease(preRelease: Boolean) {
|
||||
isPrerelease = preRelease
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
object Versions {
|
||||
object Libraries {
|
||||
const val tectonic = "4.2.0"
|
||||
const val paralithic = "0.6.0"
|
||||
const val paralithic = "0.7.0"
|
||||
const val strata = "1.1.1"
|
||||
|
||||
const val cloud = "1.6.2"
|
||||
@@ -13,14 +13,13 @@ object Versions {
|
||||
const val apacheText = "1.9"
|
||||
const val jafama = "2.3.2"
|
||||
const val apacheIO = "2.6"
|
||||
const val asm = "9.2"
|
||||
const val fastutil = "8.5.6"
|
||||
}
|
||||
}
|
||||
|
||||
object Fabric {
|
||||
const val fabricLoader = "0.14.2"
|
||||
const val fabricAPI = "0.51.1+1.18.2"
|
||||
const val fabricAPI = "0.53.4+1.18.2"
|
||||
const val minecraft = "1.18.2"
|
||||
const val yarn = "$minecraft+build.3"
|
||||
const val permissionsAPI = "0.1-SNAPSHOT"
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.dfsek.terra.addon.loader;
|
||||
|
||||
import ca.solostudios.strata.version.Version;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
|
||||
|
||||
public class ApiAddon implements BaseAddon {
|
||||
private final Version version;
|
||||
private final String id;
|
||||
|
||||
public ApiAddon(Version version, String id) {
|
||||
this.version = version;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addon.loader;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
|
||||
public class ApiAddonClassLoader extends URLClassLoader {
|
||||
static {
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
|
||||
public ApiAddonClassLoader(URL[] urls, ClassLoader parent) {
|
||||
super(urls, parent);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -14,6 +14,7 @@ import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
|
||||
|
||||
|
||||
@@ -21,7 +22,8 @@ public class ApiAddonLoader implements BootstrapBaseAddon<BaseAddon> {
|
||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||
|
||||
@Override
|
||||
public Iterable<BaseAddon> loadAddons(Path addonsFolder, ClassLoader parent) {
|
||||
public Iterable<BaseAddon> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
|
||||
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.biome.image.lib.jafama")
|
||||
}
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class ImageBiomeProvider implements BiomeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int z, long seed) {
|
||||
public Biome getBiome(int x, int y, int z, long seed) {
|
||||
x /= resolution;
|
||||
z /= resolution;
|
||||
Color color = align.getColor(image, x, z);
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.image.ImageBiomeProviderAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-biome-provider-image/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-biome-provider-image
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,14 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
implementation("com.github.ben-manes.caffeine:caffeine:3.1.0")
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("com.github.benmanes.caffeine", "com.dfsek.terra.addons.biome.pipeline.lib.caffeine")
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.biome.pipeline.lib.jafama")
|
||||
}
|
||||
+7
-16
@@ -7,11 +7,9 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.pipeline;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
@@ -40,16 +38,9 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
this.resolution = resolution;
|
||||
this.mutator = mutator;
|
||||
this.noiseAmp = noiseAmp;
|
||||
holderCache = CacheBuilder.newBuilder()
|
||||
.maximumSize(1024)
|
||||
.build(
|
||||
new CacheLoader<>() {
|
||||
@Override
|
||||
public BiomeHolder load(@NotNull SeededVector key) {
|
||||
return pipeline.getBiomes(key.x, key.z, key.seed);
|
||||
}
|
||||
}
|
||||
);
|
||||
holderCache = Caffeine.newBuilder()
|
||||
.maximumSize(1024)
|
||||
.build(key -> pipeline.getBiomes(key.x, key.z, key.seed));
|
||||
this.pipeline = pipeline;
|
||||
|
||||
Set<BiomeDelegate> biomeSet = new HashSet<>();
|
||||
@@ -81,7 +72,7 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int z, long seed) {
|
||||
public Biome getBiome(int x, int y, int z, long seed) {
|
||||
x += mutator.noise(seed + 1, x, z) * noiseAmp;
|
||||
z += mutator.noise(seed + 2, x, z) * noiseAmp;
|
||||
|
||||
@@ -92,7 +83,7 @@ public class BiomePipelineProvider implements BiomeProvider {
|
||||
|
||||
int fdX = FastMath.floorDiv(x, pipeline.getSize());
|
||||
int fdZ = FastMath.floorDiv(z, pipeline.getSize());
|
||||
return holderCache.getUnchecked(new SeededVector(fdX, fdZ, seed)).getBiome(x - fdX * pipeline.getSize(),
|
||||
return holderCache.get(new SeededVector(fdX, fdZ, seed)).getBiome(x - fdX * pipeline.getSize(),
|
||||
z - fdZ * pipeline.getSize()).getBiome();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ final class SelfDelegate implements BiomeDelegate {
|
||||
public static final SelfDelegate INSTANCE = new SelfDelegate();
|
||||
|
||||
private SelfDelegate() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
|
||||
@Description("""
|
||||
The initial size of biome chunks. This value must be at least 2.
|
||||
<b>This is not the final size of biome chunks. Final chunks will be much larger</b>.
|
||||
|
||||
|
||||
It is recommended to keep biome chunks' final size in the range of [50, 300]
|
||||
to prevent performance issues. To calculate the size of biome chunks, simply
|
||||
take initial-size and for each expand stage, multiply the running value by 2
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.pipeline.BiomePipelineAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-biome-provider-pipeline/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-biome-provider-pipeline
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class SingleBiomeProvider implements BiomeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int z, long seed) {
|
||||
public Biome getBiome(int x, int y, int z, long seed) {
|
||||
return biome;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.single.SingleBiomeProviderAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-biome-provider-single/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-biome-provider-single
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,12 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.chunkgenerator.lib.jafama")
|
||||
}
|
||||
|
||||
+1
-1
@@ -79,6 +79,6 @@ public class BiomePaletteTemplate implements ObjectTemplate<PaletteInfo> {
|
||||
slantLayers.put(threshold, layer.getPalette());
|
||||
}
|
||||
|
||||
return new PaletteInfo(builder.build(), new SlantHolder(slantLayers, minThreshold), oceanPalette, seaLevel, slantDepth);
|
||||
return new PaletteInfo(builder.build(), SlantHolder.of(slantLayers, minThreshold), oceanPalette, seaLevel, slantDepth);
|
||||
}
|
||||
}
|
||||
|
||||
+47
-48
@@ -18,7 +18,6 @@ import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
@@ -51,61 +50,61 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
public void generateChunkData(@NotNull ProtoChunk chunk, @NotNull WorldProperties world,
|
||||
@NotNull BiomeProvider biomeProvider,
|
||||
int chunkX, int chunkZ) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) {
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
|
||||
Sampler3D sampler = samplerCache.getChunk(chunkX, chunkZ, world, biomeProvider);
|
||||
|
||||
long seed = world.getSeed();
|
||||
|
||||
LazilyEvaluatedInterpolator carver = new LazilyEvaluatedInterpolator(biomeProvider,
|
||||
chunkX,
|
||||
chunkZ,
|
||||
world.getMaxHeight(),
|
||||
world.getMinHeight(),
|
||||
carverHorizontalResolution,
|
||||
carverVerticalResolution,
|
||||
seed);
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
int paletteLevel = 0;
|
||||
|
||||
int cx = xOrig + x;
|
||||
int cz = zOrig + z;
|
||||
|
||||
Biome biome = biomeProvider.getBiome(cx, cz, seed);
|
||||
|
||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||
|
||||
int sea = paletteInfo.seaLevel();
|
||||
Palette seaPalette = paletteInfo.ocean();
|
||||
|
||||
BlockState data;
|
||||
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
|
||||
if(sampler.sample(x, y, z) > 0) {
|
||||
if(carver.sample(x, y, z) <= 0) {
|
||||
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo, paletteLevel).get(paletteLevel, cx, y, cz,
|
||||
seed);
|
||||
chunk.setBlock(x, y, z, data);
|
||||
}
|
||||
|
||||
paletteLevel++;
|
||||
} else if(y <= sea) {
|
||||
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, y, z + zOrig, seed));
|
||||
paletteLevel = 0;
|
||||
} else {
|
||||
paletteLevel = 0;
|
||||
platform.getProfiler().push("chunk_base_3d");
|
||||
int xOrig = (chunkX << 4);
|
||||
int zOrig = (chunkZ << 4);
|
||||
|
||||
Sampler3D sampler = samplerCache.getChunk(chunkX, chunkZ, world, biomeProvider);
|
||||
|
||||
long seed = world.getSeed();
|
||||
|
||||
LazilyEvaluatedInterpolator carver = new LazilyEvaluatedInterpolator(biomeProvider,
|
||||
chunkX,
|
||||
chunkZ,
|
||||
world.getMaxHeight(),
|
||||
world.getMinHeight(),
|
||||
carverHorizontalResolution,
|
||||
carverVerticalResolution,
|
||||
seed);
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
int paletteLevel = 0;
|
||||
|
||||
int cx = xOrig + x;
|
||||
int cz = zOrig + z;
|
||||
|
||||
Biome biome = biomeProvider.getBiome(cx, 0, cz, seed);
|
||||
|
||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||
|
||||
int sea = paletteInfo.seaLevel();
|
||||
Palette seaPalette = paletteInfo.ocean();
|
||||
|
||||
BlockState data;
|
||||
for(int y = world.getMaxHeight() - 1; y >= world.getMinHeight(); y--) {
|
||||
if(sampler.sample(x, y, z) > 0) {
|
||||
if(carver.sample(x, y, z) <= 0) {
|
||||
data = PaletteUtil.getPalette(x, y, z, sampler, paletteInfo, paletteLevel).get(paletteLevel, cx, y, cz,
|
||||
seed);
|
||||
chunk.setBlock(x, y, z, data);
|
||||
}
|
||||
|
||||
paletteLevel++;
|
||||
} else if(y <= sea) {
|
||||
chunk.setBlock(x, y, z, seaPalette.get(sea - y, x + xOrig, y, z + zOrig, seed));
|
||||
paletteLevel = 0;
|
||||
} else {
|
||||
paletteLevel = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
platform.getProfiler().pop("chunk_base_3d");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(WorldProperties world, int x, int y, int z, BiomeProvider biomeProvider) {
|
||||
Biome biome = biomeProvider.getBiome(x, z, world.getSeed());
|
||||
Biome biome = biomeProvider.getBiome(x, y, z, world.getSeed());
|
||||
Sampler3D sampler = samplerCache.get(x, z, world, biomeProvider);
|
||||
|
||||
PaletteInfo paletteInfo = biome.getContext().get(PaletteInfo.class);
|
||||
@@ -129,7 +128,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public Palette getPalette(int x, int y, int z, WorldProperties world, BiomeProvider biomeProvider) {
|
||||
return biomeProvider.getBiome(x, z, world.getSeed()).getContext().get(PaletteInfo.class).paletteHolder().getPalette(y);
|
||||
return biomeProvider.getBiome(x, y, z, world.getSeed()).getContext().get(PaletteInfo.class).paletteHolder().getPalette(y);
|
||||
}
|
||||
|
||||
public SamplerProvider samplerProvider() {
|
||||
|
||||
+7
-3
@@ -55,7 +55,7 @@ public class ChunkInterpolator {
|
||||
|
||||
for(int x = 0; x < 5; x++) {
|
||||
for(int z = 0; z < 5; z++) {
|
||||
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), zOrigin + (z << 2), seed)
|
||||
BiomeNoiseProperties generationSettings = provider.getBiome(xOrigin + (x << 2), 0, zOrigin + (z << 2), seed)
|
||||
.getContext()
|
||||
.get(BiomeNoiseProperties.class);
|
||||
Map<BiomeNoiseProperties, MutableInteger> genMap = new HashMap<>();
|
||||
@@ -66,7 +66,7 @@ public class ChunkInterpolator {
|
||||
for(int xi = -blend; xi <= blend; xi++) {
|
||||
for(int zi = -blend; zi <= blend; zi++) {
|
||||
genMap.computeIfAbsent(
|
||||
provider.getBiome(xOrigin + (x << 2) + (xi * step), zOrigin + (z << 2) + (zi * step), seed)
|
||||
provider.getBiome(xOrigin + (x << 2) + (xi * step), 0, zOrigin + (z << 2) + (zi * step), seed)
|
||||
.getContext()
|
||||
.get(BiomeNoiseProperties.class),
|
||||
g -> new MutableInteger(0)).increment(); // Increment by 1
|
||||
@@ -133,6 +133,10 @@ public class ChunkInterpolator {
|
||||
}
|
||||
|
||||
public double getNoise(int x, int y, int z) {
|
||||
return interpGrid[x / 4][(y - min) / 4][z / 4].trilerp((double) (x % 4) / 4, (double) (y % 4) / 4, (double) (z % 4) / 4);
|
||||
return interpGrid[x / 4][(y - min) / 4][z / 4].trilerp(
|
||||
(double) (x & 3) / 4, // x & 3 == x % 4
|
||||
(double) (y & 3) / 4, // x & 3 == x % 4
|
||||
(double) (z & 3) / 4 // x & 3 == x % 4
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class ElevationInterpolator {
|
||||
// Precompute generators.
|
||||
for(int x = -1 - smooth; x <= 16 + smooth; x++) {
|
||||
for(int z = -1 - smooth; z <= 16 + smooth; z++) {
|
||||
gens[x + 1 + smooth][z + 1 + smooth] = provider.getBiome(xOrigin + x, zOrigin + z, seed).getContext().get(
|
||||
gens[x + 1 + smooth][z + 1 + smooth] = provider.getBiome(xOrigin + x, 0, zOrigin + z, seed).getContext().get(
|
||||
BiomeNoiseProperties.class);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ public class LazilyEvaluatedInterpolator {
|
||||
|
||||
NoiseSampler sampler = samplers[x][z];
|
||||
if(sampler == null) {
|
||||
sampler = biomeProvider.getBiome(xi, zi, seed).getContext().get(BiomeNoiseProperties.class).carving();
|
||||
sampler = biomeProvider.getBiome(xi, y, zi, seed).getContext().get(BiomeNoiseProperties.class).carving();
|
||||
samplers[x][z] = sampler;
|
||||
}
|
||||
|
||||
|
||||
+31
-1
@@ -8,6 +8,7 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.palette;
|
||||
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
||||
@@ -15,11 +16,19 @@ public class SlantHolder {
|
||||
private final TreeMap<Double, PaletteHolder> layers;
|
||||
private final double minSlope;
|
||||
|
||||
public SlantHolder(TreeMap<Double, PaletteHolder> layers, double minSlope) {
|
||||
private SlantHolder(TreeMap<Double, PaletteHolder> layers, double minSlope) {
|
||||
this.layers = layers;
|
||||
this.minSlope = minSlope;
|
||||
}
|
||||
|
||||
public static SlantHolder of(TreeMap<Double, PaletteHolder> layers, double minSlope) {
|
||||
if(layers.size() == 1) {
|
||||
Entry<Double, PaletteHolder> firstEntry = layers.firstEntry();
|
||||
return new Single(firstEntry.getValue(), minSlope);
|
||||
}
|
||||
return new SlantHolder(layers, minSlope);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return layers.isEmpty();
|
||||
}
|
||||
@@ -31,4 +40,25 @@ public class SlantHolder {
|
||||
public double getMinSlope() {
|
||||
return minSlope;
|
||||
}
|
||||
|
||||
private static final class Single extends SlantHolder {
|
||||
|
||||
private final PaletteHolder layers;
|
||||
|
||||
public Single(PaletteHolder layers, double minSlope) {
|
||||
super(of(minSlope, layers), minSlope);
|
||||
this.layers = layers;
|
||||
}
|
||||
|
||||
private static TreeMap<Double, PaletteHolder> of(double v, PaletteHolder layer) {
|
||||
TreeMap<Double, PaletteHolder> map = new TreeMap<>();
|
||||
map.put(v, layer);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaletteHolder getPalette(double slope) {
|
||||
return layers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.chunkgenerator.NoiseChunkGenerator3DAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-chunk-generator-noise-3d/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-chunk-generator-noise-3d
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+3
-5
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.biome.holder;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@@ -25,11 +23,11 @@ public class PaletteHolderBuilder {
|
||||
|
||||
public PaletteHolder build() {
|
||||
|
||||
int min = FastMath.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0);
|
||||
int max = FastMath.max(paletteMap.keySet().stream().max(Integer::compareTo).orElse(255), 255);
|
||||
int min = Math.min(paletteMap.keySet().stream().min(Integer::compareTo).orElse(0), 0);
|
||||
int max = Math.max(paletteMap.keySet().stream().max(Integer::compareTo).orElse(255), 255);
|
||||
|
||||
Palette[] palettes = new Palette[paletteMap.lastKey() + 1 - min];
|
||||
for(int y = min; y <= FastMath.max(paletteMap.lastKey(), max); y++) {
|
||||
for(int y = min; y <= Math.max(paletteMap.lastKey(), max); y++) {
|
||||
Palette d = null;
|
||||
for(Map.Entry<Integer, Palette> e : paletteMap.entrySet()) {
|
||||
if(e.getKey() >= y) {
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.biome.BiomeAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-biome/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-biome
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,12 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.feature.distributor.lib.jafama")
|
||||
}
|
||||
+3
-3
@@ -34,12 +34,12 @@ public class PaddedGridDistributor implements Distributor {
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
int cellX = FastMath.floorDiv(x, cellWidth);
|
||||
int cellZ = FastMath.floorDiv(z, cellWidth);
|
||||
|
||||
|
||||
Random random = new Random((murmur64(MathUtil.squash(cellX, cellZ)) ^ seed) + salt);
|
||||
|
||||
|
||||
int pointX = random.nextInt(width) + cellX * cellWidth;
|
||||
int pointZ = random.nextInt(width) + cellZ * cellWidth;
|
||||
|
||||
|
||||
return x == pointX && z == pointZ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.feature.distributor.DistributorAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-distributors/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-distributors
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
config-feature: "0.1.+"
|
||||
generation-stage-feature: "0.1.+"
|
||||
config-feature: "1.+"
|
||||
generation-stage-feature: "1.+"
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.feature.FeatureAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-feature/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-feature
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
generation-stage-feature: "0.1.+"
|
||||
generation-stage-feature: "1.+"
|
||||
@@ -1,5 +1,11 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.flora.lib.jafama")
|
||||
}
|
||||
|
||||
-7
@@ -15,7 +15,6 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.base.Properties;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.Direction;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
@@ -90,12 +89,6 @@ public class TerraFlora implements Structure {
|
||||
if(doRotation) {
|
||||
Direction oneFace = new ArrayList<>(faces).get(
|
||||
new Random(location.getX() ^ location.getZ()).nextInt(faces.size())); // Get random face.
|
||||
|
||||
data = data.setIfPresent(Properties.DIRECTION, oneFace.opposite())
|
||||
.setIfPresent(Properties.NORTH, faces.contains(Direction.NORTH))
|
||||
.setIfPresent(Properties.SOUTH, faces.contains(Direction.SOUTH))
|
||||
.setIfPresent(Properties.EAST, faces.contains(Direction.EAST))
|
||||
.setIfPresent(Properties.WEST, faces.contains(Direction.WEST));
|
||||
}
|
||||
world.setBlockState(location.mutable().add(0, i + c, 0).immutable(), data, physics);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.flora.FloraAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-flora/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-flora
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,12 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.feature.locator.lib.jafama")
|
||||
}
|
||||
|
||||
+14
-3
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.dfsek.terra.addons.feature.locator.locators;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
@@ -31,11 +29,24 @@ public class SamplerLocator implements Locator {
|
||||
|
||||
long seed = column.getWorld().getSeed();
|
||||
samplers.forEach(sampler -> {
|
||||
int y = FastMath.floorToInt(sampler.noise(seed, column.getX(), column.getZ()));
|
||||
int y = floorToInt(sampler.noise(seed, column.getX(), column.getZ()));
|
||||
if(y >= column.getMaxY() || y < column.getMinY()) return;
|
||||
results.set(y);
|
||||
});
|
||||
|
||||
return results.build();
|
||||
}
|
||||
|
||||
private static int floorToInt(double value) {
|
||||
int valueInt = (int)value;
|
||||
if (value < 0.0) {
|
||||
if (value == (double)valueInt) {
|
||||
return valueInt;
|
||||
} else {
|
||||
return valueInt == Integer.MIN_VALUE ? valueInt : valueInt - 1;
|
||||
}
|
||||
} else {
|
||||
return valueInt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.feature.locator.LocatorAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-locators/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-locators
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
depends:
|
||||
config-feature: "0.1.+"
|
||||
generation-stage-feature: "0.1.+"
|
||||
config-feature: "1.+"
|
||||
generation-stage-feature: "1.+"
|
||||
@@ -1,5 +1,16 @@
|
||||
version = version("0.1.0")
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
api("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("com.dfsek.paralithic", "com.dfsek.terra.addons.noise.lib.paralithic")
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.noise.lib.jafama")
|
||||
}
|
||||
+2
-1
@@ -32,6 +32,7 @@ import com.dfsek.terra.addons.noise.config.templates.noise.fractal.RidgedFractal
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ClampNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.NormalNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.PosterizationNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ProbabilityNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ScaleNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.AdditionSampler;
|
||||
@@ -90,6 +91,7 @@ public class NoiseAddon implements AddonInitializer {
|
||||
noiseRegistry.register(addon.key("CLAMP"), ClampNormalizerTemplate::new);
|
||||
noiseRegistry.register(addon.key("PROBABILITY"), ProbabilityNormalizerTemplate::new);
|
||||
noiseRegistry.register(addon.key("SCALE"), ScaleNormalizerTemplate::new);
|
||||
noiseRegistry.register(addon.key("POSTERIZATION"), PosterizationNormalizerTemplate::new);
|
||||
|
||||
noiseRegistry.register(addon.key("IMAGE"), ImageSamplerTemplate::new);
|
||||
|
||||
@@ -121,7 +123,6 @@ public class NoiseAddon implements AddonInitializer {
|
||||
|
||||
noiseRegistry.register(addon.key("LINEAR_HEIGHTMAP"), LinearHeightmapSamplerTemplate::new);
|
||||
|
||||
|
||||
noiseRegistry.register(addon.key("ADD"), () -> new BinaryArithmeticTemplate<>(AdditionSampler::new));
|
||||
noiseRegistry.register(addon.key("SUB"), () -> new BinaryArithmeticTemplate<>(SubtractionSampler::new));
|
||||
noiseRegistry.register(addon.key("MUL"), () -> new BinaryArithmeticTemplate<>(MultiplicationSampler::new));
|
||||
|
||||
+14
@@ -13,6 +13,7 @@ import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
|
||||
@@ -45,4 +46,17 @@ public class FunctionTemplate implements ObjectTemplate<FunctionTemplate> {
|
||||
public LinkedHashMap<String, FunctionTemplate> getFunctions() {
|
||||
return functions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
FunctionTemplate that = (FunctionTemplate) o;
|
||||
return args.equals(that.args) && function.equals(that.function) && functions.equals(that.functions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(args, function, functions);
|
||||
}
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.noise.config.templates.normalizer;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.addons.noise.normalizer.PosterizationNormalizer;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||
public class PosterizationNormalizerTemplate extends NormalizerTemplate<PosterizationNormalizer> {
|
||||
@Value("steps")
|
||||
private @Meta int steps;
|
||||
|
||||
@Override
|
||||
public NoiseSampler get() {
|
||||
return new PosterizationNormalizer(function, steps);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.noise.normalizer;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class PosterizationNormalizer extends Normalizer {
|
||||
private final double stepSize;
|
||||
|
||||
public PosterizationNormalizer(NoiseSampler sampler, int steps) {
|
||||
super(sampler);
|
||||
this.stepSize = 2.0 / (steps - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double normalize(double in) {
|
||||
return FastMath.roundToInt((in + 1) / stepSize) * stepSize - 1;
|
||||
}
|
||||
}
|
||||
+22
-13
@@ -15,6 +15,8 @@ import com.dfsek.paralithic.functions.dynamic.Context;
|
||||
import com.dfsek.paralithic.functions.dynamic.DynamicFunction;
|
||||
import com.dfsek.paralithic.node.Statefulness;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.dfsek.terra.addons.noise.config.templates.FunctionTemplate;
|
||||
@@ -24,26 +26,33 @@ public class UserDefinedFunction implements DynamicFunction {
|
||||
private final Expression expression;
|
||||
private final int args;
|
||||
|
||||
private static final Map<FunctionTemplate, UserDefinedFunction> CACHE = new HashMap<>();
|
||||
|
||||
protected UserDefinedFunction(Expression expression, int args) {
|
||||
this.expression = expression;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public static UserDefinedFunction newInstance(FunctionTemplate template) throws ParseException {
|
||||
Parser parser = new Parser();
|
||||
Scope parent = new Scope();
|
||||
|
||||
Scope functionScope = new Scope().withParent(parent);
|
||||
|
||||
template.getArgs().forEach(functionScope::addInvocationVariable);
|
||||
|
||||
for(Entry<String, FunctionTemplate> entry : template.getFunctions().entrySet()) {
|
||||
String id = entry.getKey();
|
||||
FunctionTemplate nest = entry.getValue();
|
||||
parser.registerFunction(id, newInstance(nest));
|
||||
UserDefinedFunction function = CACHE.get(template);
|
||||
if(function == null) {
|
||||
Parser parser = new Parser();
|
||||
Scope parent = new Scope();
|
||||
|
||||
Scope functionScope = new Scope().withParent(parent);
|
||||
|
||||
template.getArgs().forEach(functionScope::addInvocationVariable);
|
||||
|
||||
for(Entry<String, FunctionTemplate> entry : template.getFunctions().entrySet()) {
|
||||
String id = entry.getKey();
|
||||
FunctionTemplate nest = entry.getValue();
|
||||
parser.registerFunction(id, newInstance(nest));
|
||||
}
|
||||
|
||||
function = new UserDefinedFunction(parser.parse(template.getFunction(), functionScope), template.getArgs().size());
|
||||
CACHE.put(template, function);
|
||||
}
|
||||
|
||||
return new UserDefinedFunction(parser.parse(template.getFunction(), functionScope), template.getArgs().size());
|
||||
return function;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
@@ -22,6 +22,7 @@ public class GaborNoiseSampler extends NoiseFunction {
|
||||
private double impulseDensity = (impulsesPerKernel / (Math.PI * kernelRadius * kernelRadius));
|
||||
private double impulsesPerCell = impulseDensity * kernelRadius * kernelRadius;
|
||||
private double g = FastMath.exp(-impulsesPerCell);
|
||||
|
||||
private double omega0 = Math.PI * 0.25;
|
||||
private boolean isotropic = true;
|
||||
|
||||
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.noise.util;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public abstract class HashIntrinsic implements Serializable {
|
||||
public static final int FLOAT_EXP_BIT_MASK = 2139095040;
|
||||
public static final int FLOAT_SIGNIF_BIT_MASK = 8388607;
|
||||
public static final long DOUBLE_EXP_BIT_MASK = 9218868437227405312L;
|
||||
public static final long DOUBLE_SIGNIF_BIT_MASK = 4503599627370495L;
|
||||
protected static final int DEFAULT_INITIAL_CAPACITY = 16;
|
||||
protected static final int MAXIMUM_CAPACITY = 1073741824;
|
||||
protected static final float DEFAULT_LOAD_FACTOR = 0.75F;
|
||||
@Serial
|
||||
private static final long serialVersionUID = 8058099372006904458L;
|
||||
protected int size;
|
||||
protected int threshold;
|
||||
protected float loadFactor;
|
||||
protected int capMinus1;
|
||||
|
||||
protected HashIntrinsic(int initialCapacity, float loadFactor) {
|
||||
if(initialCapacity <= 0) {
|
||||
throw new IllegalArgumentException("Illegal initial capacity: " + initialCapacity);
|
||||
} else if(!(loadFactor <= 0.0F) && !Float.isNaN(loadFactor)) {
|
||||
if(initialCapacity > 1073741824) {
|
||||
initialCapacity = 1073741824;
|
||||
}
|
||||
|
||||
int capacity;
|
||||
for(capacity = 1; capacity < initialCapacity; capacity <<= 1) {
|
||||
}
|
||||
|
||||
this.capMinus1 = capacity - 1;
|
||||
this.loadFactor = loadFactor;
|
||||
this.threshold = (int) ((float) capacity * loadFactor);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Illegal load factor: " + loadFactor);
|
||||
}
|
||||
}
|
||||
|
||||
public static int floatToIntBits(float value) {
|
||||
int result = Float.floatToRawIntBits(value);
|
||||
if((result & 2139095040) == 2139095040 && (result & 8388607) != 0) {
|
||||
result = 2143289344;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static long doubleToLongBits(double value) {
|
||||
long result = Double.doubleToRawLongBits(value);
|
||||
if((result & 9218868437227405312L) == 9218868437227405312L && (result & 4503599627370495L) != 0L) {
|
||||
result = 9221120237041090560L;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected static int hashCodeLong(long value) {
|
||||
return (int) (value ^ value >>> 32);
|
||||
}
|
||||
|
||||
protected static int hashCodeFloat(float value) {
|
||||
return floatToIntBits(value);
|
||||
}
|
||||
|
||||
protected static int hashCodeDouble(double value) {
|
||||
long bits = doubleToLongBits(value);
|
||||
return (int) (bits ^ bits >>> 32);
|
||||
}
|
||||
|
||||
protected static int tableIndex(int hc, int lm1) {
|
||||
hc ^= hc >>> 20 ^ hc >>> 12;
|
||||
hc ^= hc >>> 7 ^ hc >>> 4;
|
||||
return hc & lm1;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public abstract void clear();
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.size == 0;
|
||||
}
|
||||
}
|
||||
-272
@@ -1,272 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.noise.util;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
||||
public class HashMapDoubleDouble extends HashIntrinsic {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 2109458761298324234L;
|
||||
private HashMapDoubleDouble.Entry[] table;
|
||||
|
||||
public HashMapDoubleDouble(int initialCapacity, float loadFactor) {
|
||||
super(initialCapacity, loadFactor);
|
||||
this.table = this.createTable(this.capMinus1 + 1);
|
||||
}
|
||||
|
||||
public HashMapDoubleDouble(int initialCapacity) {
|
||||
this(initialCapacity, 0.75F);
|
||||
}
|
||||
|
||||
public HashMapDoubleDouble() {
|
||||
this(16, 0.75F);
|
||||
}
|
||||
|
||||
public final boolean contains(double key) {
|
||||
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
|
||||
|
||||
for(HashMapDoubleDouble.Entry e = this.table[i]; e != null; e = e.next) {
|
||||
if(e.key == key) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsValue(double value) {
|
||||
for(Entry entry : this.table) {
|
||||
for(Entry e = entry; e != null; e = e.next) {
|
||||
if(value == e.value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public double get(double key) {
|
||||
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
|
||||
|
||||
for(HashMapDoubleDouble.Entry e = this.table[i]; e != null; e = e.next) {
|
||||
if(key == e.key) {
|
||||
return e.value;
|
||||
}
|
||||
}
|
||||
|
||||
return 4.9E-324D;
|
||||
}
|
||||
|
||||
public double put(double key, double value) {
|
||||
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
|
||||
|
||||
for(HashMapDoubleDouble.Entry e = this.table[i]; e != null; e = e.next) {
|
||||
if(key == e.key) {
|
||||
double oldValue = e.value;
|
||||
e.value = value;
|
||||
return oldValue;
|
||||
}
|
||||
}
|
||||
|
||||
this.addEntry(key, value, i);
|
||||
return 4.9E-324D;
|
||||
}
|
||||
|
||||
public void resize(int newCapacity) {
|
||||
int oldCapacity = this.table.length;
|
||||
if(oldCapacity == 1073741824) {
|
||||
this.threshold = 2147483647;
|
||||
} else {
|
||||
HashMapDoubleDouble.Entry[] newTable = this.createTable(newCapacity);
|
||||
this.capMinus1 = newCapacity - 1;
|
||||
this.transfer(newTable);
|
||||
this.table = newTable;
|
||||
this.threshold = (int) ((float) newCapacity * this.loadFactor);
|
||||
}
|
||||
}
|
||||
|
||||
public final HashMapDoubleDouble.Entry remove(double key) {
|
||||
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
|
||||
HashMapDoubleDouble.Entry prev = this.table[i];
|
||||
|
||||
HashMapDoubleDouble.Entry e;
|
||||
HashMapDoubleDouble.Entry next;
|
||||
for(e = prev; e != null; e = next) {
|
||||
next = e.next;
|
||||
if(key == e.key) {
|
||||
--this.size;
|
||||
if(prev == e) {
|
||||
this.table[i] = next;
|
||||
} else {
|
||||
prev.next = next;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
prev = e;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
Arrays.fill(this.table, null);
|
||||
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
public long memoryEstimate(int ptrsize) {
|
||||
return (long) ptrsize * (long) (this.capMinus1 + this.size + 1) + (this.size * 64L / 4);
|
||||
}
|
||||
|
||||
public HashMapDoubleDouble.Iterator iterator() {
|
||||
return new HashMapDoubleDouble.Iterator();
|
||||
}
|
||||
|
||||
private void addEntry(double key, double value, int index) {
|
||||
HashMapDoubleDouble.Entry e = this.table[index];
|
||||
this.table[index] = new HashMapDoubleDouble.Entry(key, value, e);
|
||||
if(this.size++ >= this.threshold) {
|
||||
this.resize(2 * this.table.length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void transfer(HashMapDoubleDouble.Entry[] newTable) {
|
||||
for(int j = 0; j < this.table.length; ++j) {
|
||||
HashMapDoubleDouble.Entry e = this.table[j];
|
||||
if(e != null) {
|
||||
this.table[j] = null;
|
||||
|
||||
HashMapDoubleDouble.Entry next;
|
||||
do {
|
||||
next = e.next;
|
||||
int i = tableIndex(hashCodeDouble(e.key), this.capMinus1);
|
||||
e.next = newTable[i];
|
||||
newTable[i] = e;
|
||||
e = next;
|
||||
} while(next != null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private HashMapDoubleDouble.Entry[] createTable(int capacity) {
|
||||
return new HashMapDoubleDouble.Entry[capacity];
|
||||
}
|
||||
|
||||
public HashMapDoubleDouble.Entry getEntry(double key) {
|
||||
int i = tableIndex(hashCodeDouble(key), this.capMinus1);
|
||||
|
||||
for(HashMapDoubleDouble.Entry e = this.table[i]; e != null; e = e.next) {
|
||||
if(key == e.key) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static class Entry implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 7972173983741231238L;
|
||||
private final double key;
|
||||
private double value;
|
||||
private HashMapDoubleDouble.Entry next;
|
||||
|
||||
public Entry(double key, double val, HashMapDoubleDouble.Entry n) {
|
||||
this.key = key;
|
||||
this.value = val;
|
||||
this.next = n;
|
||||
}
|
||||
|
||||
public final double setValue(double newValue) {
|
||||
double oldValue = this.value;
|
||||
this.value = newValue;
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
public final double getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public final double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public final int hashCode() {
|
||||
return hashCodeDouble(key) + hashCodeDouble(value);
|
||||
}
|
||||
|
||||
public final boolean equals(Object o) {
|
||||
HashMapDoubleDouble.Entry e = (HashMapDoubleDouble.Entry) o;
|
||||
return this.key == e.key && this.value == e.value;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return this.key + " = " + this.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Iterator {
|
||||
HashMapDoubleDouble.Entry next;
|
||||
int index;
|
||||
HashMapDoubleDouble.Entry current;
|
||||
|
||||
Iterator() {
|
||||
if(HashMapDoubleDouble.this.size > 0) {
|
||||
while(this.index < HashMapDoubleDouble.this.table.length &&
|
||||
(this.next = HashMapDoubleDouble.this.table[this.index++]) == null) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public HashMapDoubleDouble.Entry nextEntry() {
|
||||
HashMapDoubleDouble.Entry e = this.next;
|
||||
if(e == null) {
|
||||
throw new NoSuchElementException();
|
||||
} else {
|
||||
if((this.next = e.next) == null) {
|
||||
while(this.index < HashMapDoubleDouble.this.table.length &&
|
||||
(this.next = HashMapDoubleDouble.this.table[this.index++]) == null) {
|
||||
}
|
||||
}
|
||||
|
||||
this.current = e;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
public double next() {
|
||||
return this.nextEntry().value;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
if(this.current == null) {
|
||||
throw new IllegalStateException();
|
||||
} else {
|
||||
double k = this.current.key;
|
||||
this.current = null;
|
||||
HashMapDoubleDouble.this.remove(k);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean hasNext() {
|
||||
return this.next != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.noise.NoiseAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-noise-function/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-noise-function
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,11 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.ore.lib.jafama")
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.ore.OreAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-ore/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-ore
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.palette.PaletteAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-palette/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-palette
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,6 +1,13 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi("com.googlecode.json-simple:json-simple:1.1.1")
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
api("com.googlecode.json-simple:json-simple:1.1.1")
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.structure.lib.jafama")
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.structure.StructureAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-config-structure/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-config-structure
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
+36
-34
@@ -12,7 +12,6 @@ import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
@@ -27,49 +26,52 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
|
||||
private final String id;
|
||||
|
||||
private final String profile;
|
||||
|
||||
public FeatureGenerationStage(Platform platform, String id) {
|
||||
this.platform = platform;
|
||||
this.id = id;
|
||||
this.profile = "feature_stage:" + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public void populate(ProtoWorld world) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("feature_stage:" + id)) {
|
||||
int cx = world.centerChunkX() << 4;
|
||||
int cz = world.centerChunkZ() << 4;
|
||||
long seed = world.getSeed();
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
int tx = cx + x;
|
||||
int tz = cz + z;
|
||||
Column<WritableWorld> column = world.column(tx, tz);
|
||||
long coordinateSeed = (seed * 31 + tx) * 31 + tz;
|
||||
|
||||
world.getBiomeProvider()
|
||||
.getBiome(tx, tz, seed)
|
||||
.getContext()
|
||||
.get(BiomeFeatures.class)
|
||||
.getFeatures()
|
||||
.getOrDefault(this, Collections.emptyList())
|
||||
.forEach(feature -> {
|
||||
try(ProfileFrame ignored = platform.getProfiler().profile(feature.getID())) {
|
||||
if(feature.getDistributor().matches(tx, tz, seed)) {
|
||||
feature.getLocator()
|
||||
.getSuitableCoordinates(column)
|
||||
.forEach(y ->
|
||||
feature.getStructure(world, tx, y, tz)
|
||||
.generate(Vector3Int.of(tx, y, tz),
|
||||
world,
|
||||
new Random(coordinateSeed * 31 + y),
|
||||
Rotation.NONE)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
platform.getProfiler().push(profile);
|
||||
int cx = world.centerChunkX() << 4;
|
||||
int cz = world.centerChunkZ() << 4;
|
||||
long seed = world.getSeed();
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
int tx = cx + x;
|
||||
int tz = cz + z;
|
||||
Column<WritableWorld> column = world.column(tx, tz);
|
||||
long coordinateSeed = (seed * 31 + tx) * 31 + tz;
|
||||
|
||||
world.getBiomeProvider()
|
||||
.getBiome(tx, 0, tz, seed)
|
||||
.getContext()
|
||||
.get(BiomeFeatures.class)
|
||||
.getFeatures()
|
||||
.getOrDefault(this, Collections.emptyList())
|
||||
.forEach(feature -> {
|
||||
platform.getProfiler().push(feature.getID());
|
||||
if(feature.getDistributor().matches(tx, tz, seed)) {
|
||||
feature.getLocator()
|
||||
.getSuitableCoordinates(column)
|
||||
.forEach(y ->
|
||||
feature.getStructure(world, tx, y, tz)
|
||||
.generate(Vector3Int.of(tx, y, tz),
|
||||
world,
|
||||
new Random(coordinateSeed * 31 + y),
|
||||
Rotation.NONE)
|
||||
);
|
||||
}
|
||||
platform.getProfiler().pop(feature.getID());
|
||||
});
|
||||
}
|
||||
}
|
||||
platform.getProfiler().pop(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.generation.feature.FeatureGenerationAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-generation-stage-feature/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-generation-stage-feature
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.generation.structure.StructureGenerationAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-generation-stage-structure/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-generation-stage-structure
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,6 +1,6 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedImplementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.yaml.YamlAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-language-yaml/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-language-yaml
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,8 +1,8 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi("commons-io:commons-io:2.6")
|
||||
shadedImplementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
api("commons-io:commons-io:2.7")
|
||||
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
}
|
||||
|
||||
tasks.withType<Jar> {
|
||||
|
||||
+6
-10
@@ -20,7 +20,6 @@ import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.FileVisitOption;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -38,6 +37,7 @@ import com.dfsek.terra.addons.manifest.impl.config.loaders.VersionRangeLoader;
|
||||
import com.dfsek.terra.addons.manifest.impl.exception.AddonException;
|
||||
import com.dfsek.terra.addons.manifest.impl.exception.ManifestException;
|
||||
import com.dfsek.terra.addons.manifest.impl.exception.ManifestNotPresentException;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
|
||||
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;
|
||||
|
||||
|
||||
@@ -72,13 +72,9 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
|
||||
throw new AddonException("Addon " + manifest.getID() + " has unknown schema version: " + manifest.getSchemaVersion());
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed", "resource" })
|
||||
ManifestAddonClassLoader childLoader = new ManifestAddonClassLoader(new URL[]{ addonPath.toUri().toURL() },
|
||||
loader);
|
||||
|
||||
List<AddonInitializer> initializers = manifest.getEntryPoints().stream().map(entryPoint -> {
|
||||
try {
|
||||
Object in = childLoader.loadClass(entryPoint).getConstructor().newInstance();
|
||||
Object in = loader.loadClass(entryPoint).getConstructor().newInstance();
|
||||
if(!(in instanceof AddonInitializer)) {
|
||||
throw new AddonException(in.getClass() + " does not extend " + AddonInitializer.class);
|
||||
}
|
||||
@@ -103,7 +99,7 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ManifestAddon> loadAddons(Path addonsFolder, ClassLoader parent) {
|
||||
public Iterable<ManifestAddon> loadAddons(Path addonsFolder, BootstrapAddonClassLoader parent) {
|
||||
logger.debug("Loading addons...");
|
||||
|
||||
try(Stream<Path> files = Files.walk(addonsFolder, 1, FileVisitOption.FOLLOW_LINKS)) {
|
||||
@@ -114,16 +110,16 @@ public class ManifestAddonLoader implements BootstrapBaseAddon<ManifestAddon> {
|
||||
.filter(path -> path.toString().endsWith(".jar"))
|
||||
.toList();
|
||||
|
||||
ManifestAddonClassLoader loader = new ManifestAddonClassLoader(addons.stream().map(path -> {
|
||||
addons.stream().map(path -> {
|
||||
try {
|
||||
return path.toUri().toURL();
|
||||
} catch(MalformedURLException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}).toArray(URL[]::new), getClass().getClassLoader());
|
||||
}).forEach(parent::addURL);
|
||||
|
||||
return addons.stream()
|
||||
.map(jar -> loadAddon(jar, loader))
|
||||
.map(jar -> loadAddon(jar, parent))
|
||||
.collect(Collectors.toList());
|
||||
} catch(IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ entrypoints:
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,5 +1,5 @@
|
||||
version = version("0.1.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ entrypoints: [ ]
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,25 +1,17 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("0.1.0")
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
version = version("1.0.0")
|
||||
|
||||
repositories {
|
||||
maven { url = uri("https://jitpack.io/") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
shadedApi("commons-io:commons-io:2.6")
|
||||
shadedApi("com.github.Querz:NBT:6.1")
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
api("commons-io:commons-io:2.7")
|
||||
api("com.github.Querz:NBT:6.1")
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("org.apache.commons", "com.dfsek.terra.addons.sponge.lib.commons")
|
||||
}
|
||||
|
||||
tasks.named("build") {
|
||||
finalizedBy(tasks.named("shadowJar"))
|
||||
}
|
||||
@@ -6,7 +6,7 @@ version: @VERSION@
|
||||
entrypoints:
|
||||
- "com.dfsek.terra.addons.sponge.SpongeSchematicAddon"
|
||||
website:
|
||||
issues: https://github.com/PolyhedralDev/Terra-structure-sponge-loader/issues
|
||||
source: https://github.com/PolyhedralDev/Terra-structure-sponge-loader
|
||||
docs: https://github.com/PolyhedralDev/Terra/wiki
|
||||
license: GNU LGPL v3.0
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
@@ -1,21 +1,15 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("0.1.0")
|
||||
|
||||
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow")
|
||||
}
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
shadedApi("commons-io:commons-io:2.6")
|
||||
shadedApi(project(":common:addons:manifest-addon-loader"))
|
||||
api("commons-io:commons-io:2.7")
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate("org.apache.commons", "com.dfsek.terra.addons.terrascript.lib.commons")
|
||||
}
|
||||
|
||||
tasks.named("build") {
|
||||
finalizedBy(tasks.named("shadowJar"))
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.terrascript.lib.jafama")
|
||||
}
|
||||
+2
-2
@@ -12,7 +12,7 @@ public class Scope {
|
||||
public Variable<?> get(String id) {
|
||||
throw new IllegalStateException("Cannot get variable from null scope: " + id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void put(String id, Variable<?> variable) {
|
||||
throw new IllegalStateException("Cannot set variable in null scope: " + id);
|
||||
@@ -38,7 +38,7 @@ public class Scope {
|
||||
public void put(String id, Variable<?> variable) {
|
||||
variableMap.put(id, variable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Scope sub() {
|
||||
return new Scope(this);
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
|
||||
@@ -24,11 +26,11 @@ public abstract class BinaryOperation<I, O> implements Returnable<O> {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public abstract O apply(I left, I right);
|
||||
public abstract O apply(Supplier<I> left, Supplier<I> right);
|
||||
|
||||
@Override
|
||||
public O apply(ImplementationArguments implementationArguments, Scope scope) {
|
||||
return apply(left.apply(implementationArguments, scope), right.apply(implementationArguments, scope));
|
||||
return apply(() -> left.apply(implementationArguments, scope), () -> right.apply(implementationArguments, scope));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
@@ -17,8 +19,8 @@ public class BooleanAndOperation extends BinaryOperation<Boolean, Boolean> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(Boolean left, Boolean right) {
|
||||
return left && right;
|
||||
public Boolean apply(Supplier<Boolean> left, Supplier<Boolean> right) {
|
||||
return left.get() && right.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
@@ -17,8 +19,8 @@ public class BooleanOrOperation extends BinaryOperation<Boolean, Boolean> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(Boolean left, Boolean right) {
|
||||
return left || right;
|
||||
public Boolean apply(Supplier<Boolean> left, Supplier<Boolean> right) {
|
||||
return left.get() || right.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
@@ -17,8 +19,8 @@ public class ConcatenationOperation extends BinaryOperation<Object, Object> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Object left, Object right) {
|
||||
return left.toString() + right.toString();
|
||||
public String apply(Supplier<Object> left, Supplier<Object> right) {
|
||||
return left.get().toString() + right.get().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
@@ -17,8 +19,8 @@ public class DivisionOperation extends BinaryOperation<Number, Number> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number apply(Number left, Number right) {
|
||||
return left.doubleValue() / right.doubleValue();
|
||||
public Number apply(Supplier<Number> left, Supplier<Number> right) {
|
||||
return left.get().doubleValue() / right.get().doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
@@ -17,8 +19,8 @@ public class ModuloOperation extends BinaryOperation<Number, Number> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number apply(Number left, Number right) {
|
||||
return left.doubleValue() % right.doubleValue();
|
||||
public Number apply(Supplier<Number> left, Supplier<Number> right) {
|
||||
return left.get().doubleValue() % right.get().doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
@@ -17,8 +19,8 @@ public class MultiplicationOperation extends BinaryOperation<Number, Number> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number apply(Number left, Number right) {
|
||||
return left.doubleValue() * right.doubleValue();
|
||||
public Number apply(Supplier<Number> left, Supplier<Number> right) {
|
||||
return left.get().doubleValue() * right.get().doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
@@ -17,8 +19,8 @@ public class NumberAdditionOperation extends BinaryOperation<Number, Number> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number apply(Number left, Number right) {
|
||||
return left.doubleValue() + right.doubleValue();
|
||||
public Number apply(Supplier<Number> left, Supplier<Number> right) {
|
||||
return left.get().doubleValue() + right.get().doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
@@ -17,8 +19,8 @@ public class SubtractionOperation extends BinaryOperation<Number, Number> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number apply(Number left, Number right) {
|
||||
return left.doubleValue() - right.doubleValue();
|
||||
public Number apply(Supplier<Number> left, Supplier<Number> right) {
|
||||
return left.get().doubleValue() - right.get().doubleValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-5
@@ -9,25 +9,30 @@ package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
import static com.dfsek.terra.api.util.MathUtil.EPSILON;
|
||||
|
||||
|
||||
public class EqualsStatement extends BinaryOperation<Object, Boolean> {
|
||||
private static final double EPSILON = 0.000000001D;
|
||||
|
||||
public EqualsStatement(Returnable<Object> left, Returnable<Object> right, Position position) {
|
||||
super(left, right, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(Object left, Object right) {
|
||||
if(left instanceof Number && right instanceof Number) {
|
||||
return FastMath.abs(((Number) left).doubleValue() - ((Number) right).doubleValue()) <= EPSILON;
|
||||
public Boolean apply(Supplier<Object> left, Supplier<Object> right) {
|
||||
Object leftUnwrapped = left.get();
|
||||
Object rightUnwrapped = right.get();
|
||||
if(leftUnwrapped instanceof Number l && rightUnwrapped instanceof Number r) {
|
||||
return FastMath.abs(l.doubleValue() - r.doubleValue()) <= EPSILON;
|
||||
}
|
||||
|
||||
return left.equals(right);
|
||||
return left.equals(rightUnwrapped);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
@@ -18,8 +20,8 @@ public class GreaterOrEqualsThanStatement extends BinaryOperation<Number, Boolea
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(Number left, Number right) {
|
||||
return left.doubleValue() >= right.doubleValue();
|
||||
public Boolean apply(Supplier<Number> left, Supplier<Number> right) {
|
||||
return left.get().doubleValue() >= right.get().doubleValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
@@ -18,8 +20,8 @@ public class GreaterThanStatement extends BinaryOperation<Number, Boolean> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(Number left, Number right) {
|
||||
return left.doubleValue() > right.doubleValue();
|
||||
public Boolean apply(Supplier<Number> left, Supplier<Number> right) {
|
||||
return left.get().doubleValue() > right.get().doubleValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
@@ -18,8 +20,8 @@ public class LessThanOrEqualsStatement extends BinaryOperation<Number, Boolean>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(Number left, Number right) {
|
||||
return left.doubleValue() <= right.doubleValue();
|
||||
public Boolean apply(Supplier<Number> left, Supplier<Number> right) {
|
||||
return left.get().doubleValue() <= right.get().doubleValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+4
-2
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
@@ -18,8 +20,8 @@ public class LessThanStatement extends BinaryOperation<Number, Boolean> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(Number left, Number right) {
|
||||
return left.doubleValue() < right.doubleValue();
|
||||
public Boolean apply(Supplier<Number> left, Supplier<Number> right) {
|
||||
return left.get().doubleValue() < right.get().doubleValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user