mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
Merge pull request #362 from duplexsystem/dev/enviroment
Dev/enviroment
This commit is contained in:
@@ -3,32 +3,20 @@ plugins {
|
||||
kotlin("jvm") version embeddedKotlinVersion
|
||||
}
|
||||
|
||||
buildscript {
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
force("org.ow2.asm:asm:9.3") // TODO: remove when ShadowJar updates ASM version
|
||||
force("org.ow2.asm:asm-commons:9.3")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven("https://repo.codemc.org/repository/maven-public") {
|
||||
name = "CodeMC"
|
||||
}
|
||||
maven("https://papermc.io/repo/repository/maven-public/") {
|
||||
name = "PaperMC"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:+")
|
||||
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.3.5")
|
||||
implementation(libs.libraries.internal.shadow)
|
||||
|
||||
|
||||
implementation("org.ow2.asm:asm:9.3")
|
||||
implementation("org.ow2.asm:asm-tree:9.3")
|
||||
implementation("com.dfsek.tectonic:common:4.2.0")
|
||||
implementation("org.yaml:snakeyaml:1.27")
|
||||
implementation(libs.libraries.internal.asm)
|
||||
implementation(libs.libraries.internal.asm.tree)
|
||||
implementation(libs.libraries.tectonic)
|
||||
implementation(libs.libraries.snakeyaml)
|
||||
}
|
||||
7
buildSrc/settings.gradle.kts
Normal file
7
buildSrc/settings.gradle.kts
Normal file
@@ -0,0 +1,7 @@
|
||||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../gradle/libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import org.gradle.kotlin.dsl.getValue
|
||||
import org.gradle.kotlin.dsl.getting
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.gradle.kotlin.dsl.repositories
|
||||
import org.gradle.api.artifacts.VersionCatalog
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
|
||||
fun Project.configureDependencies() {
|
||||
val testImplementation by configurations.getting
|
||||
@@ -15,6 +17,8 @@ fun Project.configureDependencies() {
|
||||
|
||||
val shaded by configurations.creating
|
||||
|
||||
val libs = rootProject.project.versionCatalogs.libs
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val shadedApi by configurations.creating {
|
||||
shaded.extendsFrom(this)
|
||||
@@ -48,14 +52,17 @@ fun Project.configureDependencies() {
|
||||
maven("https://jitpack.io") {
|
||||
name = "JitPack"
|
||||
}
|
||||
maven("Modrinth") {
|
||||
url = uri("https://api.modrinth.com/maven")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
|
||||
compileOnly("com.google.guava:guava:30.0-jre")
|
||||
testImplementation("com.google.guava:guava:30.0-jre")
|
||||
testImplementation(libs.findLibrary("libraries.internal.junit.jupiter.api").get())
|
||||
testImplementation(libs.findLibrary("libraries.internal.junit.jupiter.engine").get())
|
||||
compileOnly(libs.findLibrary("libraries.internal.jetbrains.annotations").get())
|
||||
|
||||
compileOnly(libs.findLibrary("libraries.guava").get())
|
||||
testImplementation(libs.findLibrary("libraries.guava").get())
|
||||
}
|
||||
}
|
||||
12
buildSrc/src/main/kotlin/Helper.kt
Normal file
12
buildSrc/src/main/kotlin/Helper.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
import org.gradle.api.artifacts.VersionCatalogsExtension
|
||||
import org.gradle.api.artifacts.VersionCatalog
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
|
||||
internal
|
||||
val Project.versionCatalogs: VersionCatalogsExtension
|
||||
get() = the<VersionCatalogsExtension>()
|
||||
|
||||
internal
|
||||
val VersionCatalogsExtension.libs: VersionCatalog
|
||||
get() = named("libs")
|
||||
@@ -1,72 +0,0 @@
|
||||
object Versions {
|
||||
object Libraries {
|
||||
const val tectonic = "4.2.0"
|
||||
const val paralithic = "0.7.0"
|
||||
const val strata = "1.1.1"
|
||||
|
||||
const val cloud = "1.7.0"
|
||||
|
||||
const val slf4j = "1.7.36"
|
||||
const val log4j_slf4j_impl = "2.14.1"
|
||||
|
||||
const val caffeine = "3.1.0"
|
||||
const val vavr = "0.10.4"
|
||||
|
||||
object Internal {
|
||||
const val apacheText = "1.9"
|
||||
const val jafama = "2.3.2"
|
||||
const val apacheIO = "2.6"
|
||||
const val fastutil = "8.5.6"
|
||||
}
|
||||
}
|
||||
|
||||
object Fabric {
|
||||
const val fabricLoader = "0.14.8"
|
||||
const val fabricAPI = "0.57.0+1.19"
|
||||
}
|
||||
|
||||
object Quilt {
|
||||
const val quiltLoader = "0.17.0"
|
||||
const val fabricApi = "2.0.0-beta.4+0.57.0-1.19"
|
||||
}
|
||||
|
||||
object Mod {
|
||||
const val mixin = "0.11.2+mixin.0.8.5"
|
||||
|
||||
const val minecraft = "1.19"
|
||||
const val yarn = "$minecraft+build.1"
|
||||
const val fabricLoader = "0.14.2"
|
||||
|
||||
const val architecuryLoom = "0.12.0.290"
|
||||
const val architecturyPlugin = "3.4-SNAPSHOT"
|
||||
|
||||
const val loomQuiltflower = "1.7.1"
|
||||
|
||||
const val lazyDfu = "0.1.2"
|
||||
}
|
||||
|
||||
object Forge {
|
||||
const val forge = "${Mod.minecraft}-41.0.63"
|
||||
const val burningwave = "12.53.0"
|
||||
}
|
||||
|
||||
object Bukkit {
|
||||
const val paper = "1.18.2-R0.1-SNAPSHOT"
|
||||
const val paperLib = "1.0.5"
|
||||
const val minecraft = "1.19"
|
||||
const val reflectionRemapper = "0.1.0-SNAPSHOT"
|
||||
}
|
||||
|
||||
object Sponge {
|
||||
const val sponge = "9.0.0-SNAPSHOT"
|
||||
const val mixin = "0.8.2"
|
||||
const val minecraft = "1.17.1"
|
||||
}
|
||||
|
||||
object CLI {
|
||||
const val nbt = "6.1"
|
||||
const val logback = "1.2.9"
|
||||
const val commonsIO = "2.7"
|
||||
const val guava = "31.0.1-jre"
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,4 @@ version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
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")
|
||||
}
|
||||
@@ -2,11 +2,4 @@ version = version("1.0.1")
|
||||
|
||||
dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
}
|
||||
|
||||
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.biome.pipeline.lib.jafama")
|
||||
}
|
||||
@@ -2,11 +2,4 @@ version = version("1.1.0")
|
||||
|
||||
dependencies {
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Class for bilinear interpolation of values arranged on a unit square.
|
||||
*/
|
||||
@@ -28,19 +31,6 @@ public class Interpolator {
|
||||
this.v3 = v3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1D Linear interpolation between 2 points 1 unit apart.
|
||||
*
|
||||
* @param t - Distance from v0. Total distance between v0 and v1 is 1 unit.
|
||||
* @param v0 - Value at v0.
|
||||
* @param v1 - Value at v1.
|
||||
*
|
||||
* @return double - The interpolated value.
|
||||
*/
|
||||
public static double lerp(double t, double v0, double v1) {
|
||||
return v0 + t * (v1 - v0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2D Bilinear interpolation between 4 points on a unit square.
|
||||
*
|
||||
@@ -50,8 +40,8 @@ public class Interpolator {
|
||||
* @return double - The interpolated value.
|
||||
*/
|
||||
public double bilerp(double s, double t) {
|
||||
double v01 = lerp(s, v0, v1);
|
||||
double v23 = lerp(s, v2, v3);
|
||||
return lerp(t, v01, v23);
|
||||
double v01 = MathUtil.lerp(s, v0, v1);
|
||||
double v23 = MathUtil.lerp(s, v2, v3);
|
||||
return MathUtil.lerp(t, v01, v23);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Class for bilinear interpolation of values arranged on a unit square.
|
||||
*/
|
||||
@@ -34,6 +37,6 @@ public class Interpolator3 {
|
||||
}
|
||||
|
||||
public double trilerp(double x, double y, double z) {
|
||||
return Interpolator.lerp(x, top.bilerp(y, z), bottom.bilerp(y, z));
|
||||
return MathUtil.lerp(x, top.bilerp(y, z), bottom.bilerp(y, z));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
|
||||
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
|
||||
import static com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.Interpolator.lerp;
|
||||
|
||||
|
||||
public class LazilyEvaluatedInterpolator {
|
||||
private final Double[] samples; //
|
||||
@@ -84,10 +84,10 @@ public class LazilyEvaluatedInterpolator {
|
||||
|
||||
double xFrac = (double) (x % horizontalRes) / horizontalRes;
|
||||
double zFrac = (double) (z % horizontalRes) / horizontalRes;
|
||||
double lerp_bottom_0 = lerp(zFrac, sample_0_0_0, sample_0_0_1);
|
||||
double lerp_bottom_1 = lerp(zFrac, sample_1_0_0, sample_1_0_1);
|
||||
double lerp_bottom_0 = MathUtil.lerp(zFrac, sample_0_0_0, sample_0_0_1);
|
||||
double lerp_bottom_1 = MathUtil.lerp(zFrac, sample_1_0_0, sample_1_0_1);
|
||||
|
||||
double lerp_bottom = lerp(xFrac, lerp_bottom_0, lerp_bottom_1);
|
||||
double lerp_bottom = MathUtil.lerp(xFrac, lerp_bottom_0, lerp_bottom_1);
|
||||
|
||||
if(yRange) { // we can do bilerp
|
||||
return lerp_bottom;
|
||||
@@ -103,11 +103,11 @@ public class LazilyEvaluatedInterpolator {
|
||||
double sample_1_1_0 = sample(xIndex + 1, yIndex + 1, zIndex, x + horizontalRes, y + verticalRes, z);
|
||||
double sample_1_1_1 = sample(xIndex + 1, yIndex + 1, zIndex + 1, x + horizontalRes, y + verticalRes, z + horizontalRes);
|
||||
|
||||
double lerp_top_0 = lerp(zFrac, sample_0_1_0, sample_0_1_1);
|
||||
double lerp_top_1 = lerp(zFrac, sample_1_1_0, sample_1_1_1);
|
||||
double lerp_top_0 = MathUtil.lerp(zFrac, sample_0_1_0, sample_0_1_1);
|
||||
double lerp_top_1 = MathUtil.lerp(zFrac, sample_1_1_0, sample_1_1_1);
|
||||
|
||||
double lerp_top = lerp(xFrac, lerp_top_0, lerp_top_1);
|
||||
double lerp_top = MathUtil.lerp(xFrac, lerp_top_0, lerp_top_1);
|
||||
|
||||
return lerp(yFrac, lerp_bottom, lerp_top);
|
||||
return MathUtil.lerp(yFrac, lerp_bottom, lerp_top);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,21 +6,18 @@ import cloud.commandframework.arguments.standard.EnumArgument;
|
||||
import cloud.commandframework.arguments.standard.LongArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.addons.manifest.api.MonadAddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Do;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Get;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.command.CommandSender;
|
||||
import com.dfsek.terra.api.command.arguments.RegistryArgument;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
@@ -42,7 +39,7 @@ public class StructureCommandAddon implements MonadAddonInitializer {
|
||||
handler.register(base, CommandRegistrationEvent.class)
|
||||
.then(event -> {
|
||||
CommandManager<CommandSender> manager = event.getCommandManager();
|
||||
|
||||
|
||||
manager.command(
|
||||
manager.commandBuilder("structures", ArgumentDescription.of("Manage or generate structures"))
|
||||
.literal("generate")
|
||||
@@ -57,9 +54,7 @@ public class StructureCommandAddon implements MonadAddonInitializer {
|
||||
structure.generate(
|
||||
sender.position().toInt(),
|
||||
sender.world(),
|
||||
((Long) context.get("seed") == 0) ? new Random() : new Random(context.get("seed")),
|
||||
context.get("rotation")
|
||||
);
|
||||
context.get("rotation"));
|
||||
})
|
||||
.permission("terra.structures.generate")
|
||||
);
|
||||
|
||||
@@ -2,11 +2,4 @@ version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
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")
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.function.Supplier;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.AndDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.NoDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.OrDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.PaddedGridDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.PaddedGridSamplerDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.PointSetDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.SamplerDistributorTemplate;
|
||||
import com.dfsek.terra.addons.feature.distributor.config.XorDistributorTemplate;
|
||||
@@ -25,11 +25,8 @@ import com.dfsek.terra.addons.manifest.api.MonadAddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Do;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Get;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
import com.dfsek.terra.api.util.function.monad.Monad;
|
||||
@@ -54,7 +51,7 @@ public class DistributorAddon implements MonadAddonInitializer {
|
||||
|
||||
distributorRegistry.register(base.key("SAMPLER"), SamplerDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("POINTS"), PointSetDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("PADDED_GRID"), PaddedGridDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("PADDED_GRID_SAMPLER"), PaddedGridSamplerDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("AND"), AndDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("OR"), OrDistributorTemplate::new);
|
||||
distributorRegistry.register(base.key("XOR"), XorDistributorTemplate::new);
|
||||
|
||||
@@ -3,23 +3,24 @@ package com.dfsek.terra.addons.feature.distributor.config;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.feature.distributor.distributors.PaddedGridDistributor;
|
||||
import com.dfsek.terra.addons.feature.distributor.distributors.PaddedGridSamplerDistributor;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
|
||||
|
||||
public class PaddedGridDistributorTemplate implements ObjectTemplate<Distributor> {
|
||||
public class PaddedGridSamplerDistributorTemplate implements ObjectTemplate<Distributor> {
|
||||
@Value("width")
|
||||
private @Meta int width;
|
||||
|
||||
@Value("padding")
|
||||
private @Meta int padding;
|
||||
|
||||
@Value("salt")
|
||||
private @Meta int salt;
|
||||
@Value("sampler")
|
||||
private @Meta NoiseSampler noise;
|
||||
|
||||
@Override
|
||||
public Distributor get() {
|
||||
return new PaddedGridDistributor(width, padding, salt);
|
||||
return new PaddedGridSamplerDistributor(noise, width, padding);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.dfsek.terra.addons.feature.distributor.distributors;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
|
||||
public class PaddedGridDistributor implements Distributor {
|
||||
private final int width;
|
||||
|
||||
private final int cellWidth;
|
||||
|
||||
private final int salt;
|
||||
|
||||
public PaddedGridDistributor(int width, int padding, int salt) {
|
||||
this.width = width;
|
||||
this.salt = salt;
|
||||
this.cellWidth = width + padding;
|
||||
}
|
||||
|
||||
private static long murmur64(long h) {
|
||||
h ^= h >>> 33;
|
||||
h *= 0xff51afd7ed558ccdL;
|
||||
h ^= h >>> 33;
|
||||
h *= 0xc4ceb9fe1a85ec53L;
|
||||
h ^= h >>> 33;
|
||||
return h;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.dfsek.terra.addons.feature.distributor.distributors;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
|
||||
public class PaddedGridSamplerDistributor implements Distributor {
|
||||
private final NoiseSampler sampler;
|
||||
private final int width;
|
||||
|
||||
private final int cellWidth;
|
||||
|
||||
public PaddedGridSamplerDistributor(NoiseSampler sampler, int width, int padding) {
|
||||
this.sampler = sampler;
|
||||
this.width = width;
|
||||
this.cellWidth = width + padding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
int cellX = FastMath.floorDiv(x, cellWidth);
|
||||
int cellZ = FastMath.floorDiv(z, cellWidth);
|
||||
|
||||
int pointX = (int) (FastMath.round(MathUtil.lerp(MathUtil.inverseLerp(sampler.noise(x, z, seed), -1, 1), 0, width)) + cellX * cellWidth);
|
||||
int pointZ = (int) (FastMath.round(MathUtil.lerp(MathUtil.inverseLerp(sampler.noise(x, z, seed + 1), -1, 1), 0, width)) + cellZ * cellWidth);
|
||||
|
||||
return x == pointX && z == pointZ;
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,4 @@ version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ import net.jafama.FastMath;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.state.properties.enums.Direction;
|
||||
@@ -73,7 +74,7 @@ public class TerraFlora implements Structure {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
boolean doRotation = testRotation.size() > 0;
|
||||
int size = layers.size();
|
||||
int c = ceiling ? -1 : 1;
|
||||
@@ -86,10 +87,7 @@ public class TerraFlora implements Structure {
|
||||
int lvl = (FastMath.abs(i));
|
||||
BlockState data = getStateCollection((ceiling ? lvl : size - lvl - 1)).get(distribution, location.getX(), location.getY(),
|
||||
location.getZ(), world.getSeed());
|
||||
if(doRotation) {
|
||||
Direction oneFace = new ArrayList<>(faces).get(
|
||||
new Random(location.getX() ^ location.getZ()).nextInt(faces.size())); // Get random face.
|
||||
}
|
||||
|
||||
world.setBlockState(location.mutable().add(0, i + c, 0).immutable(), data, physics);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -2,11 +2,4 @@ version = version("1.1.0")
|
||||
|
||||
dependencies {
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -13,10 +13,8 @@ import java.util.function.Supplier;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.config.AdjacentPatternLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.AndLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.GaussianRandomLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.OrLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.PatternLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.RandomLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.Sampler3DLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.SamplerLocatorTemplate;
|
||||
import com.dfsek.terra.addons.feature.locator.config.SurfaceLocatorTemplate;
|
||||
@@ -35,11 +33,8 @@ import com.dfsek.terra.addons.manifest.api.MonadAddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Do;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Get;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.function.monad.Monad;
|
||||
@@ -66,9 +61,6 @@ public class LocatorAddon implements MonadAddonInitializer {
|
||||
locatorRegistry.register(base.key("SURFACE"), SurfaceLocatorTemplate::new);
|
||||
locatorRegistry.register(base.key("TOP"), TopLocatorTemplate::new);
|
||||
|
||||
locatorRegistry.register(base.key("RANDOM"), RandomLocatorTemplate::new);
|
||||
locatorRegistry.register(base.key("GAUSSIAN_RANDOM"), GaussianRandomLocatorTemplate::new);
|
||||
|
||||
locatorRegistry.register(base.key("PATTERN"), PatternLocatorTemplate::new);
|
||||
locatorRegistry.register(base.key("ADJACENT_PATTERN"), AdjacentPatternLocatorTemplate::new);
|
||||
|
||||
|
||||
@@ -1,39 +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.feature.locator.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.locators.GaussianRandomLocator;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class GaussianRandomLocatorTemplate implements ObjectTemplate<Locator> {
|
||||
@Value("height")
|
||||
private @Meta Range height;
|
||||
|
||||
@Value("amount")
|
||||
private @Meta Range amount;
|
||||
|
||||
@Value("standard-deviation")
|
||||
private @Meta double standardDeviation;
|
||||
|
||||
@Value("salt")
|
||||
@Default
|
||||
private @Meta int salt = 0;
|
||||
|
||||
@Override
|
||||
public Locator get() {
|
||||
return new GaussianRandomLocator(height, amount, standardDeviation, salt);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +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.feature.locator.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.feature.locator.locators.RandomLocator;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
public class RandomLocatorTemplate implements ObjectTemplate<Locator> {
|
||||
@Value("height")
|
||||
private @Meta Range height;
|
||||
|
||||
@Value("amount")
|
||||
private @Meta Range amount;
|
||||
|
||||
@Value("salt")
|
||||
@Default
|
||||
private @Meta int salt = 0;
|
||||
|
||||
@Override
|
||||
public Locator get() {
|
||||
return new RandomLocator(height, amount, salt);
|
||||
}
|
||||
}
|
||||
@@ -1,57 +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.feature.locator.locators;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column.BinaryColumnBuilder;
|
||||
|
||||
|
||||
public class GaussianRandomLocator implements Locator {
|
||||
private final double mean;
|
||||
|
||||
private final Range points;
|
||||
|
||||
private final double standardDeviation;
|
||||
|
||||
private final int salt;
|
||||
|
||||
|
||||
public GaussianRandomLocator(Range height, Range points, double standardDeviation, int salt) {
|
||||
this.mean = (height.getMax() + height.getMin()) / 2.0;
|
||||
this.points = points;
|
||||
this.standardDeviation = standardDeviation;
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
long seed = column.getWorld().getSeed();
|
||||
seed = 31 * seed + column.getX();
|
||||
seed = 31 * seed + column.getZ();
|
||||
seed += salt;
|
||||
|
||||
Random r = new Random(seed);
|
||||
|
||||
int size = points.get(r);
|
||||
|
||||
|
||||
BinaryColumnBuilder results = column.newBinaryColumn();
|
||||
for(int i = 0; i < size; i++) {
|
||||
int h = (int) r.nextGaussian(mean, standardDeviation);
|
||||
if(h >= column.getMaxY() || h < column.getMinY()) continue;
|
||||
results.set(h);
|
||||
}
|
||||
|
||||
return results.build();
|
||||
}
|
||||
}
|
||||
@@ -1,52 +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.feature.locator.locators;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.structure.feature.Locator;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column.BinaryColumnBuilder;
|
||||
|
||||
|
||||
public class RandomLocator implements Locator {
|
||||
private final Range height;
|
||||
|
||||
private final Range points;
|
||||
|
||||
private final int salt;
|
||||
|
||||
public RandomLocator(Range height, Range points, int salt) {
|
||||
this.height = height;
|
||||
this.points = points;
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||
long seed = column.getWorld().getSeed();
|
||||
seed = 31 * seed + column.getX();
|
||||
seed = 31 * seed + column.getZ();
|
||||
seed += salt;
|
||||
|
||||
Random r = new Random(seed);
|
||||
|
||||
int size = points.get(r);
|
||||
|
||||
BinaryColumnBuilder results = column.newBinaryColumn();
|
||||
for(int i = 0; i < size; i++) {
|
||||
int h = height.get(r);
|
||||
if(h >= column.getMaxY() || h < column.getMinY()) continue;
|
||||
results.set(h);
|
||||
}
|
||||
|
||||
return results.build();
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,4 @@ version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
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,10 +2,5 @@ version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
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")
|
||||
compileOnlyApi(project(":common:addons:config-noise-function"))
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.ore;
|
||||
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.random.WhiteNoiseSampler;
|
||||
import com.dfsek.terra.addons.ore.ores.VanillaOre;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
@@ -19,6 +20,6 @@ public class OreFactory implements ConfigFactory<OreTemplate, Structure> {
|
||||
public VanillaOre build(OreTemplate config, Platform platform) {
|
||||
BlockState m = config.getMaterial();
|
||||
return new VanillaOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.isExposed(),
|
||||
config.getMaterialOverrides());
|
||||
config.getMaterialOverrides(), new WhiteNoiseSampler());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,13 @@
|
||||
|
||||
package com.dfsek.terra.addons.ore.ores;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
@@ -30,38 +33,40 @@ public class VanillaOre implements Structure {
|
||||
private final boolean applyGravity;
|
||||
private final double exposed;
|
||||
private final Map<BlockType, BlockState> materials;
|
||||
private final NoiseSampler sampler;
|
||||
|
||||
public VanillaOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity,
|
||||
double exposed, Map<BlockType, BlockState> materials) {
|
||||
double exposed, Map<BlockType, BlockState> materials, NoiseSampler sampler) {
|
||||
this.material = material;
|
||||
this.size = size;
|
||||
this.replaceable = replaceable;
|
||||
this.applyGravity = applyGravity;
|
||||
this.exposed = exposed;
|
||||
this.materials = materials;
|
||||
this.sampler = sampler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation){
|
||||
int centerX = location.getX();
|
||||
int centerZ = location.getZ();
|
||||
int centerY = location.getY();
|
||||
|
||||
|
||||
float f = random.nextFloat() * (float) Math.PI;
|
||||
double f = sampler.noise(centerX, centerY, centerZ, world.getSeed()) * (float) Math.PI;
|
||||
|
||||
double d1 = centerX + 8 + FastMath.sin(f) * size / 8.0F;
|
||||
double d2 = centerX + 8 - FastMath.sin(f) * size / 8.0F;
|
||||
double d3 = centerZ + 8 + FastMath.cos(f) * size / 8.0F;
|
||||
double d4 = centerZ + 8 - FastMath.cos(f) * size / 8.0F;
|
||||
|
||||
double d5 = centerY + random.nextInt(3) - 2D;
|
||||
double d6 = centerY + random.nextInt(3) - 2D;
|
||||
double d5 = centerY + (Math.round(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 1) + 1)) - 2D;
|
||||
double d6 = centerY + (Math.round(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 2) + 1)) - 2D;
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
float iFactor = (float) i / (float) size;
|
||||
|
||||
double d10 = random.nextDouble() * size / 16.0D;
|
||||
double d10 = MathUtil.inverseLerp(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 2 + (i * 2 - 1)), -1, 1) * size / 16.0D;
|
||||
double d11 = (FastMath.sin(Math.PI * iFactor) + 1.0) * d10 + 1.0;
|
||||
double d12 = (FastMath.sin(Math.PI * iFactor) + 1.0) * d10 + 1.0;
|
||||
|
||||
@@ -85,7 +90,7 @@ public class VanillaOre implements Structure {
|
||||
if(y >= world.getMaxHeight() || y < world.getMinHeight()) continue;
|
||||
BlockType block = world.getBlockState(x, y, z).getBlockType();
|
||||
if((d13 * d13 + d14 * d14 + d15 * d15 < 1.0D) && getReplaceable().contains(block)) {
|
||||
if(exposed > random.nextDouble() || !(world.getBlockState(x, y, z - 1).isAir() ||
|
||||
if(exposed > MathUtil.inverseLerp(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 2 + (i * 2)), -1, 1) || !(world.getBlockState(x, y, z - 1).isAir() ||
|
||||
world.getBlockState(x, y, z + 1).isAir() ||
|
||||
world.getBlockState(x, y - 1, z).isAir() ||
|
||||
world.getBlockState(x, y + 1, z).isAir() ||
|
||||
|
||||
@@ -9,4 +9,6 @@ website:
|
||||
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||
source: https://github.com/PolyhedralDev/Terra
|
||||
docs: https://terra.polydev.org
|
||||
license: MIT License
|
||||
license: MIT License
|
||||
depends:
|
||||
config-noise-function: "1.+"
|
||||
@@ -1,13 +1,5 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
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")
|
||||
}
|
||||
}
|
||||
@@ -1,109 +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.structure.structures.loot;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.AmountFunction;
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.DamageFunction;
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.EnchantFunction;
|
||||
import com.dfsek.terra.addons.structure.structures.loot.functions.LootFunction;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.Item;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a single item entry within a Loot Table pool.
|
||||
*/
|
||||
public class Entry {
|
||||
private final Item item;
|
||||
private final long weight;
|
||||
private final List<LootFunction> functions = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Instantiates an Entry from a JSON representation.
|
||||
*
|
||||
* @param entry The JSON Object to instantiate from.
|
||||
*/
|
||||
public Entry(JSONObject entry, Platform platform) {
|
||||
String id = entry.get("name").toString();
|
||||
this.item = platform.getItemHandle().createItem(id);
|
||||
|
||||
long weight1;
|
||||
try {
|
||||
weight1 = (long) entry.get("weight");
|
||||
} catch(NullPointerException e) {
|
||||
weight1 = 1;
|
||||
}
|
||||
|
||||
this.weight = weight1;
|
||||
if(entry.containsKey("functions")) {
|
||||
for(Object function : (JSONArray) entry.get("functions")) {
|
||||
switch(((String) ((JSONObject) function).get("function"))) {
|
||||
case "minecraft:set_count", "set_count" -> {
|
||||
Object loot = ((JSONObject) function).get("count");
|
||||
long max, min;
|
||||
if(loot instanceof Long) {
|
||||
max = (Long) loot;
|
||||
min = (Long) loot;
|
||||
} else {
|
||||
max = (long) ((JSONObject) loot).get("max");
|
||||
min = (long) ((JSONObject) loot).get("min");
|
||||
}
|
||||
functions.add(new AmountFunction(FastMath.toIntExact(min), FastMath.toIntExact(max)));
|
||||
}
|
||||
case "minecraft:set_damage", "set_damage" -> {
|
||||
long maxDamage = (long) ((JSONObject) ((JSONObject) function).get("damage")).get("max");
|
||||
long minDamage = (long) ((JSONObject) ((JSONObject) function).get("damage")).get("min");
|
||||
functions.add(new DamageFunction(FastMath.toIntExact(minDamage), FastMath.toIntExact(maxDamage)));
|
||||
}
|
||||
case "minecraft:enchant_with_levels", "enchant_with_levels" -> {
|
||||
long maxEnchant = (long) ((JSONObject) ((JSONObject) function).get("levels")).get("max");
|
||||
long minEnchant = (long) ((JSONObject) ((JSONObject) function).get("levels")).get("min");
|
||||
JSONArray disabled = null;
|
||||
if(((JSONObject) function).containsKey("disabled_enchants"))
|
||||
disabled = (JSONArray) ((JSONObject) function).get("disabled_enchants");
|
||||
functions.add(
|
||||
new EnchantFunction(FastMath.toIntExact(minEnchant), FastMath.toIntExact(maxEnchant), disabled, platform));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a single ItemStack from the Entry, applying all functions to it.
|
||||
*
|
||||
* @param r The Random instance to apply functions with
|
||||
*
|
||||
* @return ItemStack - The ItemStack with all functions applied.
|
||||
*/
|
||||
public ItemStack getItem(Random r) {
|
||||
ItemStack item = this.item.newItemStack(1);
|
||||
for(LootFunction f : functions) {
|
||||
item = f.apply(item, r);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weight attribute of the Entry.
|
||||
*
|
||||
* @return long - The weight of the Entry.
|
||||
*/
|
||||
public long getWeight() {
|
||||
return this.weight;
|
||||
}
|
||||
}
|
||||
@@ -1,80 +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.structure.structures.loot;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.Inventory;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
|
||||
/**
|
||||
* Class representation of a Loot Table to populate chest loot.
|
||||
*/
|
||||
public class LootTableImpl implements com.dfsek.terra.api.structure.LootTable {
|
||||
private final List<Pool> pools = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Instantiates a LootTable from a JSON String.
|
||||
*
|
||||
* @param json The JSON String representing the loot table.
|
||||
*
|
||||
* @throws ParseException if malformed JSON is passed.
|
||||
*/
|
||||
public LootTableImpl(String json, Platform platform) throws ParseException {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
Object tableJSON = jsonParser.parse(json);
|
||||
JSONArray poolArray = (JSONArray) ((JSONObject) tableJSON).get("pools");
|
||||
for(Object pool : poolArray) {
|
||||
pools.add(new Pool((JSONObject) pool, platform));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInventory(Inventory i, Random r) {
|
||||
List<ItemStack> loot = getLoot(r);
|
||||
for(ItemStack stack : loot) {
|
||||
int attempts = 0;
|
||||
while(stack.getAmount() != 0 && attempts < 10) {
|
||||
ItemStack newStack = stack.getType().newItemStack(stack.getAmount());
|
||||
newStack.setItemMeta(stack.getItemMeta());
|
||||
newStack.setAmount(1);
|
||||
int slot = r.nextInt(i.getSize());
|
||||
ItemStack slotItem = i.getItem(slot);
|
||||
if(slotItem == null) {
|
||||
i.setItem(slot, newStack);
|
||||
stack.setAmount(stack.getAmount() - 1);
|
||||
} else if(slotItem.getType().equals(newStack.getType())) {
|
||||
ItemStack dep = newStack.getType().newItemStack(newStack.getAmount());
|
||||
dep.setItemMeta(newStack.getItemMeta());
|
||||
dep.setAmount(newStack.getAmount() + slotItem.getAmount());
|
||||
i.setItem(slot, dep);
|
||||
stack.setAmount(stack.getAmount() - 1);
|
||||
}
|
||||
attempts++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getLoot(Random r) {
|
||||
List<ItemStack> itemList = new ArrayList<>();
|
||||
for(Pool pool : pools) {
|
||||
itemList.addAll(pool.getItems(r));
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
}
|
||||
@@ -1,69 +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.structure.structures.loot;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
|
||||
/**
|
||||
* Representation of a Loot Table pool, or a set of items to be fetched independently.
|
||||
*/
|
||||
public class Pool {
|
||||
private final int max;
|
||||
private final int min;
|
||||
private final ProbabilityCollection<Entry> entries;
|
||||
|
||||
/**
|
||||
* Instantiates a Pool from a JSON representation.
|
||||
*
|
||||
* @param pool The JSON Object to instantiate from.
|
||||
*/
|
||||
public Pool(JSONObject pool, Platform platform) {
|
||||
entries = new ProbabilityCollection<>();
|
||||
Object amount = pool.get("rolls");
|
||||
if(amount instanceof Long) {
|
||||
max = FastMath.toIntExact((Long) amount);
|
||||
min = FastMath.toIntExact((Long) amount);
|
||||
} else {
|
||||
max = FastMath.toIntExact((Long) ((JSONObject) amount).get("max"));
|
||||
min = FastMath.toIntExact((Long) ((JSONObject) amount).get("min"));
|
||||
}
|
||||
|
||||
for(Object entryJSON : (JSONArray) pool.get("entries")) {
|
||||
Entry entry = new Entry((JSONObject) entryJSON, platform);
|
||||
entries.add(entry, FastMath.toIntExact(entry.getWeight()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a list of items from the pool using the provided Random instance.
|
||||
*
|
||||
* @param r The Random instance to use.
|
||||
*
|
||||
* @return List<ItemStack> - The list of items fetched.
|
||||
*/
|
||||
public List<ItemStack> getItems(Random r) {
|
||||
|
||||
int rolls = r.nextInt(max - min + 1) + min;
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for(int i = 0; i < rolls; i++) {
|
||||
items.add(entries.get(r).getItem(r));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +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.structure.structures.loot.functions;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
|
||||
/**
|
||||
* Loot LootFunction fot setting the amount of an item.
|
||||
*/
|
||||
public class AmountFunction implements LootFunction {
|
||||
private final int max;
|
||||
private final int min;
|
||||
|
||||
/**
|
||||
* Instantiates an AmountFunction.
|
||||
*
|
||||
* @param min Minimum amount.
|
||||
* @param max Maximum amount.
|
||||
*/
|
||||
public AmountFunction(int min, int max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the function to an ItemStack.
|
||||
*
|
||||
* @param original The ItemStack on which to apply the function.
|
||||
* @param r The Random instance to use.
|
||||
*
|
||||
* @return - ItemStack - The mutated ItemStack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack apply(ItemStack original, Random r) {
|
||||
original.setAmount(r.nextInt(max - min + 1) + min);
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +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.structure.structures.loot.functions;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.inventory.item.Damageable;
|
||||
import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
|
||||
|
||||
/**
|
||||
* Loot LootFunction for setting the damage on items in Loot Tables
|
||||
*/
|
||||
public class DamageFunction implements LootFunction {
|
||||
private final int max;
|
||||
private final int min;
|
||||
|
||||
/**
|
||||
* Instantiates a DamageFunction.
|
||||
*
|
||||
* @param min Minimum amount of damage (percentage, out of 100)
|
||||
* @param max Maximum amount of damage (percentage, out of 100)
|
||||
*/
|
||||
public DamageFunction(int min, int max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the function to an ItemStack.
|
||||
*
|
||||
* @param original The ItemStack on which to apply the function.
|
||||
* @param r The Random instance to use.
|
||||
*
|
||||
* @return - ItemStack - The mutated ItemStack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack apply(ItemStack original, Random r) {
|
||||
if(original == null) return null;
|
||||
if(!original.isDamageable()) return original;
|
||||
ItemMeta meta = original.getItemMeta();
|
||||
double itemDurability = (r.nextDouble() * (max - min)) + min;
|
||||
Damageable damage = (Damageable) meta;
|
||||
damage.setDamage((int) (original.getType().getMaxDurability() - (itemDurability / 100) * original.getType().getMaxDurability()));
|
||||
original.setItemMeta((ItemMeta) damage);
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +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.structure.structures.loot.functions;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.inventory.item.ItemMeta;
|
||||
|
||||
|
||||
public class EnchantFunction implements LootFunction {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EnchantFunction.class);
|
||||
private final int min;
|
||||
private final int max;
|
||||
private final JSONArray disabled;
|
||||
private final Platform platform;
|
||||
|
||||
|
||||
public EnchantFunction(int min, int max, JSONArray disabled, Platform platform) {
|
||||
this.max = max;
|
||||
this.min = min;
|
||||
this.disabled = disabled;
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the function to an ItemStack.
|
||||
*
|
||||
* @param original The ItemStack on which to apply the function.
|
||||
* @param r The Random instance to use.
|
||||
*
|
||||
* @return - ItemStack - The mutated ItemStack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack apply(ItemStack original, Random r) {
|
||||
if(original.getItemMeta() == null) return original;
|
||||
|
||||
double enchant = (r.nextDouble() * (max - min)) + min;
|
||||
List<Enchantment> possible = new ArrayList<>();
|
||||
for(Enchantment ench : platform.getItemHandle().getEnchantments()) {
|
||||
if(ench.canEnchantItem(original) && (disabled == null || !this.disabled.contains(ench.getID()))) {
|
||||
possible.add(ench);
|
||||
}
|
||||
}
|
||||
int numEnchant = (r.nextInt((int) FastMath.abs(enchant)) / 10 + 1);
|
||||
Collections.shuffle(possible);
|
||||
ItemMeta meta = original.getItemMeta();
|
||||
iter:
|
||||
for(int i = 0; i < numEnchant && i < possible.size(); i++) {
|
||||
Enchantment chosen = possible.get(i);
|
||||
for(Enchantment ench : meta.getEnchantments().keySet()) {
|
||||
if(chosen.conflictsWith(ench)) continue iter;
|
||||
}
|
||||
int lvl = r.nextInt(1 + (int) (((enchant / 40 > 1) ? 1 : enchant / 40) * (chosen.getMaxLevel())));
|
||||
try {
|
||||
meta.addEnchantment(chosen, FastMath.max(lvl, 1));
|
||||
} catch(IllegalArgumentException e) {
|
||||
LOGGER.warn(
|
||||
"Attempted to enchant {} with {} at level {}, but an unexpected exception occurred! Usually this is caused by a " +
|
||||
"misbehaving enchantment plugin.",
|
||||
original.getType(), chosen, FastMath.max(lvl, 1));
|
||||
}
|
||||
}
|
||||
original.setItemMeta(meta);
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +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.structure.structures.loot.functions;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for mutating items in Loot Tables.
|
||||
*/
|
||||
public interface LootFunction {
|
||||
/**
|
||||
* Applies the function to an ItemStack.
|
||||
*
|
||||
* @param original The ItemStack on which to apply the function.
|
||||
* @param r The Random instance to use.
|
||||
*
|
||||
* @return - ItemStack - The mutated ItemStack.
|
||||
*/
|
||||
ItemStack apply(ItemStack original, Random r);
|
||||
}
|
||||
@@ -8,7 +8,8 @@
|
||||
package com.dfsek.terra.addons.generation.feature;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
@@ -58,7 +59,6 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
for(int subChunkZ = 0; subChunkZ < resolution; subChunkZ++) {
|
||||
int x = subChunkX + tx;
|
||||
int z = subChunkZ + tz;
|
||||
long coordinateSeed = (seed * 31 + x) * 31 + z;
|
||||
Column<WritableWorld> column = world.column(x, z);
|
||||
biome.getContext()
|
||||
.get(biomeFeaturesKey)
|
||||
@@ -72,7 +72,6 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
.forEach(y -> feature.getStructure(world, x, y, z)
|
||||
.generate(Vector3Int.of(x, y, z),
|
||||
world,
|
||||
new Random(coordinateSeed * 31 + y),
|
||||
Rotation.NONE)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
implementation(libs.libraries.tectonic.yaml)
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
version = version("1.0.0")
|
||||
|
||||
dependencies {
|
||||
api("commons-io:commons-io:2.7")
|
||||
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}")
|
||||
api(libs.libraries.internal.apache.io)
|
||||
implementation(libs.libraries.tectonic.yaml)
|
||||
}
|
||||
|
||||
tasks.withType<Jar> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.palette.shortcut.block;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
@@ -17,7 +17,7 @@ public class SingletonStructure implements Structure {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
world.setBlockState(location, blockState);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.structure.mutator;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.registry.key.Keyed;
|
||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||
@@ -32,13 +32,12 @@ public class MutatedStructure implements Structure, Keyed<MutatedStructure> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
return base.generate(location,
|
||||
world
|
||||
.buffer()
|
||||
.read(readInterceptor)
|
||||
.write(writeInterceptor)
|
||||
.build(),
|
||||
random, rotation);
|
||||
.build(), rotation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.sponge;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.registry.key.Keyed;
|
||||
@@ -31,7 +31,7 @@ public class SpongeStructure implements Structure, Keyed<SpongeStructure> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
int bX = location.getX();
|
||||
int bY = location.getY();
|
||||
int bZ = location.getZ();
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
version = version("1.1.0")
|
||||
|
||||
dependencies {
|
||||
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")
|
||||
relocate("net.jafama", "com.dfsek.terra.addons.terrascript.lib.jafama")
|
||||
api(libs.libraries.internal.apache.io)
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.Parser;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Executable;
|
||||
@@ -29,7 +29,6 @@ import com.dfsek.terra.addons.terrascript.script.builders.EntityFunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.GetMarkFunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.LootFunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.PullFunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.RandomFunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.RecursionsFunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.SetMarkFunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.builders.StateFunctionBuilder;
|
||||
@@ -77,7 +76,6 @@ public class StructureScript implements Structure, Keyed<StructureScript> {
|
||||
.registerFunction("block", new BlockFunctionBuilder(platform))
|
||||
.registerFunction("debugBlock", new BlockFunctionBuilder(platform))
|
||||
.registerFunction("structure", new StructureFunctionBuilder(registry, platform))
|
||||
.registerFunction("randomInt", new RandomFunctionBuilder())
|
||||
.registerFunction("recursions", new RecursionsFunctionBuilder())
|
||||
.registerFunction("setMark", new SetMarkFunctionBuilder())
|
||||
.registerFunction("getMark", new GetMarkFunctionBuilder())
|
||||
@@ -130,16 +128,16 @@ public class StructureScript implements Structure, Keyed<StructureScript> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation) {
|
||||
platform.getProfiler().push(profile);
|
||||
boolean result = applyBlock(new TerraImplementationArguments(location, rotation, random, world, 0));
|
||||
boolean result = applyBlock(new TerraImplementationArguments(location, rotation, world, 0));
|
||||
platform.getProfiler().pop(profile);
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation, int recursions) {
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, int recursions) {
|
||||
platform.getProfiler().push(profile);
|
||||
boolean result = applyBlock(new TerraImplementationArguments(location, rotation, random, world, recursions));
|
||||
boolean result = applyBlock(new TerraImplementationArguments(location, rotation, world, recursions));
|
||||
platform.getProfiler().pop(profile);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ package com.dfsek.terra.addons.terrascript.script;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
@@ -20,16 +20,14 @@ import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
public class TerraImplementationArguments implements ImplementationArguments {
|
||||
private final Rotation rotation;
|
||||
private final Random random;
|
||||
private final WritableWorld world;
|
||||
private final Map<Vector3, String> marks = new HashMap<>();
|
||||
private final int recursions;
|
||||
private final Vector3Int origin;
|
||||
private boolean waterlog = false;
|
||||
|
||||
public TerraImplementationArguments(Vector3Int origin, Rotation rotation, Random random, WritableWorld world, int recursions) {
|
||||
public TerraImplementationArguments(Vector3Int origin, Rotation rotation, WritableWorld world, int recursions) {
|
||||
this.rotation = rotation;
|
||||
this.random = random;
|
||||
this.world = world;
|
||||
this.recursions = recursions;
|
||||
this.origin = origin;
|
||||
@@ -39,10 +37,6 @@ public class TerraImplementationArguments implements ImplementationArguments {
|
||||
return recursions;
|
||||
}
|
||||
|
||||
public Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
|
||||
public Rotation getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
@@ -1,35 +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.terrascript.script.builders;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.script.functions.RandomFunction;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
|
||||
public class RandomFunctionBuilder implements FunctionBuilder<RandomFunction> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public RandomFunction build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new RandomFunction((Returnable<Number>) argumentList.get(0), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int argNumber() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
if(position == 0) return Returnable.ReturnType.NUMBER;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,6 @@ import net.jafama.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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;
|
||||
@@ -31,6 +29,9 @@ import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.random.RandomGeneratorFactory;
|
||||
|
||||
|
||||
public class LootFunction implements Function<Void> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LootFunction.class);
|
||||
@@ -84,8 +85,7 @@ public class LootFunction implements Function<Void> {
|
||||
platform.getEventManager().callEvent(event);
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
event.getTable().fillInventory(container.getInventory(),
|
||||
new Random(apply.hashCode()));
|
||||
event.getTable().fillInventory(container.getInventory());
|
||||
data.update(false);
|
||||
} catch(Exception e) {
|
||||
LOGGER.error("Could not apply loot at {}", apply, e);
|
||||
|
||||
@@ -1,43 +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.terrascript.script.functions;
|
||||
|
||||
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;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.functions.Function;
|
||||
import com.dfsek.terra.addons.terrascript.script.TerraImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
|
||||
|
||||
public class RandomFunction implements Function<Integer> {
|
||||
private final Returnable<Number> numberReturnable;
|
||||
private final Position position;
|
||||
|
||||
public RandomFunction(Returnable<Number> numberReturnable, Position position) {
|
||||
this.numberReturnable = numberReturnable;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return ReturnType.NUMBER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer apply(ImplementationArguments implementationArguments, Scope scope) {
|
||||
return ((TerraImplementationArguments) implementationArguments).getRandom().nextInt(
|
||||
numberReturnable.apply(implementationArguments, scope).intValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
@@ -67,31 +67,20 @@ public class StructureFunction implements Function<Boolean> {
|
||||
|
||||
String app = id.apply(implementationArguments, scope);
|
||||
return registry.getByID(app).map(script -> {
|
||||
Rotation rotation1;
|
||||
String rotString = rotations.get(arguments.getRandom().nextInt(rotations.size())).apply(implementationArguments, scope);
|
||||
try {
|
||||
rotation1 = Rotation.valueOf(rotString);
|
||||
} catch(IllegalArgumentException e) {
|
||||
LOGGER.warn("Invalid rotation {}", rotString);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(script instanceof StructureScript structureScript) {
|
||||
return structureScript.generate(arguments.getOrigin(),
|
||||
arguments.getWorld()
|
||||
.buffer(FastMath.roundToInt(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())),
|
||||
arguments.getRandom(),
|
||||
arguments.getRotation().rotate(rotation1), arguments.getRecursions() + 1);
|
||||
arguments.getRotation(), arguments.getRecursions() + 1);
|
||||
}
|
||||
return script.generate(arguments.getOrigin(),
|
||||
arguments.getWorld()
|
||||
.buffer(FastMath.roundToInt(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())),
|
||||
arguments.getRandom(),
|
||||
arguments.getRotation().rotate(rotation1));
|
||||
arguments.getRotation());
|
||||
}).orElseGet(() -> {
|
||||
LOGGER.error("No such structure {}", app);
|
||||
return false;
|
||||
|
||||
@@ -4,11 +4,4 @@ dependencies {
|
||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||
compileOnlyApi(project(":common:addons:chunk-generator-noise-3d"))
|
||||
compileOnlyApi(project(":common:addons:structure-terrascript-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.addon.terrascript.check.lib.jafama")
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
dependencies {
|
||||
api("ca.solo-studios", "strata", Versions.Libraries.strata)
|
||||
compileOnlyApi("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
|
||||
testImplementation("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
|
||||
api("cloud.commandframework", "cloud-core", Versions.Libraries.cloud)
|
||||
api(libs.libraries.strata)
|
||||
compileOnlyApi(libs.libraries.slf4j.api)
|
||||
testImplementation(libs.libraries.slf4j.api)
|
||||
api(libs.libraries.cloud.core)
|
||||
|
||||
api("com.dfsek.tectonic", "common", Versions.Libraries.tectonic)
|
||||
api(libs.libraries.tectonic)
|
||||
|
||||
api("com.github.ben-manes.caffeine", "caffeine", Versions.Libraries.caffeine)
|
||||
api(libs.libraries.caffeine)
|
||||
|
||||
api("io.vavr", "vavr", Versions.Libraries.vavr)
|
||||
api(libs.libraries.vavr)
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
api(libs.libraries.jafama)
|
||||
|
||||
api(libs.libraries.paralithic)
|
||||
}
|
||||
@@ -10,7 +10,7 @@ package com.dfsek.terra.api.structure;
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.inventory.Inventory;
|
||||
import com.dfsek.terra.api.inventory.ItemStack;
|
||||
@@ -22,16 +22,15 @@ public interface LootTable {
|
||||
* Fills an Inventory with loot.
|
||||
*
|
||||
* @param i The Inventory to fill.
|
||||
* @param r The The Random instance to use.
|
||||
*/
|
||||
void fillInventory(Inventory i, Random r);
|
||||
void fillInventory(Inventory i);
|
||||
|
||||
/**
|
||||
* Fetches a list of ItemStacks from the loot table using the given Random instance.
|
||||
* Fetches a list of ItemStacks from the loot table using the given RandomGenerator instance.
|
||||
*
|
||||
* @param r The Random instance to use.
|
||||
* @param r The RandomGenerator instance to use.
|
||||
*
|
||||
* @return List<ItemStack> - The list of loot fetched.
|
||||
*/
|
||||
List<ItemStack> getLoot(Random r);
|
||||
List<ItemStack> getLoot(RandomGenerator r);
|
||||
}
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
|
||||
package com.dfsek.terra.api.structure;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
public interface Structure {
|
||||
boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation);
|
||||
boolean generate(Vector3Int location, WritableWorld world, Rotation rotation);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
|
||||
public class ConstantRange implements Range {
|
||||
@@ -37,7 +37,7 @@ public class ConstantRange implements Range {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get(Random r) {
|
||||
public int get(RandomGenerator r) {
|
||||
return r.nextInt(min, max);
|
||||
}
|
||||
|
||||
|
||||
@@ -173,4 +173,21 @@ public final class MathUtil {
|
||||
|
||||
return mu + sigma * val;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1D Linear interpolation between 2 points 1 unit apart.
|
||||
*
|
||||
* @param t - Distance from v0. Total distance between v0 and v1 is 1 unit.
|
||||
* @param v0 - Value at v0.
|
||||
* @param v1 - Value at v1.
|
||||
*
|
||||
* @return double - The interpolated value.
|
||||
*/
|
||||
public static double lerp(double t, double v0, double v1) {
|
||||
return v0 + t * (v1 - v0);
|
||||
}
|
||||
|
||||
public static double inverseLerp(double t, double v0, double v1) {
|
||||
return (t - v0) / (v1 - v0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
|
||||
public final class PopulationUtil {
|
||||
public static Random getRandom(Chunk c) {
|
||||
return getRandom(c, 0);
|
||||
}
|
||||
|
||||
public static Random getRandom(Chunk c, long salt) {
|
||||
return new Random(getCarverChunkSeed(c.getX(), c.getZ(), c.getWorld().getSeed() + salt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the carver seed for a chunk.
|
||||
*
|
||||
* @param chunkX Chunk's X coordinate
|
||||
* @param chunkZ Chunk's Z coordinate
|
||||
* @param seed World seed
|
||||
*
|
||||
* @return long - The carver seed.
|
||||
*/
|
||||
public static long getCarverChunkSeed(int chunkX, int chunkZ, long seed) {
|
||||
Random r = new Random(seed);
|
||||
return chunkX * r.nextLong() ^ chunkZ * r.nextLong() ^ seed;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,8 @@ package com.dfsek.terra.api.util;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
|
||||
public interface Range extends Iterable<Integer> {
|
||||
@@ -19,7 +19,7 @@ public interface Range extends Iterable<Integer> {
|
||||
|
||||
Range reflect(int pt);
|
||||
|
||||
int get(Random r);
|
||||
int get(RandomGenerator r);
|
||||
|
||||
Range intersects(Range other);
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
@@ -43,7 +43,7 @@ public class ProbabilityCollection<E> implements Collection<E> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E get(Random r) {
|
||||
public E get(RandomGenerator r) {
|
||||
if(array.length == 0) return null;
|
||||
return (E) array[r.nextInt(array.length)];
|
||||
}
|
||||
@@ -195,7 +195,7 @@ public class ProbabilityCollection<E> implements Collection<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(Random r) {
|
||||
public T get(RandomGenerator r) {
|
||||
return single;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ dependencies {
|
||||
api(project(":common:api"))
|
||||
api(project(":common:implementation:bootstrap-addon-loader"))
|
||||
|
||||
testImplementation("org.slf4j", "slf4j-api", Versions.Libraries.slf4j)
|
||||
testImplementation(libs.libraries.slf4j.api)
|
||||
|
||||
implementation("commons-io", "commons-io", Versions.Libraries.Internal.apacheIO)
|
||||
implementation(libs.libraries.internal.apache.io)
|
||||
|
||||
implementation("org.apache.commons", "commons-text", Versions.Libraries.Internal.apacheText)
|
||||
implementation("com.dfsek.tectonic", "yaml", Versions.Libraries.tectonic)
|
||||
implementation(libs.libraries.internal.apache.text)
|
||||
implementation(libs.libraries.tectonic.yaml)
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
implementation(libs.libraries.jafama)
|
||||
|
||||
implementation("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||
implementation(libs.libraries.paralithic)
|
||||
}
|
||||
|
||||
98
gradle/libs.versions.toml
Normal file
98
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,98 @@
|
||||
[versions]
|
||||
libraries_tectonic = "4.2.0"
|
||||
libraries_paralithic = "0.7.0"
|
||||
libraries_strata = "1.3.1"
|
||||
libraries_snakeyaml = "1.30"
|
||||
libraries_cloud = "1.7.0"
|
||||
libraries_slf4j = "1.7.36"
|
||||
libraries_caffeine = "3.1.1"
|
||||
libraries_vavr = "0.10.4"
|
||||
libraries_jafama = "2.3.2"
|
||||
libraries_guava = "31.1-jre"
|
||||
|
||||
libraries_internal_apache-text = "1.9"
|
||||
libraries_internal_apache-io = "2.11.0"
|
||||
libraries_internal_fastutil = "8.5.8"
|
||||
libraries_internal_shadow = "7.1.2"
|
||||
libraries_internal_junit-jupiter = "5.9.0"
|
||||
libraries_internal_jetbrains-annotations = "23.0.0"
|
||||
libraries_internal_asm = "9.3"
|
||||
|
||||
mod_mixin = "0.11.4+mixin.0.8.5"
|
||||
mod_minecraft = "1.19.2"
|
||||
mod_yarn = "1.19.2+build.4"
|
||||
mod_architecury-loom = "0.12.0.299"
|
||||
mod_architectury-plugin = "3.4.138"
|
||||
mod_loom-quiltflower = "1.7.3"
|
||||
mod_lazy-dfu = "0.1.3"
|
||||
|
||||
mod_fabric_fabric-loader = "0.14.9"
|
||||
mod_fabric_fabric-api = "0.60.0+1.19.2"
|
||||
|
||||
mod_quilt_quilt-loader = "0.17.3"
|
||||
mod_quilt_fabric-api = "4.0.0-beta.9+0.60.0-1.19.2"
|
||||
|
||||
mod_forge_forge = "1.19.2-43.1.1"
|
||||
mod_forge_burningwave = "12.59.0"
|
||||
|
||||
bukkit_run-paper = "1.0.6"
|
||||
bukkit_paperweight = "1.3.8"
|
||||
bukkit_paper = "1.19-R0.1-20220725.172700-79"
|
||||
bukkit_paper-lib = "1.0.7"
|
||||
bukkit_minecraft = "1.19.2"
|
||||
bukkit_reflection-remapper = "0.1.0-20220312.202611-7"
|
||||
|
||||
cli_nbt = "6.1"
|
||||
cli_logback = "1.2.11"
|
||||
|
||||
[libraries]
|
||||
libraries_tectonic = { module = "com.dfsek.tectonic:common", version.ref = "libraries_tectonic" }
|
||||
libraries_tectonic_yaml = { module = "com.dfsek.tectonic:yaml", version.ref = "libraries_tectonic" }
|
||||
libraries_paralithic = { module = "com.dfsek:paralithic", version.ref = "libraries_paralithic" }
|
||||
libraries_strata = { module = "ca.solo-studios:strata", version.ref = "libraries_strata" }
|
||||
libraries_snakeyaml = { module = "org.yaml:snakeyaml", version.ref = "libraries_snakeyaml" }
|
||||
libraries_cloud-core = { module = "cloud.commandframework:cloud-core", version.ref = "libraries_cloud" }
|
||||
libraries_slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "libraries_slf4j" }
|
||||
libraries_caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "libraries_caffeine" }
|
||||
libraries_vavr = { module = "io.vavr:vavr", version.ref = "libraries_vavr" }
|
||||
libraries_guava = { module = "com.google.guava:guava", version.ref = "libraries_guava" }
|
||||
libraries_jafama = { module = "net.jafama:jafama", version.ref = "libraries_jafama" }
|
||||
|
||||
libraries_internal_apache-text = { module = "org.apache.commons:commons-text", version.ref = "libraries_internal_apache-text" }
|
||||
libraries_internal_apache-io = { module = "commons-io:commons-io", version.ref = "libraries_internal_apache-io" }
|
||||
libraries_internal_fastutil = { module = "it.unimi.dsi:fastutil ", version.ref = "libraries_internal_fastutil" }
|
||||
libraries_internal_shadow = { module = "gradle.plugin.com.github.johnrengelman:shadow", version.ref = "libraries_internal_shadow" }
|
||||
libraries_internal_junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "libraries_internal_junit_jupiter" }
|
||||
libraries_internal_junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "libraries_internal_junit_jupiter" }
|
||||
libraries_internal_jetbrains-annotations = { module = "org.jetbrains:annotations", version.ref = "libraries_internal_jetbrains_annotations" }
|
||||
libraries_internal_asm = { module = "org.ow2.asm:asm", version.ref = "libraries_internal_asm" }
|
||||
libraries_internal_asm-tree = { module = "org.ow2.asm:asm-tree", version.ref = "libraries_internal_asm" }
|
||||
|
||||
mod_mixin = { module = "net.fabricmc:sponge-mixin", version.ref = "mod_mixin" }
|
||||
mod_minecraft = { module = "com.mojang:minecraft", version.ref = "mod_minecraft" }
|
||||
mod_lazy-dfu = { module = "maven.modrinth:lazydfu", version.ref = "mod_lazy-dfu" }
|
||||
mod_cloud-fabric = { module = "cloud.commandframework:cloud-fabric", version.ref = "libraries_cloud" }
|
||||
|
||||
mod_fabric_fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "mod_fabric_fabric-loader" }
|
||||
|
||||
mod_quilt_quilt-loader = { module = "org.quiltmc:quilt-loader", version.ref = "mod_quilt_quilt-loader" }
|
||||
mod_quilt_fabric-api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "mod_quilt_fabric-api" }
|
||||
|
||||
mod_forge_forge = { module = "net.minecraftforge:forge", version.ref = "mod_forge_forge" }
|
||||
mod_forge_burningwave = { module = "org.burningwave:core", version.ref = "mod_forge_burningwave" }
|
||||
|
||||
bukkit_paper-api = { module = "io.papermc.paper:paper-api", version.ref = "bukkit_paper" }
|
||||
bukkit_paper-lib = { module = "io.papermc:paperlib", version.ref = "bukkit_paper-lib" }
|
||||
bukkit_reflection-remapper = { module = "xyz.jpenilla:reflection-remapper", version.ref = "bukkit_reflection-remapper" }
|
||||
bukkit_cloud-paper = { module = "cloud.commandframework:cloud-paper", version.ref = "libraries_cloud" }
|
||||
|
||||
cli_nbt = { module = "com.github.Querz:NBT", version.ref = "cli_nbt" }
|
||||
cli_logback = { module = "ch.qos.logback:logback-classic", version.ref = "cli_logback" }
|
||||
|
||||
[plugins]
|
||||
mod_architectury-loom = { id = "dev.architectury.loom", version.ref = "mod_architecury-loom" }
|
||||
mod_architectury-plugin = { id = "architectury-plugin", version.ref = "mod_architectury-plugin" }
|
||||
mod_loom-quiltflower = { id = "io.github.juuxel.loom-quiltflower", version.ref = "mod_loom-quiltflower" }
|
||||
|
||||
bukkit_run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "bukkit_run-paper" }
|
||||
bukkit_paperweight = { id = "io.papermc.paperweight.userdev", version.ref = "bukkit_paperweight" }
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
org.gradle.jvmargs=-Xmx4096m
|
||||
269
gradlew
vendored
269
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,67 +17,101 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
@@ -106,80 +140,95 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("xyz.jpenilla.run-paper") version "1.0.6"
|
||||
alias(libs.plugins.bukkit.run.paper)
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -9,15 +9,12 @@ repositories {
|
||||
dependencies {
|
||||
shaded(project(":platforms:bukkit:common"))
|
||||
shaded(project(":platforms:bukkit:nms:v1_19_R1", configuration = "reobf"))
|
||||
shaded("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||
shaded(libs.bukkit.reflection.remapper)
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats")
|
||||
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
|
||||
relocate("com.google.common", "com.dfsek.terra.lib.google.common")
|
||||
relocate("org.apache.logging.slf4j", "com.dfsek.terra.lib.slf4j-over-log4j")
|
||||
exclude("org/slf4j/**")
|
||||
exclude("org/checkerframework/**")
|
||||
exclude("org/jetbrains/annotations/**")
|
||||
@@ -28,7 +25,7 @@ tasks {
|
||||
}
|
||||
|
||||
runServer {
|
||||
minecraftVersion("1.19")
|
||||
minecraftVersion(libs.versions.bukkit.minecraft.get())
|
||||
dependsOn(shadowJar)
|
||||
pluginJars(shadowJar.get().archiveFile)
|
||||
}
|
||||
|
||||
@@ -5,14 +5,9 @@ repositories {
|
||||
dependencies {
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
api("org.slf4j:slf4j-api:1.8.0-beta4") {
|
||||
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
|
||||
}
|
||||
compileOnly(libs.bukkit.paper.api)
|
||||
|
||||
compileOnly("io.papermc.paper:paper-api:${Versions.Bukkit.paper}")
|
||||
shadedApi(libs.bukkit.paper.lib)
|
||||
|
||||
shadedApi("io.papermc", "paperlib", Versions.Bukkit.paperLib)
|
||||
shadedApi("com.google.guava:guava:30.0-jre")
|
||||
|
||||
shadedApi("cloud.commandframework", "cloud-paper", Versions.Libraries.cloud)
|
||||
shadedApi(libs.bukkit.cloud.paper)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
@@ -63,7 +63,7 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkData chunkData) {
|
||||
public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull RandomGenerator random, int x, int z, @NotNull ChunkData chunkData) {
|
||||
BukkitWorldProperties properties = new BukkitWorldProperties(worldInfo);
|
||||
delegate.generateChunkData(new BukkitProtoChunk(chunkData), properties, pack.getBiomeProvider(), x, z);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
||||
.stream()
|
||||
.map(generationStage -> new BlockPopulator() {
|
||||
@Override
|
||||
public void populate(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z,
|
||||
public void populate(@NotNull WorldInfo worldInfo, @NotNull RandomGenerator random, int x, int z,
|
||||
@NotNull LimitedRegion limitedRegion) {
|
||||
generationStage.populate(new BukkitProtoWorld(limitedRegion, air, pack.getBiomeProvider()));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
apply(plugin = "io.papermc.paperweight.userdev")
|
||||
plugins {
|
||||
alias(libs.plugins.bukkit.paperweight)
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.dfsek.terra.bukkit.nms.v1_19_R1.config;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -14,7 +17,7 @@ import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
|
||||
@Value("strucutres")
|
||||
@Default
|
||||
private ProbabilityCollection<ConfiguredStructure> structures = null;
|
||||
private ProbabilityCollection<Structure> structures = null;
|
||||
|
||||
@Value("cooldowns")
|
||||
@Default
|
||||
@@ -28,7 +31,7 @@ public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
|
||||
@Default
|
||||
private Boolean villagerFertilizable = null;
|
||||
|
||||
public ProbabilityCollection<ConfiguredStructure> getStructures() {
|
||||
public ProbabilityCollection<Structure> getStructures() {
|
||||
return structures;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,10 @@ val javaMainClass = "com.dfsek.terra.cli.TerraCLI"
|
||||
dependencies {
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
shadedApi("commons-io:commons-io:${Versions.CLI.commonsIO}")
|
||||
shadedApi("com.github.Querz:NBT:${Versions.CLI.nbt}")
|
||||
shadedApi(libs.libraries.internal.apache.io)
|
||||
shadedApi(libs.cli.nbt)
|
||||
|
||||
shadedImplementation("com.google.guava:guava:${Versions.CLI.guava}")
|
||||
|
||||
shadedImplementation("ch.qos.logback:logback-classic:${Versions.CLI.logback}")
|
||||
|
||||
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||
shadedImplementation(libs.cli.logback)
|
||||
}
|
||||
|
||||
tasks.withType<Jar> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
||||
alias(libs.plugins.mod.architectury.loom)
|
||||
alias(libs.plugins.mod.architectury.plugin)
|
||||
alias(libs.plugins.mod.loom.quiltflower)
|
||||
}
|
||||
|
||||
architectury {
|
||||
@@ -12,9 +12,6 @@ architectury {
|
||||
dependencies {
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
||||
|
||||
implementation(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
||||
"developmentFabric"(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
||||
shaded(project(path = ":platforms:mixin-common", configuration = "transformProductionFabric")) { isTransitive = false }
|
||||
@@ -22,28 +19,15 @@ dependencies {
|
||||
"developmentFabric"(project(path = ":platforms:mixin-lifecycle", configuration = "namedElements")) { isTransitive = false }
|
||||
shaded(project(path = ":platforms:mixin-lifecycle", configuration = "transformProductionFabric")) { isTransitive = false }
|
||||
|
||||
minecraft(libs.mod.minecraft)
|
||||
mappings("net.fabricmc", "yarn", libs.versions.mod.yarn.get(), classifier = "v2")
|
||||
|
||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||
modImplementation(libs.mod.fabric.fabric.loader)
|
||||
|
||||
modImplementation("net.fabricmc:fabric-loader:${Versions.Fabric.fabricLoader}")
|
||||
modImplementation(libs.mod.cloud.fabric)
|
||||
include(libs.mod.cloud.fabric)
|
||||
|
||||
setOf(
|
||||
"fabric-lifecycle-events-v1",
|
||||
"fabric-resource-loader-v0",
|
||||
"fabric-api-base",
|
||||
"fabric-command-api-v2",
|
||||
"fabric-networking-api-v1"
|
||||
).forEach { apiModule ->
|
||||
val module = fabricApi.module(apiModule, Versions.Fabric.fabricAPI)
|
||||
modImplementation(module)
|
||||
include(module)
|
||||
}
|
||||
|
||||
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
|
||||
include("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud)
|
||||
|
||||
modLocalRuntime("com.github.astei:lazydfu:${Versions.Mod.lazyDfu}")
|
||||
modLocalRuntime(libs.mod.lazy.dfu)
|
||||
}
|
||||
|
||||
loom {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
||||
alias(libs.plugins.mod.architectury.loom)
|
||||
alias(libs.plugins.mod.architectury.plugin)
|
||||
alias(libs.plugins.mod.loom.quiltflower)
|
||||
}
|
||||
|
||||
architectury {
|
||||
@@ -10,9 +10,6 @@ architectury {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
||||
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
"forgeRuntimeLibrary"(project(":common:implementation:base"))
|
||||
|
||||
@@ -20,14 +17,14 @@ dependencies {
|
||||
"developmentForge"(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
||||
shaded(project(path = ":platforms:mixin-common", configuration = "transformProductionForge")) { isTransitive = false }
|
||||
|
||||
forge(group = "net.minecraftforge", name = "forge", version = Versions.Forge.forge)
|
||||
forge(libs.mod.forge.forge)
|
||||
|
||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||
minecraft(libs.mod.minecraft)
|
||||
mappings("net.fabricmc", "yarn", libs.versions.mod.yarn.get(), classifier = "v2")
|
||||
|
||||
//forge is not ok.
|
||||
compileOnly("org.burningwave:core:${Versions.Forge.burningwave}")
|
||||
"forgeRuntimeLibrary"("org.burningwave:core:${Versions.Forge.burningwave}")
|
||||
compileOnly(libs.mod.forge.burningwave)
|
||||
"forgeRuntimeLibrary"(libs.mod.forge.burningwave)
|
||||
}
|
||||
|
||||
loom {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
||||
alias(libs.plugins.mod.architectury.loom)
|
||||
alias(libs.plugins.mod.architectury.plugin)
|
||||
alias(libs.plugins.mod.loom.quiltflower)
|
||||
}
|
||||
|
||||
loom {
|
||||
@@ -15,16 +15,14 @@ loom {
|
||||
dependencies {
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
||||
modImplementation(libs.mod.fabric.fabric.loader)
|
||||
|
||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||
minecraft(libs.mod.minecraft)
|
||||
mappings("net.fabricmc", "yarn", libs.versions.mod.yarn.get(), classifier = "v2")
|
||||
}
|
||||
|
||||
architectury {
|
||||
common("fabric", "forge", "quilt")
|
||||
minecraft = Versions.Mod.minecraft
|
||||
minecraft = libs.versions.mod.minecraft.get()
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ package com.dfsek.terra.mod;
|
||||
|
||||
import ca.solostudios.strata.Versions;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
import com.dfsek.terra.mod.config.VanillaWorldProperties;
|
||||
|
||||
import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -44,6 +51,15 @@ public abstract class MinecraftAddon implements BaseAddon {
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
modPlatform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
if(event.is(ConfigPack.class)) {
|
||||
event.getLoadedObject(ConfigPack.class).getContext().put(event.load(new VanillaWorldProperties()));
|
||||
}
|
||||
})
|
||||
.global();
|
||||
modPlatform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
|
||||
@@ -77,14 +77,11 @@ public abstract class ModPlatform extends AbstractPlatform {
|
||||
throw new LoadException("Invalid identifier: " + o, depthTracker);
|
||||
return identifier;
|
||||
})
|
||||
.registerLoader(Precipitation.class, (type, o, loader, depthTracker) -> Precipitation.valueOf(((String) o).toUpperCase(
|
||||
Locale.ROOT)))
|
||||
.registerLoader(Precipitation.class, (type, o, loader, depthTracker) -> Precipitation.valueOf(((String) o).toUpperCase()))
|
||||
.registerLoader(GrassColorModifier.class,
|
||||
(type, o, loader, depthTracker) -> GrassColorModifier.valueOf(((String) o).toUpperCase(
|
||||
Locale.ROOT)))
|
||||
.registerLoader(GrassColorModifier.class,
|
||||
(type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase(
|
||||
Locale.ROOT)))
|
||||
(type, o, loader, depthTracker) -> GrassColorModifier.valueOf(((String) o).toUpperCase()))
|
||||
.registerLoader(TemperatureModifier.class,
|
||||
(type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase()))
|
||||
.registerLoader(SpawnGroup.class, (type, o, loader, depthTracker) -> SpawnGroup.valueOf((String) o))
|
||||
.registerLoader(BiomeParticleConfig.class, BiomeParticleConfigTemplate::new)
|
||||
.registerLoader(SoundEvent.class, SoundEventTemplate::new)
|
||||
|
||||
@@ -7,14 +7,14 @@ import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
|
||||
public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
|
||||
@Value("strucutres")
|
||||
@Default
|
||||
private ProbabilityCollection<ConfiguredStructure> structures = null;
|
||||
private ProbabilityCollection<Structure> structures = null;
|
||||
|
||||
@Value("cooldowns")
|
||||
@Default
|
||||
@@ -22,13 +22,13 @@ public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
|
||||
|
||||
@Value("can-grow")
|
||||
@Default
|
||||
private ConfiguredStructure canGrow = null;
|
||||
private Structure canGrow = null;
|
||||
|
||||
@Value("villager-fertilizable")
|
||||
@Value("villager-farmable")
|
||||
@Default
|
||||
private Boolean villagerFertilizable = null;
|
||||
private Boolean villagerFarmable = null;
|
||||
|
||||
public ProbabilityCollection<ConfiguredStructure> getStructures() {
|
||||
public ProbabilityCollection<Structure> getStructures() {
|
||||
return structures;
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
|
||||
return cooldowns;
|
||||
}
|
||||
|
||||
public ConfiguredStructure getCanGrow() {
|
||||
public Structure getCanGrow() {
|
||||
return canGrow;
|
||||
}
|
||||
|
||||
public Boolean isVillagerFertilizable() {
|
||||
return villagerFertilizable;
|
||||
public Boolean isVillagerFarmable() {
|
||||
return villagerFarmable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.dfsek.terra.mod.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.api.util.ConstantRange;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
import com.dfsek.terra.mod.implmentation.TerraIntProvider;
|
||||
|
||||
import net.minecraft.world.dimension.DimensionType.MonsterSettings;
|
||||
|
||||
|
||||
public class MonsterSettingsTemplate implements ObjectTemplate<MonsterSettings> {
|
||||
@Value("piglin-safe")
|
||||
@Default
|
||||
private Boolean piglinSafe = false;
|
||||
|
||||
@Value("has-raids")
|
||||
@Default
|
||||
private Boolean hasRaids = false;
|
||||
|
||||
@Value("monster-spawn-light")
|
||||
@Default
|
||||
private Range monsterSpawnLight = new ConstantRange(0, 1);
|
||||
|
||||
@Value("monster-spawn-block-light-limit")
|
||||
@Default
|
||||
private int monsterSpawnBlockLightLimit = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public MonsterSettings get() {
|
||||
return new MonsterSettings(piglinSafe, hasRaids, new TerraIntProvider(monsterSpawnLight), monsterSpawnBlockLightLimit);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.dfsek.terra.mod.config;
|
||||
|
||||
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.Value;
|
||||
|
||||
import com.dfsek.terra.mod.implmentation.TerraIntProvider;
|
||||
|
||||
import net.minecraft.client.gl.Uniform;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.intprovider.IntProvider;
|
||||
import net.minecraft.util.math.intprovider.IntProviderType;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.world.dimension.DimensionType.MonsterSettings;
|
||||
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
import com.dfsek.terra.api.util.ConstantRange;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
|
||||
public class VanillaWorldProperties implements ConfigTemplate, Properties {
|
||||
@Value("minecraft.fixed-time")
|
||||
@Default
|
||||
private Long fixedTime = null;
|
||||
|
||||
@Value("minecraft.has-sky-light")
|
||||
@Default
|
||||
private Boolean hasSkyLight = false;
|
||||
|
||||
@Value("minecraft.has-ceiling")
|
||||
@Default
|
||||
private Boolean hasCeiling = false;
|
||||
|
||||
@Value("minecraft.ultra-warm")
|
||||
@Default
|
||||
private Boolean ultraWarm = false;
|
||||
|
||||
@Value("minecraft.natural")
|
||||
@Default
|
||||
private Boolean natural = false;
|
||||
|
||||
@Value("minecraft.coordinate-scale")
|
||||
@Default
|
||||
private Double coordinateScale = 1.0E-5d;
|
||||
|
||||
@Value("minecraft.bed-works")
|
||||
@Default
|
||||
private Boolean bedWorks = false;
|
||||
|
||||
@Value("minecraft.respawn-anchor-works")
|
||||
@Default
|
||||
private Boolean respawnAnchorWorks = false;
|
||||
|
||||
@Value("minecraft.height")
|
||||
@Default
|
||||
private Range height = new ConstantRange(0, 16);
|
||||
|
||||
@Value("minecraft.height.logical")
|
||||
@Default
|
||||
private Integer logicalHeight = 0;
|
||||
|
||||
@Value("minecraft.infiniburn")
|
||||
@Default
|
||||
private Identifier infiniburn = new Identifier("");
|
||||
|
||||
@Value("minecraft.effects")
|
||||
@Default
|
||||
private Identifier effects = new Identifier("");
|
||||
|
||||
@Value("minecraft.ambient-light")
|
||||
@Default
|
||||
private Float ambientLight = Float.MAX_VALUE;
|
||||
|
||||
@Value("minecraft.monster-settings")
|
||||
@Default
|
||||
private MonsterSettings monsterSettings = new MonsterSettings(false, false, new TerraIntProvider(new ConstantRange(0, 1)), 0);
|
||||
|
||||
@Value("minecraft.sealevel")
|
||||
@Default
|
||||
private Integer sealevel = 0;
|
||||
|
||||
public Long getFixedTime() {
|
||||
return fixedTime;
|
||||
}
|
||||
|
||||
public Boolean getHasSkyLight() {
|
||||
return hasSkyLight;
|
||||
}
|
||||
|
||||
public Boolean getHasCeiling() {
|
||||
return hasCeiling;
|
||||
}
|
||||
|
||||
public Boolean getUltraWarm() {
|
||||
return ultraWarm;
|
||||
}
|
||||
|
||||
public Boolean getNatural() {
|
||||
return natural;
|
||||
}
|
||||
|
||||
public Double getCoordinateScale() {
|
||||
return coordinateScale;
|
||||
}
|
||||
|
||||
public Boolean getBedWorks() {
|
||||
return bedWorks;
|
||||
}
|
||||
|
||||
public Boolean getRespawnAnchorWorks() {
|
||||
return respawnAnchorWorks;
|
||||
}
|
||||
|
||||
public Range getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public Integer getLogicalHeight() {
|
||||
return logicalHeight;
|
||||
}
|
||||
|
||||
public Identifier getInfiniburn() {
|
||||
return infiniburn;
|
||||
}
|
||||
|
||||
public Identifier getEffects() {
|
||||
return effects;
|
||||
}
|
||||
|
||||
public Float getAmbientLight() {
|
||||
return ambientLight;
|
||||
}
|
||||
|
||||
public MonsterSettings getMonsterSettings() {
|
||||
return monsterSettings;
|
||||
}
|
||||
|
||||
public Integer getSealevel() {
|
||||
return sealevel;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.dfsek.terra.mod.data;
|
||||
|
||||
import com.dfsek.terra.api.util.ConstantRange;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
import com.dfsek.terra.mod.implmentation.TerraIntProvider;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.util.dynamic.RegistryOps;
|
||||
@@ -62,4 +67,9 @@ public final class Codecs {
|
||||
.forGetter(MinecraftChunkGeneratorWrapper::getSettings)
|
||||
).apply(instance, instance.stable(MinecraftChunkGeneratorWrapper::new))
|
||||
);
|
||||
|
||||
public static final Codec<TerraIntProvider> TERRA_CONSTANT_RANGE_INT_PROVIDER_TYPE = RecordCodecBuilder.create(range -> range.group(
|
||||
Codec.INT.fieldOf("min").stable().forGetter(TerraIntProvider::getMin),
|
||||
Codec.INT.fieldOf("max").stable().forGetter(TerraIntProvider::getMax)).apply(range, range.stable((min, max) -> new TerraIntProvider(new ConstantRange(
|
||||
min, max)))));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
package com.dfsek.terra.mod.generation;
|
||||
|
||||
import com.dfsek.terra.mod.config.VanillaBiomeProperties;
|
||||
import com.dfsek.terra.mod.config.VanillaWorldProperties;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
@@ -76,6 +79,8 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
private ChunkGenerator delegate;
|
||||
private ConfigPack pack;
|
||||
|
||||
private VanillaWorldProperties vanillaWorldProperties;
|
||||
|
||||
public MinecraftChunkGeneratorWrapper(Registry<StructureSet> noiseRegistry, TerraBiomeSource biomeSource, ConfigPack configPack,
|
||||
RegistryEntry<ChunkGeneratorSettings> settingsSupplier) {
|
||||
super(noiseRegistry, Optional.empty(), biomeSource);
|
||||
@@ -86,6 +91,11 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
this.delegate = pack.getGeneratorProvider().newInstance(pack);
|
||||
logger.info("Loading world with config pack {}", pack.getID());
|
||||
this.biomeSource = biomeSource;
|
||||
if (pack.getContext().has(VanillaBiomeProperties.class)) {
|
||||
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
|
||||
} else {
|
||||
vanillaWorldProperties = new VanillaWorldProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public Registry<StructureSet> getNoiseRegistry() {
|
||||
@@ -115,7 +125,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
|
||||
@Override
|
||||
public int getWorldHeight() {
|
||||
return settings.value().generationShapeConfig().height();
|
||||
return vanillaWorldProperties.getHeight().getMax();
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +147,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
|
||||
private void beard(StructureAccessor structureAccessor, Chunk chunk, WorldProperties world, BiomeProvider biomeProvider,
|
||||
PreLoadCompatibilityOptions compatibilityOptions) {
|
||||
StructureWeightSampler structureWeightSampler = StructureWeightSampler.method_42695(structureAccessor, chunk.getPos());
|
||||
StructureWeightSampler structureWeightSampler = StructureWeightSampler.createStructureWeightSampler(structureAccessor, chunk.getPos());
|
||||
double threshold = compatibilityOptions.getBeardThreshold();
|
||||
double airThreshold = compatibilityOptions.getAirThreshold();
|
||||
int xi = chunk.getPos().x << 4;
|
||||
@@ -174,12 +184,12 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
|
||||
@Override
|
||||
public int getSeaLevel() {
|
||||
return settings.value().seaLevel();
|
||||
return vanillaWorldProperties.getSealevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumY() {
|
||||
return settings.value().generationShapeConfig().minimumY();
|
||||
return vanillaWorldProperties.getHeight().getMin();
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +219,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
|
||||
@Override
|
||||
public void getDebugHudText(List<String> text, NoiseConfig noiseConfig, BlockPos pos) {
|
||||
|
||||
// no op
|
||||
}
|
||||
|
||||
public ConfigPack getPack() {
|
||||
@@ -220,6 +230,12 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
|
||||
this.pack = pack;
|
||||
this.delegate = pack.getGeneratorProvider().newInstance(pack);
|
||||
biomeSource.setPack(pack);
|
||||
|
||||
if (pack.getContext().has(VanillaBiomeProperties.class)) {
|
||||
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
|
||||
} else {
|
||||
vanillaWorldProperties = new VanillaWorldProperties();
|
||||
}
|
||||
|
||||
logger.debug("Loading world with config pack {}", pack.getID());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.dfsek.terra.mod.implmentation;
|
||||
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
|
||||
import com.dfsek.terra.mod.util.MinecraftAdapter;
|
||||
|
||||
import net.minecraft.util.math.intprovider.IntProvider;
|
||||
import net.minecraft.util.math.intprovider.IntProviderType;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class TerraIntProvider extends IntProvider {
|
||||
public static final Map<Class, IntProviderType> TERRA_RANGE_TYPE_TO_INT_PROVIDER_TYPE = new HashMap<>();
|
||||
|
||||
public Range delegate;
|
||||
|
||||
public TerraIntProvider(Range delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get(Random random) {
|
||||
return delegate.get(MinecraftAdapter.adapt(random));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMin() {
|
||||
return delegate.getMin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMax() {
|
||||
return delegate.getMax();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntProviderType<?> getType() {
|
||||
return TERRA_RANGE_TYPE_TO_INT_PROVIDER_TYPE.get(delegate.getClass());
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.dfsek.terra.mod.mixin.access;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
|
||||
@Mixin(Biome.class)
|
||||
public interface BiomeAccessor {
|
||||
@Accessor("weather")
|
||||
Biome.Weather getWeather();
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.mod.mixin.gameplay;
|
||||
|
||||
|
||||
import com.dfsek.terra.mod.util.MinecraftAdapter;
|
||||
|
||||
import net.minecraft.item.BoneMealItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -14,6 +16,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.dfsek.terra.mod.util.FertilizableUtil;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
|
||||
@Mixin(BoneMealItem.class)
|
||||
public class BoneMealItemMixin {
|
||||
@@ -22,7 +26,7 @@ public class BoneMealItemMixin {
|
||||
@Inject(method = "useOnFertilizable", at = @At("HEAD"), cancellable = true)
|
||||
private static void injectUseOnFertilizable(ItemStack stack, World world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
if(world instanceof ServerWorld) {
|
||||
Boolean value = FertilizableUtil.grow((ServerWorld) world, pos, world.getBlockState(pos), cooldownId);
|
||||
Boolean value = FertilizableUtil.grow((ServerWorld) world, MinecraftAdapter.adapt(world.getRandom()), pos, world.getBlockState(pos), cooldownId);
|
||||
stack.decrement(1);
|
||||
if(value != null) {
|
||||
cir.setReturnValue(value);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.dfsek.terra.mod.mixin.gameplay;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import com.dfsek.terra.mod.util.WritableWorldSeedRedirecter;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.ai.brain.task.BoneMealTask;
|
||||
@@ -14,14 +18,15 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.mod.config.FertilizableConfig;
|
||||
import com.dfsek.terra.mod.util.BiomeUtil;
|
||||
import com.dfsek.terra.mod.util.MinecraftAdapter;
|
||||
|
||||
|
||||
@Mixin(BoneMealTask.class)
|
||||
@@ -35,21 +40,20 @@ public class BoneMealTaskMixin {
|
||||
Block block = blockState.getBlock();
|
||||
FertilizableConfig config = map.get(Registry.BLOCK.getId(block));
|
||||
if(config != null) {
|
||||
Boolean villagerFertilizable = config.isVillagerFertilizable();
|
||||
if(villagerFertilizable != null) {
|
||||
if(villagerFertilizable) {
|
||||
ConfiguredStructure canGrow = config.getCanGrow();
|
||||
Boolean villagerFarmable = config.isVillagerFarmable();
|
||||
if(villagerFarmable != null) {
|
||||
if(villagerFarmable) {
|
||||
Structure canGrow = config.getCanGrow();
|
||||
if(canGrow != null) {
|
||||
Random random = (Random) world.getRandom();
|
||||
cir.setReturnValue(canGrow.getStructure().get(random).generate(
|
||||
Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), (WritableWorld) world, random, Rotation.NONE));
|
||||
RandomGenerator random = MinecraftAdapter.adapt(world.getRandom());
|
||||
cir.setReturnValue(canGrow.generate(
|
||||
Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), new WritableWorldSeedRedirecter((WritableWorld) world, world.getSeed() + random.nextLong(Long.MAX_VALUE)), Rotation.NONE));
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(true);
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.mod.mixin.gameplay;
|
||||
|
||||
|
||||
import com.dfsek.terra.mod.util.MinecraftAdapter;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -12,6 +14,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import com.dfsek.terra.mod.util.FertilizableUtil;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
|
||||
@Mixin(ServerWorld.class)
|
||||
public class ServerWorldMixin {
|
||||
@@ -22,7 +26,7 @@ public class ServerWorldMixin {
|
||||
target = "Lnet/minecraft/block/BlockState;randomTick(Lnet/minecraft/server/world/ServerWorld;" +
|
||||
"Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/random/Random;)V"))
|
||||
public void injectTickChunk(BlockState instance, ServerWorld serverWorld, BlockPos blockPos, Random random) {
|
||||
Boolean value = FertilizableUtil.grow(serverWorld, blockPos, instance, cooldownId);
|
||||
Boolean value = FertilizableUtil.grow(serverWorld, MinecraftAdapter.adapt(random), blockPos, instance, cooldownId);
|
||||
if(value != null) {
|
||||
if(!value) {
|
||||
instance.randomTick(serverWorld, blockPos, random);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.mod.mixin.lifecycle;
|
||||
|
||||
import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
|
||||
import net.minecraft.server.DataPackContents;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
@@ -62,7 +62,13 @@ public class BiomeUtil {
|
||||
*/
|
||||
protected static void registerBiome(Biome biome, ConfigPack pack,
|
||||
com.dfsek.terra.api.registry.key.RegistryKey id) {
|
||||
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
VanillaBiomeProperties vanillaBiomeProperties;
|
||||
if (biome.getContext().has(VanillaBiomeProperties.class)) {
|
||||
vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
} else {
|
||||
vanillaBiomeProperties = new VanillaBiomeProperties();
|
||||
}
|
||||
|
||||
|
||||
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(vanillaBiomeProperties);
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.dfsek.terra.mod.util;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.mod.config.VanillaBiomeProperties;
|
||||
import com.dfsek.terra.mod.config.VanillaWorldProperties;
|
||||
|
||||
import net.minecraft.tag.TagKey;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.dimension.DimensionOptions;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.OptionalLong;
|
||||
|
||||
|
||||
public class DimensionUtil {
|
||||
protected static RegistryKey<DimensionType> registerDimension(Identifier identifier,
|
||||
DimensionType dimension) {
|
||||
BuiltinRegistries.add(BuiltinRegistries.DIMENSION_TYPE,
|
||||
registerKey(identifier)
|
||||
.getValue(),
|
||||
dimension);
|
||||
return getDimensionKey(identifier);
|
||||
}
|
||||
|
||||
public static RegistryKey<DimensionOptions> registerKey(Identifier identifier) {
|
||||
return RegistryKey.of(Registry.DIMENSION_KEY, identifier);
|
||||
}
|
||||
public static RegistryKey<DimensionType> getDimensionKey(Identifier identifier) {
|
||||
return BuiltinRegistries.DIMENSION_TYPE.getKey(BuiltinRegistries.DIMENSION_TYPE.get(identifier)).orElseThrow();
|
||||
}
|
||||
|
||||
protected static RegistryKey<DimensionType> registerDimension(ConfigPack pack) {
|
||||
VanillaWorldProperties vanillaWorldProperties;
|
||||
if (pack.getContext().has(VanillaBiomeProperties.class)) {
|
||||
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
|
||||
} else {
|
||||
vanillaWorldProperties = new VanillaWorldProperties();
|
||||
}
|
||||
|
||||
DimensionType overworldDimensionType = new DimensionType(
|
||||
vanillaWorldProperties.getFixedTime() == null ? OptionalLong.empty() : OptionalLong.of(vanillaWorldProperties.getFixedTime()),
|
||||
vanillaWorldProperties.getHasSkyLight(),
|
||||
vanillaWorldProperties.getHasCeiling(),
|
||||
vanillaWorldProperties.getUltraWarm(),
|
||||
vanillaWorldProperties.getNatural(),
|
||||
vanillaWorldProperties.getCoordinateScale(),
|
||||
vanillaWorldProperties.getBedWorks(),
|
||||
vanillaWorldProperties.getRespawnAnchorWorks(),
|
||||
vanillaWorldProperties.getHeight().getMin(),
|
||||
vanillaWorldProperties.getHeight().getMax(),
|
||||
vanillaWorldProperties.getLogicalHeight(),
|
||||
TagKey.of(Registry.BLOCK_KEY, vanillaWorldProperties.getInfiniburn()),
|
||||
vanillaWorldProperties.getEffects(),
|
||||
vanillaWorldProperties.getAmbientLight(),
|
||||
vanillaWorldProperties.getMonsterSettings());
|
||||
|
||||
return registerDimension(new Identifier("terra", pack.getID().toLowerCase()), overworldDimensionType);
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
import com.dfsek.terra.api.structure.configured.ConfiguredStructure;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.Rotation;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
@@ -18,23 +18,16 @@ import com.dfsek.terra.mod.config.FertilizableConfig;
|
||||
|
||||
|
||||
public class FertilizableUtil {
|
||||
|
||||
private static final Random mojankRandom = new Random();
|
||||
|
||||
public static Boolean grow(ServerWorld world, BlockPos pos, BlockState state, Identifier cooldownId) {
|
||||
return grow(world, mojankRandom, pos, state, cooldownId);
|
||||
}
|
||||
|
||||
public static Boolean grow(ServerWorld world, Random random, BlockPos pos, BlockState state, Identifier cooldownId) {
|
||||
public static Boolean grow(ServerWorld world, RandomGenerator random, BlockPos pos, BlockState state, Identifier cooldownId) {
|
||||
Map<Identifier, FertilizableConfig> map = BiomeUtil.TERRA_BIOME_FERTILIZABLE_MAP.get(world.getBiome(pos));
|
||||
if(map != null) {
|
||||
Block block = state.getBlock();
|
||||
FertilizableConfig config = map.get(Registry.BLOCK.getId(block));
|
||||
if(config != null) {
|
||||
ConfiguredStructure canGrow = config.getCanGrow();
|
||||
Structure canGrow = config.getCanGrow();
|
||||
if(canGrow != null) {
|
||||
if(!canGrow.getStructure().get(random).generate(
|
||||
Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), (WritableWorld) world, random, Rotation.NONE)) {
|
||||
if(!canGrow.generate(
|
||||
Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), new WritableWorldSeedRedirecter((WritableWorld) world, world.getSeed() + random.nextLong(Long.MAX_VALUE)), Rotation.NONE)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -44,8 +37,8 @@ public class FertilizableUtil {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
config.getStructures().get(random).getStructure().get(random).generate(
|
||||
Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), (WritableWorld) world, random, Rotation.NONE);
|
||||
config.getStructures().get(random).generate(
|
||||
Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), new WritableWorldSeedRedirecter((WritableWorld) world, world.getSeed() + random.nextLong(Long.MAX_VALUE)), Rotation.NONE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@
|
||||
package com.dfsek.terra.mod.util;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.world.HeightLimitView;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
|
||||
public final class MinecraftAdapter {
|
||||
|
||||
@@ -53,4 +56,48 @@ public final class MinecraftAdapter {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static RandomGenerator adapt(Random random) {
|
||||
return new RandomGenerator() {
|
||||
@Override
|
||||
public boolean nextBoolean() {
|
||||
return random.nextBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float nextFloat() {
|
||||
return random.nextFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double nextDouble() {
|
||||
return random.nextDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt() {
|
||||
return random.nextInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt(int bound) {
|
||||
return random.nextInt(bound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextLong() {
|
||||
return random.nextLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double nextGaussian() {
|
||||
return random.nextGaussian();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt(int origin, int bound) {
|
||||
return random.nextBetween(origin, bound);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
package com.dfsek.terra.mod.util;
|
||||
|
||||
import com.dfsek.terra.api.util.ConstantRange;
|
||||
import com.dfsek.terra.mod.data.Codecs;
|
||||
|
||||
import com.dfsek.terra.mod.implmentation.TerraIntProvider;
|
||||
|
||||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||
import net.minecraft.block.entity.MobSpawnerBlockEntity;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.intprovider.ConstantIntProvider;
|
||||
import net.minecraft.util.math.intprovider.IntProviderType;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
@@ -12,6 +19,7 @@ import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biome.Builder;
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
|
||||
import net.minecraft.world.biome.GenerationSettings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -54,6 +62,13 @@ public final class MinecraftUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void registerIntProviderTypes() {
|
||||
IntProviderType<TerraIntProvider> CONSTANT = IntProviderType.register("terra:constant_range",
|
||||
Codecs.TERRA_CONSTANT_RANGE_INT_PROVIDER_TYPE);
|
||||
|
||||
TerraIntProvider.TERRA_RANGE_TYPE_TO_INT_PROVIDER_TYPE.put(ConstantRange.class, CONSTANT);
|
||||
}
|
||||
|
||||
public static RegistryKey<Biome> registerKey(Identifier identifier) {
|
||||
return RegistryKey.of(Registry.BIOME_KEY, identifier);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.dfsek.terra.mod.util;
|
||||
|
||||
import net.minecraft.client.gui.screen.CustomizeBuffetLevelScreen;
|
||||
import net.minecraft.client.gui.screen.CustomizeFlatLevelScreen;
|
||||
import net.minecraft.client.gui.screen.world.LevelScreenProvider;
|
||||
import net.minecraft.structure.StructureSet;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.noise.DoublePerlinNoiseSampler.NoiseParameters;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.MultiNoiseBiomeSource;
|
||||
import net.minecraft.world.biome.source.TheEndBiomeSource;
|
||||
@@ -13,8 +18,11 @@ import net.minecraft.world.dimension.DimensionOptions;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.dimension.DimensionTypes;
|
||||
import net.minecraft.world.gen.WorldPreset;
|
||||
import net.minecraft.world.gen.WorldPresets;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||
import net.minecraft.world.gen.chunk.FlatChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.FlatChunkGeneratorConfig;
|
||||
import net.minecraft.world.gen.chunk.NoiseChunkGenerator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -23,6 +31,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
@@ -34,6 +43,9 @@ public class PresetUtil {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PresetUtil.class);
|
||||
private static final List<Identifier> PRESETS = new ArrayList<>();
|
||||
|
||||
public static RegistryKey<WorldPreset> getPresetKey(Identifier identifier) {
|
||||
return RegistryKey.of(Registry.WORLD_PRESET_KEY, identifier);
|
||||
}
|
||||
public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack) {
|
||||
Registry<DimensionType> dimensionTypeRegistry = BuiltinRegistries.DIMENSION_TYPE;
|
||||
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = BuiltinRegistries.CHUNK_GENERATOR_SETTINGS;
|
||||
@@ -58,7 +70,7 @@ public class PresetUtil {
|
||||
new TheEndBiomeSource(biomeRegistry),
|
||||
endChunkGeneratorSettings));
|
||||
|
||||
RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getOrCreateEntry(DimensionTypes.OVERWORLD);
|
||||
RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getOrCreateEntry(DimensionUtil.registerDimension(pack));
|
||||
|
||||
RegistryEntry<ChunkGeneratorSettings> overworld = chunkGeneratorSettingsRegistry.getOrCreateEntry(ChunkGeneratorSettings.OVERWORLD);
|
||||
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
package com.dfsek.terra.mod.util;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.util.vector.Vector3.Mutable;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.BufferedWorld;
|
||||
import com.dfsek.terra.api.world.BufferedWorld.Builder;
|
||||
import com.dfsek.terra.api.world.WritableWorld;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||
|
||||
|
||||
public class WritableWorldSeedRedirecter implements WritableWorld {
|
||||
private final WritableWorld delegate;
|
||||
private final long seed;
|
||||
|
||||
|
||||
public WritableWorldSeedRedirecter(WritableWorld delegate, long seed) {
|
||||
this.delegate = delegate;
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getHandle() {
|
||||
return delegate.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(int x, int y, int z) {
|
||||
return delegate.getBlockState(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(Vector3 position) {
|
||||
return delegate.getBlockState(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(Vector3Int position) {
|
||||
return delegate.getBlockState(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity getBlockEntity(int x, int y, int z) {
|
||||
return delegate.getBlockEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity getBlockEntity(Vector3 position) {
|
||||
return delegate.getBlockEntity(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity getBlockEntity(Vector3Int position) {
|
||||
return delegate.getBlockEntity(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getGenerator() {
|
||||
return delegate.getGenerator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider getBiomeProvider() {
|
||||
return delegate.getBiomeProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return delegate.getPack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(Vector3 position, BlockState data, boolean physics) {
|
||||
delegate.setBlockState(position, data, physics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(Mutable position, BlockState data, boolean physics) {
|
||||
delegate.setBlockState(position, data, physics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(Vector3Int position, BlockState data, boolean physics) {
|
||||
delegate.setBlockState(position, data, physics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(Vector3Int.Mutable position, BlockState data, boolean physics) {
|
||||
delegate.setBlockState(position, data, physics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(Vector3 position, BlockState data) {
|
||||
delegate.setBlockState(position, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(Mutable position, BlockState data) {
|
||||
delegate.setBlockState(position, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(Vector3Int position, BlockState data) {
|
||||
delegate.setBlockState(position, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(Vector3Int.Mutable position, BlockState data) {
|
||||
delegate.setBlockState(position, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(int x, int y, int z, BlockState data) {
|
||||
delegate.setBlockState(x, y, z, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockState(int x, int y, int z, BlockState data, boolean physics) {
|
||||
delegate.setBlockState(x, y, z, data, physics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Vector3 location, EntityType entityType) {
|
||||
return delegate.spawnEntity(location, entityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(double x, double y, double z, EntityType entityType) {
|
||||
return delegate.spawnEntity(x, y, z, entityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedWorld buffer(int offsetX, int offsetY, int offsetZ) {
|
||||
return delegate.buffer(offsetX, offsetY, offsetZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder buffer() {
|
||||
return delegate.buffer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Column<WritableWorld> column(int x, int z) {
|
||||
return delegate.column(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
return seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHeight() {
|
||||
return delegate.getMaxHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinHeight() {
|
||||
return delegate.getMinHeight();
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1 @@
|
||||
accessWidener v1 named
|
||||
accessible class net/minecraft/world/biome/Biome$Weather
|
||||
accessWidener v1 named
|
||||
@@ -1,22 +1,22 @@
|
||||
plugins {
|
||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
||||
alias(libs.plugins.mod.architectury.loom)
|
||||
alias(libs.plugins.mod.architectury.plugin)
|
||||
alias(libs.plugins.mod.loom.quiltflower)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
||||
|
||||
implementation(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
||||
|
||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud) {
|
||||
modImplementation(libs.mod.fabric.fabric.loader)
|
||||
|
||||
minecraft(libs.mod.minecraft)
|
||||
mappings("net.fabricmc", "yarn", libs.versions.mod.yarn.get(), classifier = "v2")
|
||||
|
||||
modImplementation(libs.mod.cloud.fabric) {
|
||||
exclude("net.fabricmc")
|
||||
exclude("net.fabricmc.fabric-api")
|
||||
}
|
||||
@@ -42,5 +42,5 @@ tasks {
|
||||
|
||||
architectury {
|
||||
common("fabric", "quilt")
|
||||
minecraft = Versions.Mod.minecraft
|
||||
minecraft = libs.versions.mod.minecraft.get()
|
||||
}
|
||||
@@ -16,15 +16,19 @@ public class LifecycleEntryPoint {
|
||||
protected static void initialize(String modName, LifecyclePlatform platform) {
|
||||
logger.info("Initializing Terra {} mod...", modName);
|
||||
|
||||
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
serverCommandSource -> (CommandSender) serverCommandSource,
|
||||
commandSender -> (ServerCommandSource) commandSender
|
||||
);
|
||||
|
||||
|
||||
manager.brigadierManager().setNativeNumberSuggestions(false);
|
||||
|
||||
platform.getEventManager().callEvent(new CommandRegistrationEvent(manager));
|
||||
try {
|
||||
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
serverCommandSource -> (CommandSender) serverCommandSource,
|
||||
commandSender -> (ServerCommandSource) commandSender
|
||||
);
|
||||
|
||||
|
||||
manager.brigadierManager().setNativeNumberSuggestions(false);
|
||||
|
||||
platform.getEventManager().callEvent(new CommandRegistrationEvent(manager));
|
||||
} catch (Exception e) {
|
||||
logger.warn("Fabric API not found, Terra commands will not work.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.dfsek.terra.lifecycle.util;
|
||||
|
||||
import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
@@ -12,6 +14,7 @@ public final class RegistryUtil {
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
MinecraftUtil.registerIntProviderTypes();
|
||||
Registry.register(Registry.CHUNK_GENERATOR, new Identifier("terra:terra"), Codecs.MINECRAFT_CHUNK_GENERATOR_WRAPPER);
|
||||
Registry.register(Registry.BIOME_SOURCE, new Identifier("terra:terra"), Codecs.TERRA_BIOME_SOURCE);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
plugins {
|
||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
||||
alias(libs.plugins.mod.architectury.loom)
|
||||
alias(libs.plugins.mod.architectury.plugin)
|
||||
alias(libs.plugins.mod.loom.quiltflower)
|
||||
}
|
||||
|
||||
architectury {
|
||||
@@ -12,9 +12,6 @@ architectury {
|
||||
dependencies {
|
||||
shadedApi(project(":common:implementation:base"))
|
||||
|
||||
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
|
||||
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
|
||||
|
||||
implementation(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
||||
"developmentQuilt"(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
|
||||
shaded(project(path = ":platforms:mixin-common", configuration = "transformProductionQuilt")) { isTransitive = false }
|
||||
@@ -23,23 +20,22 @@ dependencies {
|
||||
"developmentQuilt"(project(path = ":platforms:mixin-lifecycle", configuration = "namedElements")) { isTransitive = false }
|
||||
shaded(project(path = ":platforms:mixin-lifecycle", configuration = "transformProductionQuilt")) { isTransitive = false }
|
||||
|
||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||
minecraft(libs.mod.minecraft)
|
||||
mappings("net.fabricmc", "yarn", libs.versions.mod.yarn.get(), classifier = "v2")
|
||||
|
||||
modImplementation("org.quiltmc:quilt-loader:${Versions.Quilt.quiltLoader}")
|
||||
modImplementation(libs.mod.quilt.quilt.loader)
|
||||
modImplementation(libs.mod.quilt.fabric.api)
|
||||
|
||||
modImplementation("org.quiltmc.quilted-fabric-api:quilted-fabric-api:${Versions.Quilt.fabricApi}")
|
||||
|
||||
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud) {
|
||||
modImplementation(libs.mod.cloud.fabric) {
|
||||
exclude("net.fabricmc")
|
||||
exclude("net.fabricmc.fabric-api")
|
||||
}
|
||||
include("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud) {
|
||||
include(libs.mod.cloud.fabric) {
|
||||
exclude("net.fabricmc")
|
||||
exclude("net.fabricmc.fabric-api")
|
||||
}
|
||||
|
||||
modLocalRuntime("com.github.astei:lazydfu:${Versions.Mod.lazyDfu}") {
|
||||
modLocalRuntime(libs.mod.lazy.dfu) {
|
||||
exclude("net.fabricmc")
|
||||
exclude("net.fabricmc.fabric-api")
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ include(":platforms:bukkit:common")
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven("https://maven.fabricmc.net") {
|
||||
name = "Fabric Maven"
|
||||
@@ -37,5 +38,8 @@ pluginManagement {
|
||||
maven("https://maven.quiltmc.org/repository/release/") {
|
||||
name = "Quilt"
|
||||
}
|
||||
maven("https://papermc.io/repo/repository/maven-public/") {
|
||||
name = "PaperMC"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user