Merge pull request #362 from duplexsystem/dev/enviroment

Dev/enviroment
This commit is contained in:
dfsek authored and GitHub committed 2022-08-21 13:35:02 -07:00
commit b6320c95ea
100 files changed
+1176 -1418

No files matched your search

+6 -18
View File
@@ -3,32 +3,20 @@ plugins {
kotlin("jvm") version embeddedKotlinVersion 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 { repositories {
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
maven("https://repo.codemc.org/repository/maven-public") { maven("https://repo.codemc.org/repository/maven-public") {
name = "CodeMC" name = "CodeMC"
} }
maven("https://papermc.io/repo/repository/maven-public/") {
name = "PaperMC"
}
} }
dependencies { dependencies {
implementation("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:+") implementation(libs.libraries.internal.shadow)
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.3.5")
implementation("org.ow2.asm:asm:9.3") implementation(libs.libraries.internal.asm)
implementation("org.ow2.asm:asm-tree:9.3") implementation(libs.libraries.internal.asm.tree)
implementation("com.dfsek.tectonic:common:4.2.0") implementation(libs.libraries.tectonic)
implementation("org.yaml:snakeyaml:1.27") implementation(libs.libraries.snakeyaml)
} }
+7
View File
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
+13 -6
View File
@@ -5,6 +5,8 @@ import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.getting import org.gradle.kotlin.dsl.getting
import org.gradle.kotlin.dsl.maven import org.gradle.kotlin.dsl.maven
import org.gradle.kotlin.dsl.repositories import org.gradle.kotlin.dsl.repositories
import org.gradle.api.artifacts.VersionCatalog
import org.gradle.kotlin.dsl.apply
fun Project.configureDependencies() { fun Project.configureDependencies() {
val testImplementation by configurations.getting val testImplementation by configurations.getting
@@ -15,6 +17,8 @@ fun Project.configureDependencies() {
val shaded by configurations.creating val shaded by configurations.creating
val libs = rootProject.project.versionCatalogs.libs
@Suppress("UNUSED_VARIABLE") @Suppress("UNUSED_VARIABLE")
val shadedApi by configurations.creating { val shadedApi by configurations.creating {
shaded.extendsFrom(this) shaded.extendsFrom(this)
@@ -48,14 +52,17 @@ fun Project.configureDependencies() {
maven("https://jitpack.io") { maven("https://jitpack.io") {
name = "JitPack" name = "JitPack"
} }
maven("Modrinth") {
url = uri("https://api.modrinth.com/maven")
}
} }
dependencies { dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0") testImplementation(libs.findLibrary("libraries.internal.junit.jupiter.api").get())
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.7.0") testImplementation(libs.findLibrary("libraries.internal.junit.jupiter.engine").get())
compileOnly("org.jetbrains:annotations:23.0.0") compileOnly(libs.findLibrary("libraries.internal.jetbrains.annotations").get())
compileOnly("com.google.guava:guava:30.0-jre") compileOnly(libs.findLibrary("libraries.guava").get())
testImplementation("com.google.guava:guava:30.0-jre") testImplementation(libs.findLibrary("libraries.guava").get())
} }
} }
+12
View 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")
-72
View File
@@ -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 { dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.biome.image.lib.jafama")
} }
@@ -2,11 +2,4 @@ version = version("1.0.1")
dependencies { dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.biome.pipeline.lib.jafama")
} }
@@ -2,11 +2,4 @@ version = version("1.1.0")
dependencies { dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.chunkgenerator.lib.jafama")
} }
@@ -7,6 +7,9 @@
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation; 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. * Class for bilinear interpolation of values arranged on a unit square.
*/ */
@@ -28,19 +31,6 @@ public class Interpolator {
this.v3 = v3; 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. * 2D Bilinear interpolation between 4 points on a unit square.
* *
@@ -50,8 +40,8 @@ public class Interpolator {
* @return double - The interpolated value. * @return double - The interpolated value.
*/ */
public double bilerp(double s, double t) { public double bilerp(double s, double t) {
double v01 = lerp(s, v0, v1); double v01 = MathUtil.lerp(s, v0, v1);
double v23 = lerp(s, v2, v3); double v23 = MathUtil.lerp(s, v2, v3);
return lerp(t, v01, v23); return MathUtil.lerp(t, v01, v23);
} }
} }
@@ -7,6 +7,9 @@
package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation; 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. * 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) { 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; package com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation;
import com.dfsek.terra.api.util.MathUtil;
import net.jafama.FastMath; import net.jafama.FastMath;
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties; import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
import com.dfsek.terra.api.properties.PropertyKey; import com.dfsek.terra.api.properties.PropertyKey;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider; import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import static com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.Interpolator.lerp;
public class LazilyEvaluatedInterpolator { public class LazilyEvaluatedInterpolator {
private final Double[] samples; // private final Double[] samples; //
@@ -84,10 +84,10 @@ public class LazilyEvaluatedInterpolator {
double xFrac = (double) (x % horizontalRes) / horizontalRes; double xFrac = (double) (x % horizontalRes) / horizontalRes;
double zFrac = (double) (z % 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_0 = MathUtil.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_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 if(yRange) { // we can do bilerp
return lerp_bottom; 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_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 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_0 = MathUtil.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_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.arguments.standard.LongArgument;
import cloud.commandframework.context.CommandContext; 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.MonadAddonInitializer;
import com.dfsek.terra.addons.manifest.api.monad.Do; 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.Get;
import com.dfsek.terra.addons.manifest.api.monad.Init; 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.CommandSender;
import com.dfsek.terra.api.command.arguments.RegistryArgument; import com.dfsek.terra.api.command.arguments.RegistryArgument;
import com.dfsek.terra.api.entity.Entity; 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.events.platform.CommandRegistrationEvent;
import com.dfsek.terra.api.event.functional.FunctionalEventHandler; 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.registry.Registry;
import com.dfsek.terra.api.structure.Structure; import com.dfsek.terra.api.structure.Structure;
import com.dfsek.terra.api.util.Rotation; import com.dfsek.terra.api.util.Rotation;
@@ -42,7 +39,7 @@ public class StructureCommandAddon implements MonadAddonInitializer {
handler.register(base, CommandRegistrationEvent.class) handler.register(base, CommandRegistrationEvent.class)
.then(event -> { .then(event -> {
CommandManager<CommandSender> manager = event.getCommandManager(); CommandManager<CommandSender> manager = event.getCommandManager();
manager.command( manager.command(
manager.commandBuilder("structures", ArgumentDescription.of("Manage or generate structures")) manager.commandBuilder("structures", ArgumentDescription.of("Manage or generate structures"))
.literal("generate") .literal("generate")
@@ -57,9 +54,7 @@ public class StructureCommandAddon implements MonadAddonInitializer {
structure.generate( structure.generate(
sender.position().toInt(), sender.position().toInt(),
sender.world(), sender.world(),
((Long) context.get("seed") == 0) ? new Random() : new Random(context.get("seed")), context.get("rotation"));
context.get("rotation")
);
}) })
.permission("terra.structures.generate") .permission("terra.structures.generate")
); );
@@ -2,11 +2,4 @@ version = version("1.0.0")
dependencies { dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.feature.distributor.lib.jafama")
} }
@@ -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.AndDistributorTemplate;
import com.dfsek.terra.addons.feature.distributor.config.NoDistributorTemplate; 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.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.PointSetDistributorTemplate;
import com.dfsek.terra.addons.feature.distributor.config.SamplerDistributorTemplate; import com.dfsek.terra.addons.feature.distributor.config.SamplerDistributorTemplate;
import com.dfsek.terra.addons.feature.distributor.config.XorDistributorTemplate; 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.Do;
import com.dfsek.terra.addons.manifest.api.monad.Get; import com.dfsek.terra.addons.manifest.api.monad.Get;
import com.dfsek.terra.addons.manifest.api.monad.Init; 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.events.config.pack.ConfigPackPreLoadEvent;
import com.dfsek.terra.api.event.functional.FunctionalEventHandler; import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
import com.dfsek.terra.api.inject.annotations.Inject;
import com.dfsek.terra.api.registry.CheckedRegistry; import com.dfsek.terra.api.registry.CheckedRegistry;
import com.dfsek.terra.api.structure.feature.Distributor; import com.dfsek.terra.api.structure.feature.Distributor;
import com.dfsek.terra.api.util.function.monad.Monad; 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("SAMPLER"), SamplerDistributorTemplate::new);
distributorRegistry.register(base.key("POINTS"), PointSetDistributorTemplate::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("AND"), AndDistributorTemplate::new);
distributorRegistry.register(base.key("OR"), OrDistributorTemplate::new); distributorRegistry.register(base.key("OR"), OrDistributorTemplate::new);
distributorRegistry.register(base.key("XOR"), XorDistributorTemplate::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.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate; 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.config.meta.Meta;
import com.dfsek.terra.api.noise.NoiseSampler;
import com.dfsek.terra.api.structure.feature.Distributor; import com.dfsek.terra.api.structure.feature.Distributor;
public class PaddedGridDistributorTemplate implements ObjectTemplate<Distributor> { public class PaddedGridSamplerDistributorTemplate implements ObjectTemplate<Distributor> {
@Value("width") @Value("width")
private @Meta int width; private @Meta int width;
@Value("padding") @Value("padding")
private @Meta int padding; private @Meta int padding;
@Value("salt") @Value("sampler")
private @Meta int salt; private @Meta NoiseSampler noise;
@Override @Override
public Distributor get() { 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 { dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.flora.lib.jafama")
} }
@@ -12,7 +12,8 @@ import net.jafama.FastMath;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; 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.BlockState;
import com.dfsek.terra.api.block.state.properties.enums.Direction; import com.dfsek.terra.api.block.state.properties.enums.Direction;
@@ -73,7 +74,7 @@ public class TerraFlora implements Structure {
} }
@Override @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; boolean doRotation = testRotation.size() > 0;
int size = layers.size(); int size = layers.size();
int c = ceiling ? -1 : 1; int c = ceiling ? -1 : 1;
@@ -86,10 +87,7 @@ public class TerraFlora implements Structure {
int lvl = (FastMath.abs(i)); int lvl = (FastMath.abs(i));
BlockState data = getStateCollection((ceiling ? lvl : size - lvl - 1)).get(distribution, location.getX(), location.getY(), BlockState data = getStateCollection((ceiling ? lvl : size - lvl - 1)).get(distribution, location.getX(), location.getY(),
location.getZ(), world.getSeed()); 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); world.setBlockState(location.mutable().add(0, i + c, 0).immutable(), data, physics);
} }
return true; return true;
@@ -2,11 +2,4 @@ version = version("1.1.0")
dependencies { dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.feature.locator.lib.jafama")
} }
@@ -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.AdjacentPatternLocatorTemplate;
import com.dfsek.terra.addons.feature.locator.config.AndLocatorTemplate; 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.OrLocatorTemplate;
import com.dfsek.terra.addons.feature.locator.config.PatternLocatorTemplate; 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.Sampler3DLocatorTemplate;
import com.dfsek.terra.addons.feature.locator.config.SamplerLocatorTemplate; import com.dfsek.terra.addons.feature.locator.config.SamplerLocatorTemplate;
import com.dfsek.terra.addons.feature.locator.config.SurfaceLocatorTemplate; 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.Do;
import com.dfsek.terra.addons.manifest.api.monad.Get; import com.dfsek.terra.addons.manifest.api.monad.Get;
import com.dfsek.terra.addons.manifest.api.monad.Init; 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.events.config.pack.ConfigPackPreLoadEvent;
import com.dfsek.terra.api.event.functional.FunctionalEventHandler; import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
import com.dfsek.terra.api.inject.annotations.Inject;
import com.dfsek.terra.api.registry.CheckedRegistry; import com.dfsek.terra.api.registry.CheckedRegistry;
import com.dfsek.terra.api.structure.feature.Locator; import com.dfsek.terra.api.structure.feature.Locator;
import com.dfsek.terra.api.util.function.monad.Monad; 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("SURFACE"), SurfaceLocatorTemplate::new);
locatorRegistry.register(base.key("TOP"), TopLocatorTemplate::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("PATTERN"), PatternLocatorTemplate::new);
locatorRegistry.register(base.key("ADJACENT_PATTERN"), AdjacentPatternLocatorTemplate::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 { dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
api("com.dfsek", "paralithic", Versions.Libraries.paralithic)
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<ShadowJar>("shadowJar") {
relocate("com.dfsek.paralithic", "com.dfsek.terra.addons.noise.lib.paralithic")
relocate("net.jafama", "com.dfsek.terra.addons.noise.lib.jafama")
} }
+1 -6
View File
@@ -2,10 +2,5 @@ version = version("1.0.0")
dependencies { dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama) compileOnlyApi(project(":common:addons:config-noise-function"))
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")
} }
@@ -7,6 +7,7 @@
package com.dfsek.terra.addons.ore; 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.addons.ore.ores.VanillaOre;
import com.dfsek.terra.api.Platform; import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.block.state.BlockState;
@@ -19,6 +20,6 @@ public class OreFactory implements ConfigFactory<OreTemplate, Structure> {
public VanillaOre build(OreTemplate config, Platform platform) { public VanillaOre build(OreTemplate config, Platform platform) {
BlockState m = config.getMaterial(); BlockState m = config.getMaterial();
return new VanillaOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.isExposed(), 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; 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 net.jafama.FastMath;
import java.util.Map; import java.util.Map;
import java.util.Random;
import com.dfsek.terra.api.block.BlockType; import com.dfsek.terra.api.block.BlockType;
import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.block.state.BlockState;
@@ -30,38 +33,40 @@ public class VanillaOre implements Structure {
private final boolean applyGravity; private final boolean applyGravity;
private final double exposed; private final double exposed;
private final Map<BlockType, BlockState> materials; private final Map<BlockType, BlockState> materials;
private final NoiseSampler sampler;
public VanillaOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity, 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.material = material;
this.size = size; this.size = size;
this.replaceable = replaceable; this.replaceable = replaceable;
this.applyGravity = applyGravity; this.applyGravity = applyGravity;
this.exposed = exposed; this.exposed = exposed;
this.materials = materials; this.materials = materials;
this.sampler = sampler;
} }
@Override @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 centerX = location.getX();
int centerZ = location.getZ(); int centerZ = location.getZ();
int centerY = location.getY(); 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 d1 = centerX + 8 + FastMath.sin(f) * size / 8.0F;
double d2 = 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 d3 = centerZ + 8 + FastMath.cos(f) * size / 8.0F;
double d4 = 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 d5 = centerY + (Math.round(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 1) + 1)) - 2D;
double d6 = centerY + random.nextInt(3) - 2D; double d6 = centerY + (Math.round(sampler.noise(centerX, centerY, centerZ, world.getSeed() + 2) + 1)) - 2D;
for(int i = 0; i < size; i++) { for(int i = 0; i < size; i++) {
float iFactor = (float) i / (float) size; 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 d11 = (FastMath.sin(Math.PI * iFactor) + 1.0) * d10 + 1.0;
double d12 = (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; if(y >= world.getMaxHeight() || y < world.getMinHeight()) continue;
BlockType block = world.getBlockState(x, y, z).getBlockType(); BlockType block = world.getBlockState(x, y, z).getBlockType();
if((d13 * d13 + d14 * d14 + d15 * d15 < 1.0D) && getReplaceable().contains(block)) { 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, z + 1).isAir() ||
world.getBlockState(x, y - 1, z).isAir() || world.getBlockState(x, y - 1, z).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 issues: https://github.com/PolyhedralDev/Terra/issues
source: https://github.com/PolyhedralDev/Terra source: https://github.com/PolyhedralDev/Terra
docs: https://terra.polydev.org 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") version = version("1.0.0")
dependencies { dependencies {
api("com.googlecode.json-simple:json-simple:1.1.1")
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
}
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
relocate("net.jafama", "com.dfsek.terra.addons.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&lt;ItemStack&gt; - 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; package com.dfsek.terra.addons.generation.feature;
import java.util.Collections; 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.addons.generation.feature.config.BiomeFeatures;
import com.dfsek.terra.api.Platform; import com.dfsek.terra.api.Platform;
@@ -58,7 +59,6 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
for(int subChunkZ = 0; subChunkZ < resolution; subChunkZ++) { for(int subChunkZ = 0; subChunkZ < resolution; subChunkZ++) {
int x = subChunkX + tx; int x = subChunkX + tx;
int z = subChunkZ + tz; int z = subChunkZ + tz;
long coordinateSeed = (seed * 31 + x) * 31 + z;
Column<WritableWorld> column = world.column(x, z); Column<WritableWorld> column = world.column(x, z);
biome.getContext() biome.getContext()
.get(biomeFeaturesKey) .get(biomeFeaturesKey)
@@ -72,7 +72,6 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
.forEach(y -> feature.getStructure(world, x, y, z) .forEach(y -> feature.getStructure(world, x, y, z)
.generate(Vector3Int.of(x, y, z), .generate(Vector3Int.of(x, y, z),
world, world,
new Random(coordinateSeed * 31 + y),
Rotation.NONE) Rotation.NONE)
); );
} }
+1 -1
View File
@@ -1,6 +1,6 @@
version = version("1.0.0") version = version("1.0.0")
dependencies { dependencies {
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}") implementation(libs.libraries.tectonic.yaml)
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
} }
@@ -1,8 +1,8 @@
version = version("1.0.0") version = version("1.0.0")
dependencies { dependencies {
api("commons-io:commons-io:2.7") api(libs.libraries.internal.apache.io)
implementation("com.dfsek.tectonic:yaml:${Versions.Libraries.tectonic}") implementation(libs.libraries.tectonic.yaml)
} }
tasks.withType<Jar> { tasks.withType<Jar> {
@@ -1,6 +1,6 @@
package com.dfsek.terra.addons.palette.shortcut.block; 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.block.state.BlockState;
import com.dfsek.terra.api.structure.Structure; import com.dfsek.terra.api.structure.Structure;
@@ -17,7 +17,7 @@ public class SingletonStructure implements Structure {
} }
@Override @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); world.setBlockState(location, blockState);
return true; return true;
} }
@@ -1,6 +1,6 @@
package com.dfsek.terra.addons.structure.mutator; 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.Keyed;
import com.dfsek.terra.api.registry.key.RegistryKey; import com.dfsek.terra.api.registry.key.RegistryKey;
@@ -32,13 +32,12 @@ public class MutatedStructure implements Structure, Keyed<MutatedStructure> {
} }
@Override @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, return base.generate(location,
world world
.buffer() .buffer()
.read(readInterceptor) .read(readInterceptor)
.write(writeInterceptor) .write(writeInterceptor)
.build(), .build(), rotation);
random, rotation);
} }
} }
@@ -7,7 +7,7 @@
package com.dfsek.terra.addons.sponge; 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.block.state.BlockState;
import com.dfsek.terra.api.registry.key.Keyed; import com.dfsek.terra.api.registry.key.Keyed;
@@ -31,7 +31,7 @@ public class SpongeStructure implements Structure, Keyed<SpongeStructure> {
} }
@Override @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 bX = location.getX();
int bY = location.getY(); int bY = location.getY();
int bZ = location.getZ(); int bZ = location.getZ();
@@ -1,15 +1,6 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
version = version("1.1.0") version = version("1.1.0")
dependencies { dependencies {
api("commons-io:commons-io:2.7")
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama) api(libs.libraries.internal.apache.io)
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")
} }
@@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.Charset; 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.Parser;
import com.dfsek.terra.addons.terrascript.parser.lang.Executable; 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.GetMarkFunctionBuilder;
import com.dfsek.terra.addons.terrascript.script.builders.LootFunctionBuilder; 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.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.RecursionsFunctionBuilder;
import com.dfsek.terra.addons.terrascript.script.builders.SetMarkFunctionBuilder; import com.dfsek.terra.addons.terrascript.script.builders.SetMarkFunctionBuilder;
import com.dfsek.terra.addons.terrascript.script.builders.StateFunctionBuilder; 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("block", new BlockFunctionBuilder(platform))
.registerFunction("debugBlock", new BlockFunctionBuilder(platform)) .registerFunction("debugBlock", new BlockFunctionBuilder(platform))
.registerFunction("structure", new StructureFunctionBuilder(registry, platform)) .registerFunction("structure", new StructureFunctionBuilder(registry, platform))
.registerFunction("randomInt", new RandomFunctionBuilder())
.registerFunction("recursions", new RecursionsFunctionBuilder()) .registerFunction("recursions", new RecursionsFunctionBuilder())
.registerFunction("setMark", new SetMarkFunctionBuilder()) .registerFunction("setMark", new SetMarkFunctionBuilder())
.registerFunction("getMark", new GetMarkFunctionBuilder()) .registerFunction("getMark", new GetMarkFunctionBuilder())
@@ -130,16 +128,16 @@ public class StructureScript implements Structure, Keyed<StructureScript> {
@Override @Override
@SuppressWarnings("try") @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); 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); platform.getProfiler().pop(profile);
return result; 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); 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); platform.getProfiler().pop(profile);
return result; return result;
} }
@@ -9,7 +9,7 @@ package com.dfsek.terra.addons.terrascript.script;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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.addons.terrascript.parser.lang.ImplementationArguments;
import com.dfsek.terra.api.util.Rotation; import com.dfsek.terra.api.util.Rotation;
@@ -20,16 +20,14 @@ import com.dfsek.terra.api.world.WritableWorld;
public class TerraImplementationArguments implements ImplementationArguments { public class TerraImplementationArguments implements ImplementationArguments {
private final Rotation rotation; private final Rotation rotation;
private final Random random;
private final WritableWorld world; private final WritableWorld world;
private final Map<Vector3, String> marks = new HashMap<>(); private final Map<Vector3, String> marks = new HashMap<>();
private final int recursions; private final int recursions;
private final Vector3Int origin; private final Vector3Int origin;
private boolean waterlog = false; 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.rotation = rotation;
this.random = random;
this.world = world; this.world = world;
this.recursions = recursions; this.recursions = recursions;
this.origin = origin; this.origin = origin;
@@ -39,10 +37,6 @@ public class TerraImplementationArguments implements ImplementationArguments {
return recursions; return recursions;
} }
public Random getRandom() {
return random;
}
public Rotation getRotation() { public Rotation getRotation() {
return rotation; 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.Logger;
import org.slf4j.LoggerFactory; 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.ImplementationArguments;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable; 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.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.Vector2;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import java.util.random.RandomGenerator;
import java.util.random.RandomGeneratorFactory;
public class LootFunction implements Function<Void> { public class LootFunction implements Function<Void> {
private static final Logger LOGGER = LoggerFactory.getLogger(LootFunction.class); private static final Logger LOGGER = LoggerFactory.getLogger(LootFunction.class);
@@ -84,8 +85,7 @@ public class LootFunction implements Function<Void> {
platform.getEventManager().callEvent(event); platform.getEventManager().callEvent(event);
if(event.isCancelled()) return; if(event.isCancelled()) return;
event.getTable().fillInventory(container.getInventory(), event.getTable().fillInventory(container.getInventory());
new Random(apply.hashCode()));
data.update(false); data.update(false);
} catch(Exception e) { } catch(Exception e) {
LOGGER.error("Could not apply loot at {}", apply, 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); String app = id.apply(implementationArguments, scope);
return registry.getByID(app).map(script -> { 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) { if(script instanceof StructureScript structureScript) {
return structureScript.generate(arguments.getOrigin(), return structureScript.generate(arguments.getOrigin(),
arguments.getWorld() arguments.getWorld()
.buffer(FastMath.roundToInt(xz.getX()), .buffer(FastMath.roundToInt(xz.getX()),
y.apply(implementationArguments, scope).intValue(), y.apply(implementationArguments, scope).intValue(),
FastMath.roundToInt(xz.getZ())), FastMath.roundToInt(xz.getZ())),
arguments.getRandom(), arguments.getRotation(), arguments.getRecursions() + 1);
arguments.getRotation().rotate(rotation1), arguments.getRecursions() + 1);
} }
return script.generate(arguments.getOrigin(), return script.generate(arguments.getOrigin(),
arguments.getWorld() arguments.getWorld()
.buffer(FastMath.roundToInt(xz.getX()), .buffer(FastMath.roundToInt(xz.getX()),
y.apply(implementationArguments, scope).intValue(), y.apply(implementationArguments, scope).intValue(),
FastMath.roundToInt(xz.getZ())), FastMath.roundToInt(xz.getZ())),
arguments.getRandom(), arguments.getRotation());
arguments.getRotation().rotate(rotation1));
}).orElseGet(() -> { }).orElseGet(() -> {
LOGGER.error("No such structure {}", app); LOGGER.error("No such structure {}", app);
return false; return false;
@@ -4,11 +4,4 @@ dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader")) compileOnlyApi(project(":common:addons:manifest-addon-loader"))
compileOnlyApi(project(":common:addons:chunk-generator-noise-3d")) compileOnlyApi(project(":common:addons:chunk-generator-noise-3d"))
compileOnlyApi(project(":common:addons:structure-terrascript-loader")) 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")
} }
+10 -8
View File
@@ -1,14 +1,16 @@
dependencies { dependencies {
api("ca.solo-studios", "strata", Versions.Libraries.strata) api(libs.libraries.strata)
compileOnlyApi("org.slf4j", "slf4j-api", Versions.Libraries.slf4j) compileOnlyApi(libs.libraries.slf4j.api)
testImplementation("org.slf4j", "slf4j-api", Versions.Libraries.slf4j) testImplementation(libs.libraries.slf4j.api)
api("cloud.commandframework", "cloud-core", Versions.Libraries.cloud) 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 org.jetbrains.annotations.ApiStatus.Experimental;
import java.util.List; 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.Inventory;
import com.dfsek.terra.api.inventory.ItemStack; import com.dfsek.terra.api.inventory.ItemStack;
@@ -22,16 +22,15 @@ public interface LootTable {
* Fills an Inventory with loot. * Fills an Inventory with loot.
* *
* @param i The Inventory to fill. * @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&lt;ItemStack&gt; - The list of loot fetched. * @return List&lt;ItemStack&gt; - 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; 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.Rotation;
import com.dfsek.terra.api.util.vector.Vector3Int; import com.dfsek.terra.api.util.vector.Vector3Int;
import com.dfsek.terra.api.world.WritableWorld; import com.dfsek.terra.api.world.WritableWorld;
public interface Structure { 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 org.jetbrains.annotations.NotNull;
import java.util.Iterator; import java.util.Iterator;
import java.util.Random; import java.util.random.RandomGenerator;
public class ConstantRange implements Range { public class ConstantRange implements Range {
@@ -37,7 +37,7 @@ public class ConstantRange implements Range {
} }
@Override @Override
public int get(Random r) { public int get(RandomGenerator r) {
return r.nextInt(min, max); return r.nextInt(min, max);
} }
@@ -173,4 +173,21 @@ public final class MathUtil {
return mu + sigma * val; 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 org.jetbrains.annotations.NotNull;
import java.util.Iterator; import java.util.Iterator;
import java.util.Random;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.random.RandomGenerator;
public interface Range extends Iterable<Integer> { public interface Range extends Iterable<Integer> {
@@ -19,7 +19,7 @@ public interface Range extends Iterable<Integer> {
Range reflect(int pt); Range reflect(int pt);
int get(Random r); int get(RandomGenerator r);
Range intersects(Range other); Range intersects(Range other);
@@ -15,9 +15,9 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.random.RandomGenerator;
import com.dfsek.terra.api.noise.NoiseSampler; import com.dfsek.terra.api.noise.NoiseSampler;
import com.dfsek.terra.api.util.MathUtil; import com.dfsek.terra.api.util.MathUtil;
@@ -43,7 +43,7 @@ public class ProbabilityCollection<E> implements Collection<E> {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public E get(Random r) { public E get(RandomGenerator r) {
if(array.length == 0) return null; if(array.length == 0) return null;
return (E) array[r.nextInt(array.length)]; return (E) array[r.nextInt(array.length)];
} }
@@ -195,7 +195,7 @@ public class ProbabilityCollection<E> implements Collection<E> {
} }
@Override @Override
public T get(Random r) { public T get(RandomGenerator r) {
return single; return single;
} }
+6 -6
View File
@@ -2,14 +2,14 @@ dependencies {
api(project(":common:api")) api(project(":common:api"))
api(project(":common:implementation:bootstrap-addon-loader")) 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(libs.libraries.internal.apache.text)
implementation("com.dfsek.tectonic", "yaml", Versions.Libraries.tectonic) 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
View 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" }
Binary file not shown.
+1 -2
View File
@@ -1,6 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
org.gradle.jvmargs=-Xmx4096m
Vendored
+159 -110
View File
@@ -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"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with 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 # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" app_path=$0
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do # Need this for daisy-chained symlinks.
ls=`ls -ld "$PRG"` while
link=`expr "$ls" : '.*-> \(.*\)$'` APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
if expr "$link" : '/.*' > /dev/null; then [ -h "$app_path" ]
PRG="$link" do
else ls=$( ls -ld "$app_path" )
PRG=`dirname "$PRG"`"/$link" link=${ls#*' -> '}
fi case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" 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. # 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"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD=maximum
warn () { warn () {
echo "$*" echo "$*"
} } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "`uname`" in case "$( uname )" in #(
CYGWIN* ) CYGWIN* ) cygwin=true ;; #(
cygwin=true Darwin* ) darwin=true ;; #(
;; MSYS* | MINGW* ) msys=true ;; #(
Darwin* ) NONSTOP* ) nonstop=true ;;
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 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 [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java" JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD="$JAVA_HOME/bin/java" JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 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." location of your Java installation."
fi fi
else 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. 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 Please set the JAVA_HOME variable in your environment to match the
@@ -106,80 +140,95 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
MAX_FD_LIMIT=`ulimit -H -n` case $MAX_FD in #(
if [ $? -eq 0 ] ; then max*)
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD=$( ulimit -H -n ) ||
MAX_FD="$MAX_FD_LIMIT" warn "Could not query maximum file descriptor limit"
fi esac
ulimit -n $MAX_FD case $MAX_FD in #(
if [ $? -ne 0 ] ; then '' | soft) :;; #(
warn "Could not set maximum file descriptor limit: $MAX_FD" *)
fi ulimit -n "$MAX_FD" ||
else warn "Could not set maximum file descriptor limit to $MAX_FD"
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" ;;
esac esac
fi fi
# Escape application args # Collect all arguments for the java command, stacking in reverse order:
save () { # * args from the command line
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done # * the main class name
echo " " # * -classpath
} # * -D...appname settings
APP_ARGS=`save "$@"` # * --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 # For Cygwin or MSYS, switch paths to Windows format before running java
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 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" "$@" exec "$JAVACMD" "$@"
+3 -6
View File
@@ -1,5 +1,5 @@
plugins { plugins {
id("xyz.jpenilla.run-paper") version "1.0.6" alias(libs.plugins.bukkit.run.paper)
} }
repositories { repositories {
@@ -9,15 +9,12 @@ repositories {
dependencies { dependencies {
shaded(project(":platforms:bukkit:common")) shaded(project(":platforms:bukkit:common"))
shaded(project(":platforms:bukkit:nms:v1_19_R1", configuration = "reobf")) shaded(project(":platforms:bukkit:nms:v1_19_R1", configuration = "reobf"))
shaded("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper) shaded(libs.bukkit.reflection.remapper)
} }
tasks { tasks {
shadowJar { shadowJar {
relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats")
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib") 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/slf4j/**")
exclude("org/checkerframework/**") exclude("org/checkerframework/**")
exclude("org/jetbrains/annotations/**") exclude("org/jetbrains/annotations/**")
@@ -28,7 +25,7 @@ tasks {
} }
runServer { runServer {
minecraftVersion("1.19") minecraftVersion(libs.versions.bukkit.minecraft.get())
dependsOn(shadowJar) dependsOn(shadowJar)
pluginJars(shadowJar.get().archiveFile) pluginJars(shadowJar.get().archiveFile)
} }
+3 -8
View File
@@ -5,14 +5,9 @@ repositories {
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) shadedApi(project(":common:implementation:base"))
api("org.slf4j:slf4j-api:1.8.0-beta4") { compileOnly(libs.bukkit.paper.api)
because("Minecraft 1.17+ includes slf4j 1.8.0-beta4, so we need to shade it for other versions.")
}
compileOnly("io.papermc.paper:paper-api:${Versions.Bukkit.paper}") shadedApi(libs.bukkit.paper.lib)
shadedApi("io.papermc", "paperlib", Versions.Bukkit.paperLib) shadedApi(libs.bukkit.cloud.paper)
shadedApi("com.google.guava:guava:30.0-jre")
shadedApi("cloud.commandframework", "cloud-paper", Versions.Libraries.cloud)
} }
@@ -28,7 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.random.RandomGenerator;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.dfsek.terra.api.block.state.BlockState; import com.dfsek.terra.api.block.state.BlockState;
@@ -63,7 +63,7 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
} }
@Override @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); BukkitWorldProperties properties = new BukkitWorldProperties(worldInfo);
delegate.generateChunkData(new BukkitProtoChunk(chunkData), properties, pack.getBiomeProvider(), x, z); delegate.generateChunkData(new BukkitProtoChunk(chunkData), properties, pack.getBiomeProvider(), x, z);
} }
@@ -74,7 +74,7 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
.stream() .stream()
.map(generationStage -> new BlockPopulator() { .map(generationStage -> new BlockPopulator() {
@Override @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) { @NotNull LimitedRegion limitedRegion) {
generationStage.populate(new BukkitProtoWorld(limitedRegion, air, pack.getBiomeProvider())); 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 { repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") 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.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value; import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate; import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
import com.dfsek.terra.api.structure.Structure;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import java.util.Map; import java.util.Map;
@@ -14,7 +17,7 @@ import com.dfsek.terra.api.util.collection.ProbabilityCollection;
public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> { public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
@Value("strucutres") @Value("strucutres")
@Default @Default
private ProbabilityCollection<ConfiguredStructure> structures = null; private ProbabilityCollection<Structure> structures = null;
@Value("cooldowns") @Value("cooldowns")
@Default @Default
@@ -28,7 +31,7 @@ public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
@Default @Default
private Boolean villagerFertilizable = null; private Boolean villagerFertilizable = null;
public ProbabilityCollection<ConfiguredStructure> getStructures() { public ProbabilityCollection<Structure> getStructures() {
return structures; return structures;
} }
+3 -7
View File
@@ -7,14 +7,10 @@ val javaMainClass = "com.dfsek.terra.cli.TerraCLI"
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) shadedApi(project(":common:implementation:base"))
shadedApi("commons-io:commons-io:${Versions.CLI.commonsIO}") shadedApi(libs.libraries.internal.apache.io)
shadedApi("com.github.Querz:NBT:${Versions.CLI.nbt}") shadedApi(libs.cli.nbt)
shadedImplementation("com.google.guava:guava:${Versions.CLI.guava}") shadedImplementation(libs.cli.logback)
shadedImplementation("ch.qos.logback:logback-classic:${Versions.CLI.logback}")
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
} }
tasks.withType<Jar> { tasks.withType<Jar> {
+9 -25
View File
@@ -1,7 +1,7 @@
plugins { plugins {
id("dev.architectury.loom") version Versions.Mod.architecuryLoom alias(libs.plugins.mod.architectury.loom)
id("architectury-plugin") version Versions.Mod.architecturyPlugin alias(libs.plugins.mod.architectury.plugin)
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower alias(libs.plugins.mod.loom.quiltflower)
} }
architectury { architectury {
@@ -12,9 +12,6 @@ architectury {
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) 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 } implementation(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
"developmentFabric"(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 } 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 } "developmentFabric"(project(path = ":platforms:mixin-lifecycle", configuration = "namedElements")) { isTransitive = false }
shaded(project(path = ":platforms:mixin-lifecycle", configuration = "transformProductionFabric")) { 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}") modImplementation(libs.mod.fabric.fabric.loader)
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
modImplementation("net.fabricmc:fabric-loader:${Versions.Fabric.fabricLoader}") modImplementation(libs.mod.cloud.fabric)
include(libs.mod.cloud.fabric)
setOf( modLocalRuntime(libs.mod.lazy.dfu)
"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}")
} }
loom { loom {
+8 -11
View File
@@ -1,7 +1,7 @@
plugins { plugins {
id("dev.architectury.loom") version Versions.Mod.architecuryLoom alias(libs.plugins.mod.architectury.loom)
id("architectury-plugin") version Versions.Mod.architecturyPlugin alias(libs.plugins.mod.architectury.plugin)
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower alias(libs.plugins.mod.loom.quiltflower)
} }
architectury { architectury {
@@ -10,9 +10,6 @@ architectury {
} }
dependencies { dependencies {
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
shadedApi(project(":common:implementation:base")) shadedApi(project(":common:implementation:base"))
"forgeRuntimeLibrary"(project(":common:implementation:base")) "forgeRuntimeLibrary"(project(":common:implementation:base"))
@@ -20,14 +17,14 @@ dependencies {
"developmentForge"(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false } "developmentForge"(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
shaded(project(path = ":platforms:mixin-common", configuration = "transformProductionForge")) { 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}") minecraft(libs.mod.minecraft)
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2") mappings("net.fabricmc", "yarn", libs.versions.mod.yarn.get(), classifier = "v2")
//forge is not ok. //forge is not ok.
compileOnly("org.burningwave:core:${Versions.Forge.burningwave}") compileOnly(libs.mod.forge.burningwave)
"forgeRuntimeLibrary"("org.burningwave:core:${Versions.Forge.burningwave}") "forgeRuntimeLibrary"(libs.mod.forge.burningwave)
} }
loom { loom {
+7 -9
View File
@@ -1,7 +1,7 @@
plugins { plugins {
id("dev.architectury.loom") version Versions.Mod.architecuryLoom alias(libs.plugins.mod.architectury.loom)
id("architectury-plugin") version Versions.Mod.architecturyPlugin alias(libs.plugins.mod.architectury.plugin)
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower alias(libs.plugins.mod.loom.quiltflower)
} }
loom { loom {
@@ -15,16 +15,14 @@ loom {
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) shadedApi(project(":common:implementation:base"))
compileOnly("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}") modImplementation(libs.mod.fabric.fabric.loader)
annotationProcessor("net.fabricmc:sponge-mixin:${Versions.Mod.mixin}")
annotationProcessor("dev.architectury:architectury-loom:${Versions.Mod.architecuryLoom}")
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}") minecraft(libs.mod.minecraft)
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2") mappings("net.fabricmc", "yarn", libs.versions.mod.yarn.get(), classifier = "v2")
} }
architectury { architectury {
common("fabric", "forge", "quilt") 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.Versions;
import ca.solostudios.strata.version.Version; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -44,6 +51,15 @@ public abstract class MinecraftAddon implements BaseAddon {
@Override @Override
public void initialize() { 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() modPlatform.getEventManager()
.getHandler(FunctionalEventHandler.class) .getHandler(FunctionalEventHandler.class)
.register(this, ConfigPackPreLoadEvent.class) .register(this, ConfigPackPreLoadEvent.class)
@@ -77,14 +77,11 @@ public abstract class ModPlatform extends AbstractPlatform {
throw new LoadException("Invalid identifier: " + o, depthTracker); throw new LoadException("Invalid identifier: " + o, depthTracker);
return identifier; return identifier;
}) })
.registerLoader(Precipitation.class, (type, o, loader, depthTracker) -> Precipitation.valueOf(((String) o).toUpperCase( .registerLoader(Precipitation.class, (type, o, loader, depthTracker) -> Precipitation.valueOf(((String) o).toUpperCase()))
Locale.ROOT)))
.registerLoader(GrassColorModifier.class, .registerLoader(GrassColorModifier.class,
(type, o, loader, depthTracker) -> GrassColorModifier.valueOf(((String) o).toUpperCase( (type, o, loader, depthTracker) -> GrassColorModifier.valueOf(((String) o).toUpperCase()))
Locale.ROOT))) .registerLoader(TemperatureModifier.class,
.registerLoader(GrassColorModifier.class, (type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase()))
(type, o, loader, depthTracker) -> TemperatureModifier.valueOf(((String) o).toUpperCase(
Locale.ROOT)))
.registerLoader(SpawnGroup.class, (type, o, loader, depthTracker) -> SpawnGroup.valueOf((String) o)) .registerLoader(SpawnGroup.class, (type, o, loader, depthTracker) -> SpawnGroup.valueOf((String) o))
.registerLoader(BiomeParticleConfig.class, BiomeParticleConfigTemplate::new) .registerLoader(BiomeParticleConfig.class, BiomeParticleConfigTemplate::new)
.registerLoader(SoundEvent.class, SoundEventTemplate::new) .registerLoader(SoundEvent.class, SoundEventTemplate::new)
@@ -7,14 +7,14 @@ import net.minecraft.util.Identifier;
import java.util.Map; 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; import com.dfsek.terra.api.util.collection.ProbabilityCollection;
public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> { public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
@Value("strucutres") @Value("strucutres")
@Default @Default
private ProbabilityCollection<ConfiguredStructure> structures = null; private ProbabilityCollection<Structure> structures = null;
@Value("cooldowns") @Value("cooldowns")
@Default @Default
@@ -22,13 +22,13 @@ public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
@Value("can-grow") @Value("can-grow")
@Default @Default
private ConfiguredStructure canGrow = null; private Structure canGrow = null;
@Value("villager-fertilizable") @Value("villager-farmable")
@Default @Default
private Boolean villagerFertilizable = null; private Boolean villagerFarmable = null;
public ProbabilityCollection<ConfiguredStructure> getStructures() { public ProbabilityCollection<Structure> getStructures() {
return structures; return structures;
} }
@@ -36,12 +36,12 @@ public class FertilizableConfig implements ObjectTemplate<FertilizableConfig> {
return cooldowns; return cooldowns;
} }
public ConfiguredStructure getCanGrow() { public Structure getCanGrow() {
return canGrow; return canGrow;
} }
public Boolean isVillagerFertilizable() { public Boolean isVillagerFarmable() {
return villagerFertilizable; return villagerFarmable;
} }
@Override @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; 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.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder; import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.dynamic.RegistryOps; import net.minecraft.util.dynamic.RegistryOps;
@@ -62,4 +67,9 @@ public final class Codecs {
.forGetter(MinecraftChunkGeneratorWrapper::getSettings) .forGetter(MinecraftChunkGeneratorWrapper::getSettings)
).apply(instance, instance.stable(MinecraftChunkGeneratorWrapper::new)) ).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; 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 com.mojang.serialization.Codec;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@@ -76,6 +79,8 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
private ChunkGenerator delegate; private ChunkGenerator delegate;
private ConfigPack pack; private ConfigPack pack;
private VanillaWorldProperties vanillaWorldProperties;
public MinecraftChunkGeneratorWrapper(Registry<StructureSet> noiseRegistry, TerraBiomeSource biomeSource, ConfigPack configPack, public MinecraftChunkGeneratorWrapper(Registry<StructureSet> noiseRegistry, TerraBiomeSource biomeSource, ConfigPack configPack,
RegistryEntry<ChunkGeneratorSettings> settingsSupplier) { RegistryEntry<ChunkGeneratorSettings> settingsSupplier) {
super(noiseRegistry, Optional.empty(), biomeSource); super(noiseRegistry, Optional.empty(), biomeSource);
@@ -86,6 +91,11 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
this.delegate = pack.getGeneratorProvider().newInstance(pack); this.delegate = pack.getGeneratorProvider().newInstance(pack);
logger.info("Loading world with config pack {}", pack.getID()); logger.info("Loading world with config pack {}", pack.getID());
this.biomeSource = biomeSource; this.biomeSource = biomeSource;
if (pack.getContext().has(VanillaBiomeProperties.class)) {
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
} else {
vanillaWorldProperties = new VanillaWorldProperties();
}
} }
public Registry<StructureSet> getNoiseRegistry() { public Registry<StructureSet> getNoiseRegistry() {
@@ -115,7 +125,7 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
@Override @Override
public int getWorldHeight() { 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, private void beard(StructureAccessor structureAccessor, Chunk chunk, WorldProperties world, BiomeProvider biomeProvider,
PreLoadCompatibilityOptions compatibilityOptions) { PreLoadCompatibilityOptions compatibilityOptions) {
StructureWeightSampler structureWeightSampler = StructureWeightSampler.method_42695(structureAccessor, chunk.getPos()); StructureWeightSampler structureWeightSampler = StructureWeightSampler.createStructureWeightSampler(structureAccessor, chunk.getPos());
double threshold = compatibilityOptions.getBeardThreshold(); double threshold = compatibilityOptions.getBeardThreshold();
double airThreshold = compatibilityOptions.getAirThreshold(); double airThreshold = compatibilityOptions.getAirThreshold();
int xi = chunk.getPos().x << 4; int xi = chunk.getPos().x << 4;
@@ -174,12 +184,12 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
@Override @Override
public int getSeaLevel() { public int getSeaLevel() {
return settings.value().seaLevel(); return vanillaWorldProperties.getSealevel();
} }
@Override @Override
public int getMinimumY() { 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 @Override
public void getDebugHudText(List<String> text, NoiseConfig noiseConfig, BlockPos pos) { public void getDebugHudText(List<String> text, NoiseConfig noiseConfig, BlockPos pos) {
// no op
} }
public ConfigPack getPack() { public ConfigPack getPack() {
@@ -220,6 +230,12 @@ public class MinecraftChunkGeneratorWrapper extends net.minecraft.world.gen.chun
this.pack = pack; this.pack = pack;
this.delegate = pack.getGeneratorProvider().newInstance(pack); this.delegate = pack.getGeneratorProvider().newInstance(pack);
biomeSource.setPack(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()); 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; package com.dfsek.terra.mod.mixin.gameplay;
import com.dfsek.terra.mod.util.MinecraftAdapter;
import net.minecraft.item.BoneMealItem; import net.minecraft.item.BoneMealItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld; 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 com.dfsek.terra.mod.util.FertilizableUtil;
import java.util.random.RandomGenerator;
@Mixin(BoneMealItem.class) @Mixin(BoneMealItem.class)
public class BoneMealItemMixin { public class BoneMealItemMixin {
@@ -22,7 +26,7 @@ public class BoneMealItemMixin {
@Inject(method = "useOnFertilizable", at = @At("HEAD"), cancellable = true) @Inject(method = "useOnFertilizable", at = @At("HEAD"), cancellable = true)
private static void injectUseOnFertilizable(ItemStack stack, World world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) { private static void injectUseOnFertilizable(ItemStack stack, World world, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
if(world instanceof ServerWorld) { 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); stack.decrement(1);
if(value != null) { if(value != null) {
cir.setReturnValue(value); cir.setReturnValue(value);
@@ -1,6 +1,10 @@
package com.dfsek.terra.mod.mixin.gameplay; 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.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.ai.brain.task.BoneMealTask; 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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Map; 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.Rotation;
import com.dfsek.terra.api.util.vector.Vector3Int; import com.dfsek.terra.api.util.vector.Vector3Int;
import com.dfsek.terra.api.world.WritableWorld; import com.dfsek.terra.api.world.WritableWorld;
import com.dfsek.terra.mod.config.FertilizableConfig; import com.dfsek.terra.mod.config.FertilizableConfig;
import com.dfsek.terra.mod.util.BiomeUtil; import com.dfsek.terra.mod.util.BiomeUtil;
import com.dfsek.terra.mod.util.MinecraftAdapter;
@Mixin(BoneMealTask.class) @Mixin(BoneMealTask.class)
@@ -35,21 +40,20 @@ public class BoneMealTaskMixin {
Block block = blockState.getBlock(); Block block = blockState.getBlock();
FertilizableConfig config = map.get(Registry.BLOCK.getId(block)); FertilizableConfig config = map.get(Registry.BLOCK.getId(block));
if(config != null) { if(config != null) {
Boolean villagerFertilizable = config.isVillagerFertilizable(); Boolean villagerFarmable = config.isVillagerFarmable();
if(villagerFertilizable != null) { if(villagerFarmable != null) {
if(villagerFertilizable) { if(villagerFarmable) {
ConfiguredStructure canGrow = config.getCanGrow(); Structure canGrow = config.getCanGrow();
if(canGrow != null) { if(canGrow != null) {
Random random = (Random) world.getRandom(); RandomGenerator random = MinecraftAdapter.adapt(world.getRandom());
cir.setReturnValue(canGrow.getStructure().get(random).generate( cir.setReturnValue(canGrow.generate(
Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), (WritableWorld) world, random, Rotation.NONE)); Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), new WritableWorldSeedRedirecter((WritableWorld) world, world.getSeed() + random.nextLong(Long.MAX_VALUE)), Rotation.NONE));
return; return;
} }
cir.setReturnValue(true); cir.setReturnValue(true);
return; return;
} }
cir.setReturnValue(false); cir.setReturnValue(false);
return;
} }
} }
} }
@@ -1,6 +1,8 @@
package com.dfsek.terra.mod.mixin.gameplay; package com.dfsek.terra.mod.mixin.gameplay;
import com.dfsek.terra.mod.util.MinecraftAdapter;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@@ -12,6 +14,8 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import com.dfsek.terra.mod.util.FertilizableUtil; import com.dfsek.terra.mod.util.FertilizableUtil;
import java.util.random.RandomGenerator;
@Mixin(ServerWorld.class) @Mixin(ServerWorld.class)
public class ServerWorldMixin { public class ServerWorldMixin {
@@ -22,7 +26,7 @@ public class ServerWorldMixin {
target = "Lnet/minecraft/block/BlockState;randomTick(Lnet/minecraft/server/world/ServerWorld;" + target = "Lnet/minecraft/block/BlockState;randomTick(Lnet/minecraft/server/world/ServerWorld;" +
"Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/random/Random;)V")) "Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/random/Random;)V"))
public void injectTickChunk(BlockState instance, ServerWorld serverWorld, BlockPos blockPos, Random random) { 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 != null) {
if(!value) { if(!value) {
instance.randomTick(serverWorld, blockPos, random); instance.randomTick(serverWorld, blockPos, random);
@@ -1,5 +1,7 @@
package com.dfsek.terra.mod.mixin.lifecycle; package com.dfsek.terra.mod.mixin.lifecycle;
import com.dfsek.terra.mod.util.MinecraftUtil;
import net.minecraft.server.DataPackContents; import net.minecraft.server.DataPackContents;
import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
@@ -62,7 +62,13 @@ public class BiomeUtil {
*/ */
protected static void registerBiome(Biome biome, ConfigPack pack, protected static void registerBiome(Biome biome, ConfigPack pack,
com.dfsek.terra.api.registry.key.RegistryKey id) { 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); 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 net.minecraft.util.registry.Registry;
import java.util.Map; 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.Rotation;
import com.dfsek.terra.api.util.vector.Vector3Int; import com.dfsek.terra.api.util.vector.Vector3Int;
import com.dfsek.terra.api.world.WritableWorld; import com.dfsek.terra.api.world.WritableWorld;
@@ -18,23 +18,16 @@ import com.dfsek.terra.mod.config.FertilizableConfig;
public class FertilizableUtil { public class FertilizableUtil {
public static Boolean grow(ServerWorld world, RandomGenerator random, BlockPos pos, BlockState state, Identifier cooldownId) {
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) {
Map<Identifier, FertilizableConfig> map = BiomeUtil.TERRA_BIOME_FERTILIZABLE_MAP.get(world.getBiome(pos)); Map<Identifier, FertilizableConfig> map = BiomeUtil.TERRA_BIOME_FERTILIZABLE_MAP.get(world.getBiome(pos));
if(map != null) { if(map != null) {
Block block = state.getBlock(); Block block = state.getBlock();
FertilizableConfig config = map.get(Registry.BLOCK.getId(block)); FertilizableConfig config = map.get(Registry.BLOCK.getId(block));
if(config != null) { if(config != null) {
ConfiguredStructure canGrow = config.getCanGrow(); Structure canGrow = config.getCanGrow();
if(canGrow != null) { if(canGrow != null) {
if(!canGrow.getStructure().get(random).generate( if(!canGrow.generate(
Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), (WritableWorld) world, random, Rotation.NONE)) { Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), new WritableWorldSeedRedirecter((WritableWorld) world, world.getSeed() + random.nextLong(Long.MAX_VALUE)), Rotation.NONE)) {
return false; return false;
} }
} }
@@ -44,8 +37,8 @@ public class FertilizableUtil {
return true; return true;
} }
} }
config.getStructures().get(random).getStructure().get(random).generate( config.getStructures().get(random).generate(
Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), (WritableWorld) world, random, Rotation.NONE); Vector3Int.of(pos.getX(), pos.getY(), pos.getZ()), new WritableWorldSeedRedirecter((WritableWorld) world, world.getSeed() + random.nextLong(Long.MAX_VALUE)), Rotation.NONE);
return true; return true;
} }
} }
@@ -18,11 +18,14 @@
package com.dfsek.terra.mod.util; package com.dfsek.terra.mod.util;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.HeightLimitView; import net.minecraft.world.HeightLimitView;
import com.dfsek.terra.api.util.vector.Vector3; import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.info.WorldProperties; import com.dfsek.terra.api.world.info.WorldProperties;
import java.util.random.RandomGenerator;
public final class MinecraftAdapter { 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; 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.LootableContainerBlockEntity;
import net.minecraft.block.entity.MobSpawnerBlockEntity; import net.minecraft.block.entity.MobSpawnerBlockEntity;
import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.block.entity.SignBlockEntity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; 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.Registry;
import net.minecraft.util.registry.RegistryEntry; import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey; 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;
import net.minecraft.world.biome.Biome.Builder; import net.minecraft.world.biome.Biome.Builder;
import net.minecraft.world.biome.BiomeEffects; import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
import net.minecraft.world.biome.GenerationSettings; import net.minecraft.world.biome.GenerationSettings;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -54,6 +62,13 @@ public final class MinecraftUtil {
return null; 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) { public static RegistryKey<Biome> registerKey(Identifier identifier) {
return RegistryKey.of(Registry.BIOME_KEY, identifier); return RegistryKey.of(Registry.BIOME_KEY, identifier);
} }
@@ -1,11 +1,16 @@
package com.dfsek.terra.mod.util; 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.structure.StructureSet;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.noise.DoublePerlinNoiseSampler.NoiseParameters; import net.minecraft.util.math.noise.DoublePerlinNoiseSampler.NoiseParameters;
import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry; import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.MultiNoiseBiomeSource; import net.minecraft.world.biome.source.MultiNoiseBiomeSource;
import net.minecraft.world.biome.source.TheEndBiomeSource; 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.DimensionType;
import net.minecraft.world.dimension.DimensionTypes; import net.minecraft.world.dimension.DimensionTypes;
import net.minecraft.world.gen.WorldPreset; 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.ChunkGenerator;
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; 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 net.minecraft.world.gen.chunk.NoiseChunkGenerator;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -23,6 +31,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import com.dfsek.terra.api.config.ConfigPack; import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.util.generic.pair.Pair; 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 Logger LOGGER = LoggerFactory.getLogger(PresetUtil.class);
private static final List<Identifier> PRESETS = new ArrayList<>(); 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) { public static Pair<Identifier, WorldPreset> createDefault(ConfigPack pack) {
Registry<DimensionType> dimensionTypeRegistry = BuiltinRegistries.DIMENSION_TYPE; Registry<DimensionType> dimensionTypeRegistry = BuiltinRegistries.DIMENSION_TYPE;
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = BuiltinRegistries.CHUNK_GENERATOR_SETTINGS; Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = BuiltinRegistries.CHUNK_GENERATOR_SETTINGS;
@@ -58,7 +70,7 @@ public class PresetUtil {
new TheEndBiomeSource(biomeRegistry), new TheEndBiomeSource(biomeRegistry),
endChunkGeneratorSettings)); endChunkGeneratorSettings));
RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getOrCreateEntry(DimensionTypes.OVERWORLD); RegistryEntry<DimensionType> overworldDimensionType = dimensionTypeRegistry.getOrCreateEntry(DimensionUtil.registerDimension(pack));
RegistryEntry<ChunkGeneratorSettings> overworld = chunkGeneratorSettingsRegistry.getOrCreateEntry(ChunkGeneratorSettings.OVERWORLD); 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 accessWidener v1 named
accessible class net/minecraft/world/biome/Biome$Weather
+11 -11
View File
@@ -1,22 +1,22 @@
plugins { plugins {
id("dev.architectury.loom") version Versions.Mod.architecuryLoom alias(libs.plugins.mod.architectury.loom)
id("architectury-plugin") version Versions.Mod.architecturyPlugin alias(libs.plugins.mod.architectury.plugin)
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower alias(libs.plugins.mod.loom.quiltflower)
} }
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) 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 } implementation(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}") shadedApi(project(":common:implementation:base"))
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
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")
exclude("net.fabricmc.fabric-api") exclude("net.fabricmc.fabric-api")
} }
@@ -42,5 +42,5 @@ tasks {
architectury { architectury {
common("fabric", "quilt") 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) { protected static void initialize(String modName, LifecyclePlatform platform) {
logger.info("Initializing Terra {} mod...", modName); logger.info("Initializing Terra {} mod...", modName);
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>( try {
CommandExecutionCoordinator.simpleCoordinator(), FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
serverCommandSource -> (CommandSender) serverCommandSource, CommandExecutionCoordinator.simpleCoordinator(),
commandSender -> (ServerCommandSource) commandSender serverCommandSource -> (CommandSender) serverCommandSource,
); commandSender -> (ServerCommandSource) commandSender
);
manager.brigadierManager().setNativeNumberSuggestions(false);
manager.brigadierManager().setNativeNumberSuggestions(false);
platform.getEventManager().callEvent(new CommandRegistrationEvent(manager));
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; package com.dfsek.terra.lifecycle.util;
import com.dfsek.terra.mod.util.MinecraftUtil;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
@@ -12,6 +14,7 @@ public final class RegistryUtil {
} }
public static void register() { public static void register() {
MinecraftUtil.registerIntProviderTypes();
Registry.register(Registry.CHUNK_GENERATOR, new Identifier("terra:terra"), Codecs.MINECRAFT_CHUNK_GENERATOR_WRAPPER); 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); Registry.register(Registry.BIOME_SOURCE, new Identifier("terra:terra"), Codecs.TERRA_BIOME_SOURCE);
} }
+10 -14
View File
@@ -1,7 +1,7 @@
plugins { plugins {
id("dev.architectury.loom") version Versions.Mod.architecuryLoom alias(libs.plugins.mod.architectury.loom)
id("architectury-plugin") version Versions.Mod.architecturyPlugin alias(libs.plugins.mod.architectury.plugin)
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower alias(libs.plugins.mod.loom.quiltflower)
} }
architectury { architectury {
@@ -12,9 +12,6 @@ architectury {
dependencies { dependencies {
shadedApi(project(":common:implementation:base")) 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 } implementation(project(path = ":platforms:mixin-common", configuration = "namedElements")) { isTransitive = false }
"developmentQuilt"(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 } 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 } "developmentQuilt"(project(path = ":platforms:mixin-lifecycle", configuration = "namedElements")) { isTransitive = false }
shaded(project(path = ":platforms:mixin-lifecycle", configuration = "transformProductionQuilt")) { isTransitive = false } shaded(project(path = ":platforms:mixin-lifecycle", configuration = "transformProductionQuilt")) { isTransitive = false }
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}") minecraft(libs.mod.minecraft)
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2") 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(libs.mod.cloud.fabric) {
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud) {
exclude("net.fabricmc") exclude("net.fabricmc")
exclude("net.fabricmc.fabric-api") exclude("net.fabricmc.fabric-api")
} }
include("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud) { include(libs.mod.cloud.fabric) {
exclude("net.fabricmc") exclude("net.fabricmc")
exclude("net.fabricmc.fabric-api") exclude("net.fabricmc.fabric-api")
} }
modLocalRuntime("com.github.astei:lazydfu:${Versions.Mod.lazyDfu}") { modLocalRuntime(libs.mod.lazy.dfu) {
exclude("net.fabricmc") exclude("net.fabricmc")
exclude("net.fabricmc.fabric-api") exclude("net.fabricmc.fabric-api")
} }
+4
View File
@@ -24,6 +24,7 @@ include(":platforms:bukkit:common")
pluginManagement { pluginManagement {
repositories { repositories {
mavenCentral()
gradlePluginPortal() gradlePluginPortal()
maven("https://maven.fabricmc.net") { maven("https://maven.fabricmc.net") {
name = "Fabric Maven" name = "Fabric Maven"
@@ -37,5 +38,8 @@ pluginManagement {
maven("https://maven.quiltmc.org/repository/release/") { maven("https://maven.quiltmc.org/repository/release/") {
name = "Quilt" name = "Quilt"
} }
maven("https://papermc.io/repo/repository/maven-public/") {
name = "PaperMC"
}
} }
} }