mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 13:30:10 +00:00
Merge branch 'ver/6.4.0' into dev/terrascript-2
This commit is contained in:
commit
77dbe92ef7
83 files changed
+1905
-537
No files matched your search
@@ -47,14 +47,7 @@ JARs are produced in `platforms/<platform>/build/libs`.
|
|||||||
To run Minecraft with Terra in the IDE (for testing) use the following tasks:
|
To run Minecraft with Terra in the IDE (for testing) use the following tasks:
|
||||||
|
|
||||||
* Bukkit
|
* Bukkit
|
||||||
* `installPaper` - Install a [Paper](https://github.com/PaperMC/Paper) test
|
* `runServer` - Run the Paper test server with Terra installed.
|
||||||
server. (Only needs to be run once).
|
|
||||||
* `installPurpur` - Install a [Purpur](https://github.com/pl3xgaming/Purpur)
|
|
||||||
test server. (Only needs to be run once).
|
|
||||||
* `runPaper` - Run the Paper test server with Terra (`installPaper` must
|
|
||||||
have been run previously).
|
|
||||||
* `runPurpur` - Run the Purpur test server with Terra (`installPurpur` must
|
|
||||||
have been run previously).
|
|
||||||
* Fabric
|
* Fabric
|
||||||
* `runClient` - Run a Minecraft Fabric client with Terra installed.
|
* `runClient` - Run a Minecraft Fabric client with Terra installed.
|
||||||
* `runServer` - Run a Minecraft Fabric server with Terra installed.
|
* `runServer` - Run a Minecraft Fabric server with Terra installed.
|
||||||
|
|||||||
@@ -3,15 +3,6 @@ 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()
|
||||||
@@ -24,11 +15,12 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:+")
|
//TODO Allow pulling from Versions.kt
|
||||||
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.3.5")
|
implementation("com.github.johnrengelman", "shadow", "8.1.1")
|
||||||
|
implementation("io.papermc.paperweight.userdev", "io.papermc.paperweight.userdev.gradle.plugin","1.5.6")
|
||||||
|
|
||||||
implementation("org.ow2.asm:asm:9.3")
|
implementation("org.ow2.asm", "asm", "9.5")
|
||||||
implementation("org.ow2.asm:asm-tree:9.3")
|
implementation("org.ow2.asm", "asm-tree", "9.5")
|
||||||
implementation("com.dfsek.tectonic:common:4.2.0")
|
implementation("com.dfsek.tectonic", "common", "4.2.0")
|
||||||
implementation("org.yaml:snakeyaml:1.27")
|
implementation("org.yaml", "snakeyaml", "2.2")
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,9 @@ fun Project.configureDependencies() {
|
|||||||
maven("https://jitpack.io") {
|
maven("https://jitpack.io") {
|
||||||
name = "JitPack"
|
name = "JitPack"
|
||||||
}
|
}
|
||||||
|
maven("https://nexuslite.gcnt.net/repos/other/") {
|
||||||
|
name = "GCNT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@@ -1,68 +1,71 @@
|
|||||||
object Versions {
|
object Versions {
|
||||||
object Libraries {
|
object Libraries {
|
||||||
const val tectonic = "4.2.0"
|
const val tectonic = "4.2.1"
|
||||||
const val paralithic = "0.7.0"
|
const val paralithic = "0.7.1"
|
||||||
const val strata = "1.1.1"
|
const val strata = "1.3.2"
|
||||||
|
|
||||||
const val cloud = "1.8.0"
|
const val cloud = "1.8.4"
|
||||||
|
|
||||||
const val slf4j = "1.7.36"
|
const val slf4j = "2.0.9"
|
||||||
const val log4j_slf4j_impl = "2.14.1"
|
const val log4j_slf4j_impl = "2.20.0"
|
||||||
|
|
||||||
object Internal {
|
object Internal {
|
||||||
const val apacheText = "1.9"
|
const val shadow = "8.1.1"
|
||||||
|
const val apacheText = "1.10.0"
|
||||||
const val jafama = "2.3.2"
|
const val jafama = "2.3.2"
|
||||||
const val apacheIO = "2.6"
|
const val apacheIO = "2.14.0"
|
||||||
const val fastutil = "8.5.6"
|
const val guava = "32.1.3-jre"
|
||||||
|
const val asm = "9.5"
|
||||||
|
const val snakeYml = "2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object Fabric {
|
object Fabric {
|
||||||
const val fabricLoader = "0.14.8"
|
const val fabricAPI = "0.90.0+${Mod.minecraft}"
|
||||||
const val fabricAPI = "0.83.1+1.20.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
object Quilt {
|
|
||||||
const val quiltLoader = "0.17.0"
|
|
||||||
const val fabricApi = "6.0.0-beta.3+0.76.0-1.19.4"
|
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// object Quilt {
|
||||||
|
// const val quiltLoader = "0.20.2"
|
||||||
|
// const val fabricApi = "7.3.1+0.89.3-1.20.1"
|
||||||
|
// }
|
||||||
|
|
||||||
object Mod {
|
object Mod {
|
||||||
const val mixin = "0.11.2+mixin.0.8.5"
|
const val mixin = "0.12.5+mixin.0.8.5"
|
||||||
|
|
||||||
const val minecraft = "1.20.1"
|
const val minecraft = "1.20.2"
|
||||||
const val yarn = "$minecraft+build.2"
|
const val yarn = "$minecraft+build.4"
|
||||||
const val fabricLoader = "0.14.21"
|
const val fabricLoader = "0.14.23"
|
||||||
|
|
||||||
const val architecuryLoom = "0.12.0.290"
|
const val architecuryLoom = "1.3.357"
|
||||||
const val architecturyPlugin = "3.4-SNAPSHOT"
|
const val architecturyPlugin = "3.4.146"
|
||||||
|
|
||||||
const val loomQuiltflower = "1.7.1"
|
const val loomVineflower = "1.11.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
object Forge {
|
object Forge {
|
||||||
const val forge = "${Mod.minecraft}-47.0.3"
|
const val forge = "${Mod.minecraft}-48.0.13"
|
||||||
const val burningwave = "12.53.0"
|
const val burningwave = "12.63.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
object Bukkit {
|
object Bukkit {
|
||||||
const val paper = "1.18.2-R0.1-SNAPSHOT"
|
const val paper = "1.18.2-R0.1-SNAPSHOT"
|
||||||
const val paperLib = "1.0.5"
|
const val paperLib = "1.0.5"
|
||||||
const val minecraft = "1.20.1"
|
const val foliaLib = "0.2.5"
|
||||||
|
const val minecraft = "1.20.2"
|
||||||
const val reflectionRemapper = "0.1.0-SNAPSHOT"
|
const val reflectionRemapper = "0.1.0-SNAPSHOT"
|
||||||
const val paperDevBundle = "1.20.1-R0.1-SNAPSHOT"
|
const val paperDevBundle = "1.20.2-R0.1-SNAPSHOT"
|
||||||
|
const val runPaper = "2.2.0"
|
||||||
|
const val paperWeight = "1.5.6"
|
||||||
}
|
}
|
||||||
|
//
|
||||||
object Sponge {
|
// object Sponge {
|
||||||
const val sponge = "9.0.0-SNAPSHOT"
|
// const val sponge = "9.0.0-SNAPSHOT"
|
||||||
const val mixin = "0.8.2"
|
// const val mixin = "0.8.2"
|
||||||
const val minecraft = "1.17.1"
|
// const val minecraft = "1.17.1"
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
object CLI {
|
object CLI {
|
||||||
const val nbt = "6.1"
|
const val nbt = "6.1"
|
||||||
const val logback = "1.2.9"
|
const val logback = "1.4.11"
|
||||||
const val commonsIO = "2.7"
|
|
||||||
const val guava = "31.0.1-jre"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -50,6 +50,7 @@ public class ImageBiomeProviderAddon implements AddonInitializer {
|
|||||||
() -> new ImageProviderTemplate(event.getPack().getRegistry(Biome.class)));
|
() -> new ImageProviderTemplate(event.getPack().getRegistry(Biome.class)));
|
||||||
})
|
})
|
||||||
.failThrough();
|
.failThrough();
|
||||||
logger.warn("The biome-provider-image addon is deprecated and scheduled for removal in Terra 7.0. It is recommended to use the biome-provider-image-v2 addon for future pack development instead.");
|
if(platform.getTerraConfig().isDebugLog())
|
||||||
|
logger.warn("The biome-provider-image addon is deprecated and scheduled for removal in Terra 7.0. It is recommended to use the biome-provider-image-v2 addon for future pack development instead.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-1
@@ -90,6 +90,7 @@ public class BiomePipelineAddon implements AddonInitializer {
|
|||||||
event.getPack().applyLoader(BiomeDelegate.class, new BiomeDelegateLoader(biomeRegistry));
|
event.getPack().applyLoader(BiomeDelegate.class, new BiomeDelegateLoader(biomeRegistry));
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.warn("The biome-provider-pipeline addon is deprecated and scheduled for removal in Terra 7.0. It is recommended to use the biome-provider-pipeline-v2 addon for future pack development instead.");
|
if(platform.getTerraConfig().isDebugLog())
|
||||||
|
logger.warn("The biome-provider-pipeline addon is deprecated and scheduled for removal in Terra 7.0. It is recommended to use the biome-provider-pipeline-v2 addon for future pack development instead.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
version = version("1.1.0")
|
version = version("1.2.0")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||||
|
|||||||
+10
@@ -155,6 +155,16 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
|||||||
return biomeProvider.getBiome(x, y, z, world.getSeed()).getContext().get(paletteInfoPropertyKey).paletteHolder().getPalette(y);
|
return biomeProvider.getBiome(x, y, z, world.getSeed()).getContext().get(paletteInfoPropertyKey).paletteHolder().getPalette(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getSlant(int x, int y, int z, WorldProperties world, BiomeProvider biomeProvider) {
|
||||||
|
int fdX = FastMath.floorMod(x, 16);
|
||||||
|
int fdZ = FastMath.floorMod(z, 16);
|
||||||
|
return biomeProvider.getBiome(x, y, z, world.getSeed())
|
||||||
|
.getContext()
|
||||||
|
.get(paletteInfoPropertyKey)
|
||||||
|
.slantHolder()
|
||||||
|
.calculateSlant(samplerCache.get(x, z, world, biomeProvider), fdX, y, fdZ);
|
||||||
|
}
|
||||||
|
|
||||||
public SamplerProvider samplerProvider() {
|
public SamplerProvider samplerProvider() {
|
||||||
return samplerCache;
|
return samplerCache;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ public class TopLocator implements Locator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||||
for(int y : search) {
|
for(int y = search.getMax(); y >= search.getMin(); y--) {
|
||||||
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
if(column.getBlock(y).isAir() && !column.getBlock(y - 1).isAir()) {
|
||||||
return new BinaryColumn(y, y + 1, yi -> true);
|
return new BinaryColumn(y, y + 1, yi -> true);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -14,6 +14,7 @@ import java.util.Map;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
|
import com.dfsek.terra.addons.noise.config.CubicSplinePointTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.DimensionApplicableNoiseSampler;
|
import com.dfsek.terra.addons.noise.config.DimensionApplicableNoiseSampler;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.BinaryArithmeticTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.BinaryArithmeticTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.DomainWarpTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.DomainWarpTemplate;
|
||||||
@@ -32,12 +33,14 @@ import com.dfsek.terra.addons.noise.config.templates.noise.fractal.BrownianMotio
|
|||||||
import com.dfsek.terra.addons.noise.config.templates.noise.fractal.PingPongTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.noise.fractal.PingPongTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.noise.fractal.RidgedFractalTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.noise.fractal.RidgedFractalTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ClampNormalizerTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.normalizer.ClampNormalizerTemplate;
|
||||||
|
import com.dfsek.terra.addons.noise.config.templates.normalizer.CubicSplineNormalizerTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ExpressionNormalizerTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.normalizer.ExpressionNormalizerTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearNormalizerTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearNormalizerTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.NormalNormalizerTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.normalizer.NormalNormalizerTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.PosterizationNormalizerTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.normalizer.PosterizationNormalizerTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ProbabilityNormalizerTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.normalizer.ProbabilityNormalizerTemplate;
|
||||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ScaleNormalizerTemplate;
|
import com.dfsek.terra.addons.noise.config.templates.normalizer.ScaleNormalizerTemplate;
|
||||||
|
import com.dfsek.terra.addons.noise.math.CubicSpline;
|
||||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.AdditionSampler;
|
import com.dfsek.terra.addons.noise.samplers.arithmetic.AdditionSampler;
|
||||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.DivisionSampler;
|
import com.dfsek.terra.addons.noise.samplers.arithmetic.DivisionSampler;
|
||||||
import com.dfsek.terra.addons.noise.samplers.arithmetic.MaxSampler;
|
import com.dfsek.terra.addons.noise.samplers.arithmetic.MaxSampler;
|
||||||
@@ -90,7 +93,8 @@ public class NoiseAddon implements AddonInitializer {
|
|||||||
.applyLoader(DistanceSampler.DistanceFunction.class,
|
.applyLoader(DistanceSampler.DistanceFunction.class,
|
||||||
(type, o, loader, depthTracker) -> DistanceSampler.DistanceFunction.valueOf((String) o))
|
(type, o, loader, depthTracker) -> DistanceSampler.DistanceFunction.valueOf((String) o))
|
||||||
.applyLoader(DimensionApplicableNoiseSampler.class, DimensionApplicableNoiseSampler::new)
|
.applyLoader(DimensionApplicableNoiseSampler.class, DimensionApplicableNoiseSampler::new)
|
||||||
.applyLoader(FunctionTemplate.class, FunctionTemplate::new);
|
.applyLoader(FunctionTemplate.class, FunctionTemplate::new)
|
||||||
|
.applyLoader(CubicSpline.Point.class, CubicSplinePointTemplate::new);
|
||||||
|
|
||||||
noiseRegistry.register(addon.key("LINEAR"), LinearNormalizerTemplate::new);
|
noiseRegistry.register(addon.key("LINEAR"), LinearNormalizerTemplate::new);
|
||||||
noiseRegistry.register(addon.key("NORMAL"), NormalNormalizerTemplate::new);
|
noiseRegistry.register(addon.key("NORMAL"), NormalNormalizerTemplate::new);
|
||||||
@@ -98,6 +102,7 @@ public class NoiseAddon implements AddonInitializer {
|
|||||||
noiseRegistry.register(addon.key("PROBABILITY"), ProbabilityNormalizerTemplate::new);
|
noiseRegistry.register(addon.key("PROBABILITY"), ProbabilityNormalizerTemplate::new);
|
||||||
noiseRegistry.register(addon.key("SCALE"), ScaleNormalizerTemplate::new);
|
noiseRegistry.register(addon.key("SCALE"), ScaleNormalizerTemplate::new);
|
||||||
noiseRegistry.register(addon.key("POSTERIZATION"), PosterizationNormalizerTemplate::new);
|
noiseRegistry.register(addon.key("POSTERIZATION"), PosterizationNormalizerTemplate::new);
|
||||||
|
noiseRegistry.register(addon.key("CUBIC_SPLINE"), CubicSplineNormalizerTemplate::new);
|
||||||
|
|
||||||
noiseRegistry.register(addon.key("IMAGE"), ImageSamplerTemplate::new);
|
noiseRegistry.register(addon.key("IMAGE"), ImageSamplerTemplate::new);
|
||||||
|
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.dfsek.terra.addons.noise.config;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.noise.math.CubicSpline.Point;
|
||||||
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
|
|
||||||
|
|
||||||
|
public class CubicSplinePointTemplate implements ObjectTemplate<Point> {
|
||||||
|
|
||||||
|
@Value("from")
|
||||||
|
private @Meta double from;
|
||||||
|
|
||||||
|
@Value("to")
|
||||||
|
private @Meta double to;
|
||||||
|
|
||||||
|
@Value("gradient")
|
||||||
|
private @Meta double gradient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Point get() {
|
||||||
|
return new Point(from, to, gradient);
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package com.dfsek.terra.addons.noise.config.templates.normalizer;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.noise.math.CubicSpline;
|
||||||
|
import com.dfsek.terra.addons.noise.math.CubicSpline.Point;
|
||||||
|
import com.dfsek.terra.addons.noise.normalizer.CubicSplineNoiseSampler;
|
||||||
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class CubicSplineNormalizerTemplate extends NormalizerTemplate<CubicSplineNoiseSampler> {
|
||||||
|
|
||||||
|
@Value("points")
|
||||||
|
private @Meta List<@Meta Point> points;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NoiseSampler get() {
|
||||||
|
return new CubicSplineNoiseSampler(function, new CubicSpline(points));
|
||||||
|
}
|
||||||
|
}
|
||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
package com.dfsek.terra.addons.noise.math;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class CubicSpline {
|
||||||
|
|
||||||
|
private final double[] fromValues;
|
||||||
|
private final double[] toValues;
|
||||||
|
private final double[] gradients;
|
||||||
|
|
||||||
|
public CubicSpline(List<Point> points) {
|
||||||
|
Collections.sort(points);
|
||||||
|
|
||||||
|
this.fromValues = new double[points.size()];
|
||||||
|
this.toValues = new double[points.size()];
|
||||||
|
this.gradients = new double[points.size()];
|
||||||
|
|
||||||
|
for(int i = 0; i < points.size(); i++) {
|
||||||
|
fromValues[i] = points.get(i).from;
|
||||||
|
toValues[i] = points.get(i).to;
|
||||||
|
gradients[i] = points.get(i).gradient;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double apply(double in) {
|
||||||
|
return calculate(in, fromValues, toValues, gradients);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double calculate(double in, double[] fromValues, double[] toValues, double[] gradients) {
|
||||||
|
int pointIdx = floorBinarySearch(in, fromValues) - 1;
|
||||||
|
|
||||||
|
int pointIdxLast = fromValues.length - 1;
|
||||||
|
|
||||||
|
if (pointIdx < 0) { // If to left of first point return linear function intersecting said point using point's gradient
|
||||||
|
return gradients[0] * (in - fromValues[0]) + toValues[0];
|
||||||
|
} else if (pointIdx == pointIdxLast) { // Do same if to right of last point
|
||||||
|
return gradients[pointIdxLast] * (in - fromValues[pointIdxLast]) + toValues[pointIdxLast];
|
||||||
|
} else {
|
||||||
|
double fromLeft = fromValues[pointIdx];
|
||||||
|
double fromRight = fromValues[pointIdx + 1];
|
||||||
|
|
||||||
|
double toLeft = toValues[pointIdx];
|
||||||
|
double toRight = toValues[pointIdx + 1];
|
||||||
|
|
||||||
|
double gradientLeft = gradients[pointIdx];
|
||||||
|
double gradientRight = gradients[pointIdx + 1];
|
||||||
|
|
||||||
|
double fromDelta = fromRight - fromLeft;
|
||||||
|
double toDelta = toRight - toLeft;
|
||||||
|
|
||||||
|
double t = (in - fromLeft) / fromDelta;
|
||||||
|
|
||||||
|
return lerp(t, toLeft, toRight) + t * (1.0F - t) * lerp(t, gradientLeft * fromDelta - toDelta, -gradientRight * fromDelta + toDelta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int floorBinarySearch(double targetValue, double[] values) {
|
||||||
|
int left = 0;
|
||||||
|
int right = values.length;
|
||||||
|
int idx = right - left;
|
||||||
|
while (idx > 0) {
|
||||||
|
int halfDelta = idx / 2;
|
||||||
|
int mid = left + halfDelta;
|
||||||
|
if (targetValue < values[mid]) {
|
||||||
|
idx = halfDelta;
|
||||||
|
} else {
|
||||||
|
left = mid + 1;
|
||||||
|
idx -= halfDelta + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double lerp(double t, double a, double b) {
|
||||||
|
return a + t * (b - a);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record Point(double from, double to, double gradient) implements Comparable<Point> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(@NotNull CubicSpline.Point o) {
|
||||||
|
return Double.compare(from, o.from);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package com.dfsek.terra.addons.noise.normalizer;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.noise.math.CubicSpline;
|
||||||
|
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||||
|
|
||||||
|
|
||||||
|
public class CubicSplineNoiseSampler extends Normalizer {
|
||||||
|
|
||||||
|
private final CubicSpline spline;
|
||||||
|
|
||||||
|
public CubicSplineNoiseSampler(NoiseSampler sampler, CubicSpline spline) {
|
||||||
|
super(sampler);
|
||||||
|
this.spline = spline;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double normalize(double in) {
|
||||||
|
return spline.apply(in);
|
||||||
|
}
|
||||||
|
}
|
||||||
+62
-194
@@ -240,99 +240,37 @@ public class CellularSampler extends NoiseFunction {
|
|||||||
double centerX = x;
|
double centerX = x;
|
||||||
double centerY = y;
|
double centerY = y;
|
||||||
|
|
||||||
switch(distanceFunction) {
|
for(int xi = xr - 1; xi <= xr + 1; xi++) {
|
||||||
default:
|
int yPrimed = yPrimedBase;
|
||||||
case Euclidean:
|
|
||||||
case EuclideanSq:
|
|
||||||
for(int xi = xr - 1; xi <= xr + 1; xi++) {
|
|
||||||
int yPrimed = yPrimedBase;
|
|
||||||
|
|
||||||
for(int yi = yr - 1; yi <= yr + 1; yi++) {
|
for(int yi = yr - 1; yi <= yr + 1; yi++) {
|
||||||
int hash = hash(seed, xPrimed, yPrimed);
|
int hash = hash(seed, xPrimed, yPrimed);
|
||||||
int idx = hash & (255 << 1);
|
int idx = hash & (255 << 1);
|
||||||
|
|
||||||
double vecX = (xi - x) + RAND_VECS_2D[idx] * cellularJitter;
|
double vecX = (xi - x) + RAND_VECS_2D[idx] * cellularJitter;
|
||||||
double vecY = (yi - y) + RAND_VECS_2D[idx | 1] * cellularJitter;
|
double vecY = (yi - y) + RAND_VECS_2D[idx | 1] * cellularJitter;
|
||||||
|
|
||||||
double newDistance = vecX * vecX + vecY * vecY;
|
double newDistance = switch(distanceFunction) {
|
||||||
|
case Manhattan -> fastAbs(vecX) + fastAbs(vecY);
|
||||||
|
case Hybrid -> (fastAbs(vecX) + fastAbs(vecY)) + (vecX * vecX + vecY * vecY);
|
||||||
|
default -> vecX * vecX + vecY * vecY;
|
||||||
|
};
|
||||||
|
|
||||||
distance1 = fastMax(fastMin(distance1, newDistance), distance0);
|
distance1 = fastMax(fastMin(distance1, newDistance), distance0);
|
||||||
if(newDistance < distance0) {
|
if(newDistance < distance0) {
|
||||||
distance0 = newDistance;
|
distance0 = newDistance;
|
||||||
closestHash = hash;
|
closestHash = hash;
|
||||||
centerX = ((xi + RAND_VECS_2D[idx] * cellularJitter) / frequency);
|
centerX = ((xi + RAND_VECS_2D[idx] * cellularJitter) / frequency);
|
||||||
centerY = ((yi + RAND_VECS_2D[idx | 1] * cellularJitter) / frequency);
|
centerY = ((yi + RAND_VECS_2D[idx | 1] * cellularJitter) / frequency);
|
||||||
} else if(newDistance < distance1) {
|
} else if(newDistance < distance1) {
|
||||||
distance2 = distance1;
|
distance2 = distance1;
|
||||||
distance1 = newDistance;
|
distance1 = newDistance;
|
||||||
} else if(newDistance < distance2) {
|
} else if(newDistance < distance2) {
|
||||||
distance2 = newDistance;
|
distance2 = newDistance;
|
||||||
}
|
|
||||||
yPrimed += PRIME_Y;
|
|
||||||
}
|
|
||||||
xPrimed += PRIME_X;
|
|
||||||
}
|
}
|
||||||
break;
|
yPrimed += PRIME_Y;
|
||||||
case Manhattan:
|
}
|
||||||
for(int xi = xr - 1; xi <= xr + 1; xi++) {
|
xPrimed += PRIME_X;
|
||||||
int yPrimed = yPrimedBase;
|
|
||||||
|
|
||||||
for(int yi = yr - 1; yi <= yr + 1; yi++) {
|
|
||||||
int hash = hash(seed, xPrimed, yPrimed);
|
|
||||||
int idx = hash & (255 << 1);
|
|
||||||
|
|
||||||
double vecX = (xi - x) + RAND_VECS_2D[idx] * cellularJitter;
|
|
||||||
double vecY = (yi - y) + RAND_VECS_2D[idx | 1] * cellularJitter;
|
|
||||||
|
|
||||||
double newDistance = fastAbs(vecX) + fastAbs(vecY);
|
|
||||||
|
|
||||||
distance1 = fastMax(fastMin(distance1, newDistance), distance0);
|
|
||||||
if(newDistance < distance0) {
|
|
||||||
distance0 = newDistance;
|
|
||||||
closestHash = hash;
|
|
||||||
centerX = ((xi + RAND_VECS_2D[idx] * cellularJitter) / frequency);
|
|
||||||
centerY = ((yi + RAND_VECS_2D[idx | 1] * cellularJitter) / frequency);
|
|
||||||
} else if(newDistance < distance1) {
|
|
||||||
distance2 = distance1;
|
|
||||||
distance1 = newDistance;
|
|
||||||
} else if(newDistance < distance2) {
|
|
||||||
distance2 = newDistance;
|
|
||||||
}
|
|
||||||
yPrimed += PRIME_Y;
|
|
||||||
}
|
|
||||||
xPrimed += PRIME_X;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Hybrid:
|
|
||||||
for(int xi = xr - 1; xi <= xr + 1; xi++) {
|
|
||||||
int yPrimed = yPrimedBase;
|
|
||||||
|
|
||||||
for(int yi = yr - 1; yi <= yr + 1; yi++) {
|
|
||||||
int hash = hash(seed, xPrimed, yPrimed);
|
|
||||||
int idx = hash & (255 << 1);
|
|
||||||
|
|
||||||
double vecX = (xi - x) + RAND_VECS_2D[idx] * cellularJitter;
|
|
||||||
double vecY = (yi - y) + RAND_VECS_2D[idx | 1] * cellularJitter;
|
|
||||||
|
|
||||||
double newDistance = (fastAbs(vecX) + fastAbs(vecY)) + (vecX * vecX + vecY * vecY);
|
|
||||||
|
|
||||||
distance1 = fastMax(fastMin(distance1, newDistance), distance0);
|
|
||||||
if(newDistance < distance0) {
|
|
||||||
distance0 = newDistance;
|
|
||||||
closestHash = hash;
|
|
||||||
centerX = ((xi + RAND_VECS_2D[idx] * cellularJitter) / frequency);
|
|
||||||
centerY = ((yi + RAND_VECS_2D[idx | 1] * cellularJitter) / frequency);
|
|
||||||
} else if(newDistance < distance1) {
|
|
||||||
distance2 = distance1;
|
|
||||||
distance1 = newDistance;
|
|
||||||
} else if(newDistance < distance2) {
|
|
||||||
distance2 = newDistance;
|
|
||||||
}
|
|
||||||
yPrimed += PRIME_Y;
|
|
||||||
}
|
|
||||||
xPrimed += PRIME_X;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(distanceFunction == DistanceFunction.Euclidean && returnType != ReturnType.CellValue) {
|
if(distanceFunction == DistanceFunction.Euclidean && returnType != ReturnType.CellValue) {
|
||||||
@@ -351,6 +289,7 @@ public class CellularSampler extends NoiseFunction {
|
|||||||
case Distance2Mul -> distance1 * distance0 * 0.5 - 1;
|
case Distance2Mul -> distance1 * distance0 * 0.5 - 1;
|
||||||
case Distance2Div -> distance0 / distance1 - 1;
|
case Distance2Div -> distance0 / distance1 - 1;
|
||||||
case NoiseLookup -> noiseLookup.noise(sl, centerX, centerY);
|
case NoiseLookup -> noiseLookup.noise(sl, centerX, centerY);
|
||||||
|
case LocalNoiseLookup -> noiseLookup.noise(sl, x / frequency - centerX, y / frequency - centerY);
|
||||||
case Distance3 -> distance2 - 1;
|
case Distance3 -> distance2 - 1;
|
||||||
case Distance3Add -> (distance2 + distance0) * 0.5 - 1;
|
case Distance3Add -> (distance2 + distance0) * 0.5 - 1;
|
||||||
case Distance3Sub -> distance2 - distance0 - 1;
|
case Distance3Sub -> distance2 - distance0 - 1;
|
||||||
@@ -382,120 +321,47 @@ public class CellularSampler extends NoiseFunction {
|
|||||||
double centerY = y;
|
double centerY = y;
|
||||||
double centerZ = z;
|
double centerZ = z;
|
||||||
|
|
||||||
switch(distanceFunction) {
|
for(int xi = xr - 1; xi <= xr + 1; xi++) {
|
||||||
case Euclidean:
|
int yPrimed = yPrimedBase;
|
||||||
case EuclideanSq:
|
|
||||||
for(int xi = xr - 1; xi <= xr + 1; xi++) {
|
|
||||||
int yPrimed = yPrimedBase;
|
|
||||||
|
|
||||||
for(int yi = yr - 1; yi <= yr + 1; yi++) {
|
for(int yi = yr - 1; yi <= yr + 1; yi++) {
|
||||||
int zPrimed = zPrimedBase;
|
int zPrimed = zPrimedBase;
|
||||||
|
|
||||||
for(int zi = zr - 1; zi <= zr + 1; zi++) {
|
for(int zi = zr - 1; zi <= zr + 1; zi++) {
|
||||||
int hash = hash(seed, xPrimed, yPrimed, zPrimed);
|
int hash = hash(seed, xPrimed, yPrimed, zPrimed);
|
||||||
int idx = hash & (255 << 2);
|
int idx = hash & (255 << 2);
|
||||||
|
|
||||||
double vecX = (xi - x) + RAND_VECS_3D[idx] * cellularJitter;
|
double vecX = (xi - x) + RAND_VECS_3D[idx] * cellularJitter;
|
||||||
double vecY = (yi - y) + RAND_VECS_3D[idx | 1] * cellularJitter;
|
double vecY = (yi - y) + RAND_VECS_3D[idx | 1] * cellularJitter;
|
||||||
double vecZ = (zi - z) + RAND_VECS_3D[idx | 2] * cellularJitter;
|
double vecZ = (zi - z) + RAND_VECS_3D[idx | 2] * cellularJitter;
|
||||||
|
|
||||||
double newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ;
|
|
||||||
|
|
||||||
if(newDistance < distance0) {
|
|
||||||
distance0 = newDistance;
|
|
||||||
closestHash = hash;
|
|
||||||
centerX = ((xi + RAND_VECS_3D[idx] * cellularJitter) / frequency);
|
|
||||||
centerY = ((yi + RAND_VECS_3D[idx | 1] * cellularJitter) / frequency);
|
|
||||||
centerZ = ((zi + RAND_VECS_3D[idx | 2] * cellularJitter) / frequency);
|
|
||||||
} else if(newDistance < distance1) {
|
|
||||||
distance2 = distance1;
|
|
||||||
distance1 = newDistance;
|
|
||||||
} else if(newDistance < distance2) {
|
|
||||||
distance2 = newDistance;
|
|
||||||
}
|
|
||||||
zPrimed += PRIME_Z;
|
|
||||||
}
|
|
||||||
yPrimed += PRIME_Y;
|
|
||||||
}
|
|
||||||
xPrimed += PRIME_X;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Manhattan:
|
|
||||||
for(int xi = xr - 1; xi <= xr + 1; xi++) {
|
|
||||||
int yPrimed = yPrimedBase;
|
|
||||||
|
|
||||||
for(int yi = yr - 1; yi <= yr + 1; yi++) {
|
|
||||||
int zPrimed = zPrimedBase;
|
|
||||||
|
|
||||||
for(int zi = zr - 1; zi <= zr + 1; zi++) {
|
|
||||||
int hash = hash(seed, xPrimed, yPrimed, zPrimed);
|
|
||||||
int idx = hash & (255 << 2);
|
|
||||||
|
|
||||||
double vecX = (xi - x) + RAND_VECS_3D[idx] * cellularJitter;
|
|
||||||
double vecY = (yi - y) + RAND_VECS_3D[idx | 1] * cellularJitter;
|
|
||||||
double vecZ = (zi - z) + RAND_VECS_3D[idx | 2] * cellularJitter;
|
|
||||||
|
|
||||||
double newDistance = fastAbs(vecX) + fastAbs(vecY) + fastAbs(vecZ);
|
|
||||||
|
|
||||||
if(newDistance < distance0) {
|
|
||||||
distance0 = newDistance;
|
|
||||||
closestHash = hash;
|
|
||||||
centerX = ((xi + RAND_VECS_3D[idx] * cellularJitter) / frequency);
|
|
||||||
centerY = ((yi + RAND_VECS_3D[idx | 1] * cellularJitter) / frequency);
|
|
||||||
centerZ = ((zi + RAND_VECS_3D[idx | 2] * cellularJitter) / frequency);
|
|
||||||
} else if(newDistance < distance1) {
|
|
||||||
distance2 = distance1;
|
|
||||||
distance1 = newDistance;
|
|
||||||
} else if(newDistance < distance2) {
|
|
||||||
distance2 = newDistance;
|
|
||||||
}
|
|
||||||
zPrimed += PRIME_Z;
|
|
||||||
}
|
|
||||||
yPrimed += PRIME_Y;
|
|
||||||
}
|
|
||||||
xPrimed += PRIME_X;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Hybrid:
|
|
||||||
for(int xi = xr - 1; xi <= xr + 1; xi++) {
|
|
||||||
int yPrimed = yPrimedBase;
|
|
||||||
|
|
||||||
for(int yi = yr - 1; yi <= yr + 1; yi++) {
|
|
||||||
int zPrimed = zPrimedBase;
|
|
||||||
|
|
||||||
for(int zi = zr - 1; zi <= zr + 1; zi++) {
|
|
||||||
int hash = hash(seed, xPrimed, yPrimed, zPrimed);
|
|
||||||
int idx = hash & (255 << 2);
|
|
||||||
|
|
||||||
double vecX = (xi - x) + RAND_VECS_3D[idx] * cellularJitter;
|
|
||||||
double vecY = (yi - y) + RAND_VECS_3D[idx | 1] * cellularJitter;
|
|
||||||
double vecZ = (zi - z) + RAND_VECS_3D[idx | 2] * cellularJitter;
|
|
||||||
|
|
||||||
double newDistance = (fastAbs(vecX) + fastAbs(vecY) + fastAbs(vecZ)) +
|
|
||||||
(vecX * vecX + vecY * vecY + vecZ * vecZ);
|
|
||||||
|
|
||||||
|
double newDistance = 0;
|
||||||
|
switch(distanceFunction) {
|
||||||
|
case Euclidean, EuclideanSq -> newDistance = vecX * vecX + vecY * vecY + vecZ * vecZ;
|
||||||
|
case Manhattan -> newDistance = fastAbs(vecX) + fastAbs(vecY) + fastAbs(vecZ);
|
||||||
|
case Hybrid -> {
|
||||||
|
newDistance = (fastAbs(vecX) + fastAbs(vecY) + fastAbs(vecZ)) + (vecX * vecX + vecY * vecY + vecZ * vecZ);
|
||||||
distance1 = fastMax(fastMin(distance1, newDistance), distance0);
|
distance1 = fastMax(fastMin(distance1, newDistance), distance0);
|
||||||
if(newDistance < distance0) {
|
|
||||||
distance0 = newDistance;
|
|
||||||
closestHash = hash;
|
|
||||||
centerX = ((xi + RAND_VECS_3D[idx] * cellularJitter) / frequency);
|
|
||||||
centerY = ((yi + RAND_VECS_3D[idx | 1] * cellularJitter) / frequency);
|
|
||||||
centerZ = ((zi + RAND_VECS_3D[idx | 2] * cellularJitter) / frequency);
|
|
||||||
} else if(newDistance < distance1) {
|
|
||||||
distance2 = distance1;
|
|
||||||
distance1 = newDistance;
|
|
||||||
} else if(newDistance < distance2) {
|
|
||||||
distance2 = newDistance;
|
|
||||||
}
|
|
||||||
zPrimed += PRIME_Z;
|
|
||||||
}
|
}
|
||||||
yPrimed += PRIME_Y;
|
|
||||||
}
|
}
|
||||||
xPrimed += PRIME_X;
|
|
||||||
|
if(newDistance < distance0) {
|
||||||
|
distance0 = newDistance;
|
||||||
|
closestHash = hash;
|
||||||
|
centerX = ((xi + RAND_VECS_3D[idx] * cellularJitter) / frequency);
|
||||||
|
centerY = ((yi + RAND_VECS_3D[idx | 1] * cellularJitter) / frequency);
|
||||||
|
centerZ = ((zi + RAND_VECS_3D[idx | 2] * cellularJitter) / frequency);
|
||||||
|
} else if(newDistance < distance1) {
|
||||||
|
distance2 = distance1;
|
||||||
|
distance1 = newDistance;
|
||||||
|
} else if(newDistance < distance2) {
|
||||||
|
distance2 = newDistance;
|
||||||
|
}
|
||||||
|
zPrimed += PRIME_Z;
|
||||||
}
|
}
|
||||||
break;
|
yPrimed += PRIME_Y;
|
||||||
default:
|
}
|
||||||
break;
|
xPrimed += PRIME_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(distanceFunction == DistanceFunction.Euclidean && returnType != ReturnType.CellValue) {
|
if(distanceFunction == DistanceFunction.Euclidean && returnType != ReturnType.CellValue) {
|
||||||
@@ -514,6 +380,7 @@ public class CellularSampler extends NoiseFunction {
|
|||||||
case Distance2Mul -> distance1 * distance0 * 0.5 - 1;
|
case Distance2Mul -> distance1 * distance0 * 0.5 - 1;
|
||||||
case Distance2Div -> distance0 / distance1 - 1;
|
case Distance2Div -> distance0 / distance1 - 1;
|
||||||
case NoiseLookup -> noiseLookup.noise(sl, centerX, centerY, centerZ);
|
case NoiseLookup -> noiseLookup.noise(sl, centerX, centerY, centerZ);
|
||||||
|
case LocalNoiseLookup -> noiseLookup.noise(sl, x / frequency - centerX, y / frequency - centerY, z / frequency - centerZ);
|
||||||
case Distance3 -> distance2 - 1;
|
case Distance3 -> distance2 - 1;
|
||||||
case Distance3Add -> (distance2 + distance0) * 0.5 - 1;
|
case Distance3Add -> (distance2 + distance0) * 0.5 - 1;
|
||||||
case Distance3Sub -> distance2 - distance0 - 1;
|
case Distance3Sub -> distance2 - distance0 - 1;
|
||||||
@@ -540,6 +407,7 @@ public class CellularSampler extends NoiseFunction {
|
|||||||
Distance2Mul,
|
Distance2Mul,
|
||||||
Distance2Div,
|
Distance2Div,
|
||||||
NoiseLookup,
|
NoiseLookup,
|
||||||
|
LocalNoiseLookup,
|
||||||
Distance3,
|
Distance3,
|
||||||
Distance3Add,
|
Distance3Add,
|
||||||
Distance3Sub,
|
Distance3Sub,
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
|
version = version("1.0.0")
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||||
|
api("com.dfsek", "paralithic", Versions.Libraries.paralithic)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tasks.named<ShadowJar>("shadowJar") {
|
||||||
|
relocate("com.dfsek.paralithic", "com.dfsek.terra.addons.numberpredicate.lib.paralithic")
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package com.dfsek.terra.addons.numberpredicate;
|
||||||
|
|
||||||
|
import com.dfsek.paralithic.Expression;
|
||||||
|
import com.dfsek.paralithic.eval.parser.Parser;
|
||||||
|
import com.dfsek.paralithic.eval.parser.Scope;
|
||||||
|
import com.dfsek.paralithic.eval.tokenizer.ParseException;
|
||||||
|
import com.dfsek.tectonic.api.depth.DepthTracker;
|
||||||
|
import com.dfsek.tectonic.api.exception.LoadException;
|
||||||
|
import com.dfsek.tectonic.api.loader.ConfigLoader;
|
||||||
|
import com.dfsek.tectonic.api.loader.type.TypeLoader;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.lang.reflect.AnnotatedType;
|
||||||
|
import java.util.function.DoublePredicate;
|
||||||
|
|
||||||
|
|
||||||
|
public class DoublePredicateLoader implements TypeLoader<DoublePredicate> {
|
||||||
|
@Override
|
||||||
|
public DoublePredicate load(@NotNull AnnotatedType annotatedType, @NotNull Object o, @NotNull ConfigLoader configLoader,
|
||||||
|
DepthTracker depthTracker) throws LoadException {
|
||||||
|
if (o instanceof String expressionString) {
|
||||||
|
Scope scope = new Scope();
|
||||||
|
scope.addInvocationVariable("value");
|
||||||
|
try {
|
||||||
|
Expression expression = new Parser().parse(expressionString, scope);
|
||||||
|
return d -> expression.evaluate(d) != 0; // Paralithic expressions treat '!= 0' as true
|
||||||
|
} catch(ParseException e) {
|
||||||
|
throw new LoadException("Failed to parse double predicate expression", e, depthTracker);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new LoadException("Double predicates must be defined as a string. E.g. 'value > 3'", depthTracker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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.numberpredicate;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.DoublePredicate;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
|
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||||
|
|
||||||
|
public class NumberPredicateAddon implements AddonInitializer {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Platform plugin;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BaseAddon addon;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
plugin.getEventManager()
|
||||||
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
|
.then(event -> event.getPack().applyLoader(DoublePredicate.class, new DoublePredicateLoader()))
|
||||||
|
.priority(50)
|
||||||
|
.failThrough();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
schema-version: 1
|
||||||
|
contributors:
|
||||||
|
- Terra contributors
|
||||||
|
id: config-number-predicate
|
||||||
|
version: @VERSION@
|
||||||
|
entrypoints:
|
||||||
|
- "com.dfsek.terra.addons.numberpredicate.NumberPredicateAddon"
|
||||||
|
website:
|
||||||
|
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||||
|
source: https://github.com/PolyhedralDev/Terra
|
||||||
|
docs: https://terra.polydev.org
|
||||||
|
license: MIT License
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020-2021 Polyhedral Development
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# config-ore-v2
|
||||||
|
|
||||||
|
Registers the default configuration for Terra Ores, `ORE`.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
version = version("1.0.0")
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||||
|
implementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||||
|
testImplementation("net.jafama", "jafama", Versions.Libraries.Internal.jafama)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
|
||||||
|
relocate("net.jafama", "com.dfsek.terra.addons.ore.lib.jafama")
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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.ore.v2;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
|
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||||
|
|
||||||
|
|
||||||
|
public class OreAddon implements AddonInitializer {
|
||||||
|
@Inject
|
||||||
|
private Platform platform;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BaseAddon addon;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
platform.getEventManager()
|
||||||
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
|
.then(event -> event.getPack().registerConfigType(new OreConfigType(), addon.key("ORE"), 1))
|
||||||
|
.failThrough();
|
||||||
|
}
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.ore.v2;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.config.ConfigFactory;
|
||||||
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
|
import com.dfsek.terra.api.config.ConfigType;
|
||||||
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
|
||||||
|
public class OreConfigType implements ConfigType<OreTemplate, Structure> {
|
||||||
|
public static final TypeKey<Structure> ORE_TYPE_TOKEN = new TypeKey<>() {
|
||||||
|
};
|
||||||
|
private final OreFactory factory = new OreFactory();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OreTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||||
|
return new OreTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigFactory<OreTemplate, Structure> getFactory() {
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypeKey<Structure> getTypeKey() {
|
||||||
|
return ORE_TYPE_TOKEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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.ore.v2;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.ore.v2.ores.VanillaOre;
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
|
import com.dfsek.terra.api.config.ConfigFactory;
|
||||||
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
|
|
||||||
|
|
||||||
|
public class OreFactory implements ConfigFactory<OreTemplate, Structure> {
|
||||||
|
@Override
|
||||||
|
public VanillaOre build(OreTemplate config, Platform platform) {
|
||||||
|
BlockState m = config.getMaterial();
|
||||||
|
return new VanillaOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.isExposed(),
|
||||||
|
config.getMaterialOverrides());
|
||||||
|
}
|
||||||
|
}
|
||||||
+80
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* 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.ore.v2;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Description;
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Final;
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.block.BlockType;
|
||||||
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
|
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||||
|
import com.dfsek.terra.api.config.meta.Meta;
|
||||||
|
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||||
|
public class OreTemplate implements AbstractableTemplate {
|
||||||
|
@Value("id")
|
||||||
|
@Final
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Value("material")
|
||||||
|
private @Meta BlockState material;
|
||||||
|
|
||||||
|
@Value("material-overrides")
|
||||||
|
@Default
|
||||||
|
private @Meta Map<@Meta BlockType, @Meta BlockState> materials = new HashMap<>();
|
||||||
|
|
||||||
|
@Value("replace")
|
||||||
|
private @Meta MaterialSet replaceable;
|
||||||
|
|
||||||
|
@Value("physics")
|
||||||
|
@Default
|
||||||
|
private @Meta boolean physics = false;
|
||||||
|
|
||||||
|
@Value("size")
|
||||||
|
private @Meta double size;
|
||||||
|
|
||||||
|
@Value("exposed")
|
||||||
|
@Default
|
||||||
|
@Description("The chance that ore blocks bordering air will be discarded as candidates for ore. 0 = 0%, 1 = 100%")
|
||||||
|
private @Meta double exposed = 0.0f;
|
||||||
|
|
||||||
|
public boolean doPhysics() {
|
||||||
|
return physics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getMaterial() {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaterialSet getReplaceable() {
|
||||||
|
return replaceable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<BlockType, BlockState> getMaterialOverrides() {
|
||||||
|
return materials;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double isExposed() {
|
||||||
|
return exposed;
|
||||||
|
}
|
||||||
|
}
|
||||||
+207
@@ -0,0 +1,207 @@
|
|||||||
|
/*
|
||||||
|
* 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.ore.v2.ores;
|
||||||
|
|
||||||
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
|
import java.util.BitSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.block.BlockType;
|
||||||
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
|
import com.dfsek.terra.api.util.Rotation;
|
||||||
|
import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||||
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
|
|
||||||
|
public class VanillaOre implements Structure {
|
||||||
|
|
||||||
|
private final BlockState material;
|
||||||
|
|
||||||
|
private final double size;
|
||||||
|
private final MaterialSet replaceable;
|
||||||
|
private final boolean applyGravity;
|
||||||
|
private final double exposed;
|
||||||
|
private final Map<BlockType, BlockState> materials;
|
||||||
|
|
||||||
|
public VanillaOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity,
|
||||||
|
double exposed, Map<BlockType, BlockState> materials) {
|
||||||
|
this.material = material;
|
||||||
|
this.size = size;
|
||||||
|
this.replaceable = replaceable;
|
||||||
|
this.applyGravity = applyGravity;
|
||||||
|
this.exposed = exposed;
|
||||||
|
this.materials = materials;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static boolean shouldNotDiscard(Random random, double chance) {
|
||||||
|
if(chance <= 0.0F) {
|
||||||
|
return true;
|
||||||
|
} else if(chance >= 1.0F) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return random.nextFloat() >= chance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double lerp(double t, double v0, double v1) {
|
||||||
|
return v0 + t * (v1 - v0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||||
|
float randomRadian = random.nextFloat() * (float) Math.PI;
|
||||||
|
double eigthSize = size / 8.0F;
|
||||||
|
|
||||||
|
// Place points to form a line segment
|
||||||
|
double startX = (double) location.getX() + FastMath.sin(randomRadian) * eigthSize;
|
||||||
|
double endX = (double) location.getX() - FastMath.sin(randomRadian) * eigthSize;
|
||||||
|
|
||||||
|
double startZ = (double) location.getZ() + FastMath.cos(randomRadian) * eigthSize;
|
||||||
|
double endZ = (double) location.getZ() - FastMath.cos(randomRadian) * eigthSize;
|
||||||
|
|
||||||
|
double startY = location.getY() + random.nextInt(3) - 2;
|
||||||
|
double endY = location.getY() + random.nextInt(3) - 2;
|
||||||
|
|
||||||
|
int sizeInt = (int) size;
|
||||||
|
double[] points = new double[sizeInt * 4];
|
||||||
|
|
||||||
|
// Compute initial point positions and radius
|
||||||
|
for(int i = 0; i < sizeInt; ++i) {
|
||||||
|
float t = (float) i / (float) sizeInt;
|
||||||
|
double xt = lerp(t, startX, endX);
|
||||||
|
double yt = lerp(t, startY, endY);
|
||||||
|
double zt = lerp(t, startZ, endZ);
|
||||||
|
double roll = random.nextDouble() * size / 16.0;
|
||||||
|
// Taper radius closer to line ends
|
||||||
|
double radius = ((FastMath.sin((float) Math.PI * t) + 1.0F) * roll + 1.0) / 2.0;
|
||||||
|
points[i * 4] = xt;
|
||||||
|
points[i * 4 + 1] = yt;
|
||||||
|
points[i * 4 + 2] = zt;
|
||||||
|
points[i * 4 + 3] = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare every point to every other point
|
||||||
|
for(int a = 0; a < sizeInt - 1; ++a) {
|
||||||
|
double radiusA = points[a * 4 + 3];
|
||||||
|
if(radiusA > 0.0) {
|
||||||
|
for(int b = a + 1; b < sizeInt; ++b) {
|
||||||
|
double radiusB = points[b * 4 + 3];
|
||||||
|
if(radiusB > 0.0) {
|
||||||
|
double dxt = points[a * 4] - points[b * 4];
|
||||||
|
double dyt = points[a * 4 + 1] - points[b * 4 + 1];
|
||||||
|
double dzt = points[a * 4 + 2] - points[b * 4 + 2];
|
||||||
|
double dRadius = radiusA - radiusB;
|
||||||
|
|
||||||
|
// If the radius difference is greater than the distance between the two points
|
||||||
|
if(dRadius * dRadius > dxt * dxt + dyt * dyt + dzt * dzt) {
|
||||||
|
// Set smaller of two radii to -1
|
||||||
|
if(dRadius > 0.0) {
|
||||||
|
points[b * 4 + 3] = -1.0;
|
||||||
|
} else {
|
||||||
|
points[a * 4 + 3] = -1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int outset = (int) FastMath.ceil((size / 16.0F * 2.0F + 1.0F) / 2.0F);
|
||||||
|
int x = (int) (location.getX() - FastMath.ceil(eigthSize) - outset);
|
||||||
|
int y = location.getY() - 2 - outset;
|
||||||
|
int z = (int) (location.getZ() - FastMath.ceil(eigthSize) - outset);
|
||||||
|
|
||||||
|
int horizontalSize = (int) (2 * (FastMath.ceil(eigthSize) + outset));
|
||||||
|
int verticalSize = 2 * (2 + outset);
|
||||||
|
|
||||||
|
int sphereCount = 0;
|
||||||
|
BitSet visited = new BitSet(horizontalSize * verticalSize * horizontalSize);
|
||||||
|
|
||||||
|
// Generate a sphere at each point
|
||||||
|
for(int i = 0; i < sizeInt; ++i) {
|
||||||
|
double radius = points[i * 4 + 3];
|
||||||
|
if(radius > 0.0) {
|
||||||
|
double xt = points[i * 4];
|
||||||
|
double yt = points[i * 4 + 1];
|
||||||
|
double zt = points[i * 4 + 2];
|
||||||
|
|
||||||
|
int xLowerBound = (int) FastMath.max(FastMath.floor(xt - radius), x);
|
||||||
|
int xUpperBound = (int) FastMath.max(FastMath.floor(xt + radius), xLowerBound);
|
||||||
|
|
||||||
|
int yLowerBound = (int) FastMath.max(FastMath.floor(yt - radius), y);
|
||||||
|
int yUpperBound = (int) FastMath.max(FastMath.floor(yt + radius), yLowerBound);
|
||||||
|
|
||||||
|
int zLowerBound = (int) FastMath.max(FastMath.floor(zt - radius), z);
|
||||||
|
int zUpperBound = (int) FastMath.max(FastMath.floor(zt + radius), zLowerBound);
|
||||||
|
|
||||||
|
// Iterate over coordinates within bounds
|
||||||
|
for(int xi = xLowerBound; xi <= xUpperBound; ++xi) {
|
||||||
|
double dx = ((double) xi + 0.5 - xt) / radius;
|
||||||
|
if(dx * dx < 1.0) {
|
||||||
|
for(int yi = yLowerBound; yi <= yUpperBound; ++yi) {
|
||||||
|
double dy = ((double) yi + 0.5 - yt) / radius;
|
||||||
|
if(dx * dx + dy * dy < 1.0) {
|
||||||
|
for(int zi = zLowerBound; zi <= zUpperBound; ++zi) {
|
||||||
|
double dz = ((double) zi + 0.5 - zt) / radius;
|
||||||
|
|
||||||
|
// If position is inside the sphere
|
||||||
|
if(dx * dx + dy * dy + dz * dz < 1.0 && !(yi < world.getMinHeight() || yi >= world.getMaxHeight())) {
|
||||||
|
int index = xi - x + (yi - y) * horizontalSize + (zi - z) * horizontalSize * verticalSize;
|
||||||
|
if(!visited.get(index)) { // Skip blocks that have already been visited
|
||||||
|
|
||||||
|
visited.set(index);
|
||||||
|
BlockType block = world.getBlockState(xi, yi, zi).getBlockType();
|
||||||
|
if(shouldPlace(block, random, world, xi, yi, zi)) {
|
||||||
|
world.setBlockState(xi, yi, zi, getMaterial(block), isApplyGravity());
|
||||||
|
++sphereCount;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sphereCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldPlace(BlockType type, Random random, WritableWorld world, int x, int y, int z) {
|
||||||
|
if(!getReplaceable().contains(type)) {
|
||||||
|
return false;
|
||||||
|
} else if(shouldNotDiscard(random, exposed)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return !(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 - 1, y, z).isAir() ||
|
||||||
|
world.getBlockState(x + 1, y, z).isAir());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getMaterial(BlockType replace) {
|
||||||
|
return materials.getOrDefault(replace, material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaterialSet getReplaceable() {
|
||||||
|
return replaceable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isApplyGravity() {
|
||||||
|
return applyGravity;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
schema-version: 1
|
||||||
|
contributors:
|
||||||
|
- Terra contributors
|
||||||
|
id: config-ore-v2
|
||||||
|
version: @VERSION@
|
||||||
|
entrypoints:
|
||||||
|
- "com.dfsek.terra.addons.ore.v2.OreAddon"
|
||||||
|
website:
|
||||||
|
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||||
|
source: https://github.com/PolyhedralDev/Terra
|
||||||
|
docs: https://terra.polydev.org
|
||||||
|
license: MIT License
|
||||||
@@ -14,8 +14,13 @@ 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.inject.annotations.Inject;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
public class OreAddon implements AddonInitializer {
|
public class OreAddon implements AddonInitializer {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(OreAddon.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Platform platform;
|
private Platform platform;
|
||||||
|
|
||||||
@@ -29,5 +34,8 @@ public class OreAddon implements AddonInitializer {
|
|||||||
.register(addon, ConfigPackPreLoadEvent.class)
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> event.getPack().registerConfigType(new OreConfigType(), addon.key("ORE"), 1))
|
.then(event -> event.getPack().registerConfigType(new OreConfigType(), addon.key("ORE"), 1))
|
||||||
.failThrough();
|
.failThrough();
|
||||||
|
|
||||||
|
if(platform.getTerraConfig().isDebugLog())
|
||||||
|
logger.warn("The ore-config addon is deprecated and scheduled for removal in Terra 7.0. It is recommended to use the ore-config-v2 addon for future pack development instead.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
version = version("1.0.0")
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
|
||||||
|
compileOnlyApi(project(":common:addons:chunk-generator-noise-3d"))
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.dfsek.terra.addon.feature.locator.slant;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.chunkgenerator.generation.NoiseChunkGenerator3D;
|
||||||
|
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
|
import com.dfsek.terra.api.world.World;
|
||||||
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
|
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
||||||
|
|
||||||
|
import java.util.function.DoublePredicate;
|
||||||
|
|
||||||
|
|
||||||
|
public class SlantLocator implements Locator {
|
||||||
|
|
||||||
|
private final DoublePredicate predicate;
|
||||||
|
|
||||||
|
public SlantLocator(DoublePredicate predicate) {
|
||||||
|
this.predicate = predicate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BinaryColumn getSuitableCoordinates(Column<?> column) {
|
||||||
|
return column.newBinaryColumn(y -> {
|
||||||
|
int x = column.getX();
|
||||||
|
int z = column.getZ();
|
||||||
|
World world = column.getWorld();
|
||||||
|
NoiseChunkGenerator3D generator = (NoiseChunkGenerator3D) world.getGenerator();
|
||||||
|
BiomeProvider biomeProvider = world.getBiomeProvider();
|
||||||
|
return predicate.test(generator.getSlant(x, y, z, world, biomeProvider));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
package com.dfsek.terra.addon.feature.locator.slant;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
|
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||||
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
|
||||||
|
public class SlantLocatorAddon implements AddonInitializer {
|
||||||
|
|
||||||
|
public static final TypeKey<Supplier<ObjectTemplate<Locator>>> LOCATOR_TOKEN = new TypeKey<>() {
|
||||||
|
};
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Platform platform;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BaseAddon addon;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
platform.getEventManager()
|
||||||
|
.getHandler(FunctionalEventHandler.class)
|
||||||
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
|
.priority(1)
|
||||||
|
.then(event -> event.getPack().getOrCreateRegistry(LOCATOR_TOKEN).register(addon.key("SLANT"), SlantLocatorTemplate::new))
|
||||||
|
.failThrough();
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package com.dfsek.terra.addon.feature.locator.slant;
|
||||||
|
|
||||||
|
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||||
|
import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.structure.feature.Locator;
|
||||||
|
|
||||||
|
import java.util.function.DoublePredicate;
|
||||||
|
|
||||||
|
|
||||||
|
public class SlantLocatorTemplate implements ObjectTemplate<Locator> {
|
||||||
|
|
||||||
|
@Value("condition")
|
||||||
|
private DoublePredicate predicate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Locator get() {
|
||||||
|
return new SlantLocator(predicate);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
schema-version: 1
|
||||||
|
contributors:
|
||||||
|
- Terra contributors
|
||||||
|
id: locator-slant-noise-3d
|
||||||
|
version: @VERSION@
|
||||||
|
entrypoints:
|
||||||
|
- "com.dfsek.terra.addon.feature.locator.slant.SlantLocatorAddon"
|
||||||
|
website:
|
||||||
|
issues: https://github.com/PolyhedralDev/Terra/issues
|
||||||
|
source: https://github.com/PolyhedralDev/Terra
|
||||||
|
docs: https://terra.polydev.org
|
||||||
|
license: MIT License
|
||||||
|
depends:
|
||||||
|
chunk-generator-noise-3d: "[1.2.0,2.0.0)"
|
||||||
@@ -21,6 +21,8 @@ public interface PluginConfig {
|
|||||||
|
|
||||||
boolean isDebugScript();
|
boolean isDebugScript();
|
||||||
|
|
||||||
|
boolean isDebugLog();
|
||||||
|
|
||||||
int getBiomeSearchResolution();
|
int getBiomeSearchResolution();
|
||||||
|
|
||||||
int getStructureCache();
|
int getStructureCache();
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ public class PluginConfigImpl implements ConfigTemplate, PluginConfig {
|
|||||||
@Default
|
@Default
|
||||||
private boolean debugScript = false;
|
private boolean debugScript = false;
|
||||||
|
|
||||||
|
@Value("debug.log")
|
||||||
|
@Default
|
||||||
|
private boolean debugLog = false;
|
||||||
|
|
||||||
@Value("biome-search-resolution")
|
@Value("biome-search-resolution")
|
||||||
@Default
|
@Default
|
||||||
private int biomeSearch = 4;
|
private int biomeSearch = 4;
|
||||||
@@ -91,6 +95,8 @@ public class PluginConfigImpl implements ConfigTemplate, PluginConfig {
|
|||||||
logger.info("Debug profiler enabled.");
|
logger.info("Debug profiler enabled.");
|
||||||
if(debugScript)
|
if(debugScript)
|
||||||
logger.info("Script debug blocks enabled.");
|
logger.info("Script debug blocks enabled.");
|
||||||
|
if(debugLog)
|
||||||
|
logger.info("Debug logging enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -113,6 +119,11 @@ public class PluginConfigImpl implements ConfigTemplate, PluginConfig {
|
|||||||
return debugScript;
|
return debugScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebugLog() {
|
||||||
|
return debugLog;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBiomeSearchResolution() {
|
public int getBiomeSearchResolution() {
|
||||||
return biomeSearch;
|
return biomeSearch;
|
||||||
|
|||||||
@@ -8,5 +8,4 @@ terra.license=MIT
|
|||||||
# Gradle options
|
# Gradle options
|
||||||
org.gradle.jvmargs=-Xmx4096M -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC
|
org.gradle.jvmargs=-Xmx4096M -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC
|
||||||
org.gradle.warning.mode=all
|
org.gradle.warning.mode=all
|
||||||
#org.gradle.parallel=true
|
|
||||||
|
|
||||||
Vendored
BIN
Binary file not shown.
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
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-8.3-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
org.gradle.jvmargs=-Xmx4096m
|
|
||||||
@@ -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,99 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## 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/HEAD/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="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# This is normally unused
|
||||||
APP_BASE_NAME=`basename "$0"`
|
# shellcheck disable=SC2034
|
||||||
|
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.
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
|
|
||||||
# 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 +119,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,88 +130,120 @@ 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.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
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
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
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
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# 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
|
||||||
|
|
||||||
|
|
||||||
|
# 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"'
|
||||||
|
|
||||||
|
# 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 \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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" "$@"
|
||||||
Vendored
+9
-6
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("xyz.jpenilla.run-paper") version "1.0.6"
|
id("xyz.jpenilla.run-paper") version Versions.Bukkit.runPaper
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
|
||||||
|
name = "Sonatype"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -13,12 +15,14 @@ dependencies {
|
|||||||
shaded(project(":platforms:bukkit:nms:v1_19_R2", configuration = "reobf"))
|
shaded(project(":platforms:bukkit:nms:v1_19_R2", configuration = "reobf"))
|
||||||
shaded(project(":platforms:bukkit:nms:v1_19_R3", configuration = "reobf"))
|
shaded(project(":platforms:bukkit:nms:v1_19_R3", configuration = "reobf"))
|
||||||
shaded(project(":platforms:bukkit:nms:v1_20_R1", configuration = "reobf"))
|
shaded(project(":platforms:bukkit:nms:v1_20_R1", configuration = "reobf"))
|
||||||
|
shaded(project(":platforms:bukkit:nms:v1_20_R2", configuration = "reobf"))
|
||||||
shaded("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
shaded("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
shadowJar {
|
shadowJar {
|
||||||
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
|
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
|
||||||
|
relocate("com.tcoded.folialib", "com.dfsek.terra.lib.folialib")
|
||||||
relocate("com.google.common", "com.dfsek.terra.lib.google.common")
|
relocate("com.google.common", "com.dfsek.terra.lib.google.common")
|
||||||
relocate("org.apache.logging.slf4j", "com.dfsek.terra.lib.slf4j-over-log4j")
|
relocate("org.apache.logging.slf4j", "com.dfsek.terra.lib.slf4j-over-log4j")
|
||||||
exclude("org/slf4j/**")
|
exclude("org/slf4j/**")
|
||||||
|
|||||||
@@ -5,14 +5,11 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
shadedApi(project(":common:implementation:base"))
|
shadedApi(project(":common:implementation:base"))
|
||||||
|
|
||||||
api("org.slf4j:slf4j-api:1.8.0-beta4") {
|
compileOnly("io.papermc.paper", "paper-api", Versions.Bukkit.paper)
|
||||||
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("io.papermc", "paperlib", Versions.Bukkit.paperLib)
|
shadedApi("io.papermc", "paperlib", Versions.Bukkit.paperLib)
|
||||||
shadedApi("com.google.guava:guava:30.0-jre")
|
shadedApi("com.tcoded", "FoliaLib" , Versions.Bukkit.foliaLib)
|
||||||
|
shadedApi("com.google.guava", "guava", Versions.Libraries.Internal.guava)
|
||||||
|
|
||||||
shadedApi("cloud.commandframework", "cloud-paper", Versions.Libraries.cloud)
|
shadedApi("cloud.commandframework", "cloud-paper", Versions.Libraries.cloud)
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.bukkit;
|
package com.dfsek.terra.bukkit;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import com.dfsek.terra.api.entity.Entity;
|
import com.dfsek.terra.api.entity.Entity;
|
||||||
@@ -44,14 +45,14 @@ public class BukkitEntity implements Entity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void position(Vector3 location) {
|
public void position(Vector3 location) {
|
||||||
entity.teleport(BukkitAdapter.adapt(location).toLocation(entity.getWorld()));
|
PaperLib.teleportAsync(entity, BukkitAdapter.adapt(location).toLocation(entity.getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void world(ServerWorld world) {
|
public void world(ServerWorld world) {
|
||||||
Location newLoc = entity.getLocation().clone();
|
Location newLoc = entity.getLocation().clone();
|
||||||
newLoc.setWorld(BukkitAdapter.adapt(world));
|
newLoc.setWorld(BukkitAdapter.adapt(world));
|
||||||
entity.teleport(newLoc);
|
PaperLib.teleportAsync(entity, newLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.bukkit;
|
package com.dfsek.terra.bukkit;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import com.dfsek.terra.api.entity.Player;
|
import com.dfsek.terra.api.entity.Player;
|
||||||
@@ -45,14 +46,14 @@ public class BukkitPlayer implements Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void position(Vector3 location) {
|
public void position(Vector3 location) {
|
||||||
delegate.teleport(BukkitAdapter.adapt(location).toLocation(delegate.getWorld()));
|
PaperLib.teleportAsync(delegate, BukkitAdapter.adapt(location).toLocation(delegate.getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void world(ServerWorld world) {
|
public void world(ServerWorld world) {
|
||||||
Location newLoc = delegate.getLocation().clone();
|
Location newLoc = delegate.getLocation().clone();
|
||||||
newLoc.setWorld(BukkitAdapter.adapt(world));
|
newLoc.setWorld(BukkitAdapter.adapt(world));
|
||||||
delegate.teleport(newLoc);
|
PaperLib.teleportAsync(delegate, newLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package com.dfsek.terra.bukkit;
|
|||||||
import com.dfsek.tectonic.api.TypeRegistry;
|
import com.dfsek.tectonic.api.TypeRegistry;
|
||||||
import com.dfsek.tectonic.api.depth.DepthTracker;
|
import com.dfsek.tectonic.api.depth.DepthTracker;
|
||||||
import com.dfsek.tectonic.api.exception.LoadException;
|
import com.dfsek.tectonic.api.exception.LoadException;
|
||||||
|
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -29,6 +30,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.dfsek.terra.AbstractPlatform;
|
import com.dfsek.terra.AbstractPlatform;
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
@@ -85,7 +87,7 @@ public class PlatformImpl extends AbstractPlatform {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runPossiblyUnsafeTask(@NotNull Runnable task) {
|
public void runPossiblyUnsafeTask(@NotNull Runnable task) {
|
||||||
Bukkit.getScheduler().runTask(plugin, task);
|
plugin.getFoliaLib().getImpl().runAsync(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import com.dfsek.terra.bukkit.nms.Initializer;
|
|||||||
import com.dfsek.terra.bukkit.util.PaperUtil;
|
import com.dfsek.terra.bukkit.util.PaperUtil;
|
||||||
import com.dfsek.terra.bukkit.util.VersionUtil;
|
import com.dfsek.terra.bukkit.util.VersionUtil;
|
||||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||||
|
import com.tcoded.folialib.FoliaLib;
|
||||||
|
|
||||||
|
|
||||||
public class TerraBukkitPlugin extends JavaPlugin {
|
public class TerraBukkitPlugin extends JavaPlugin {
|
||||||
@@ -50,6 +51,8 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
private final PlatformImpl platform = new PlatformImpl(this);
|
private final PlatformImpl platform = new PlatformImpl(this);
|
||||||
private final Map<String, com.dfsek.terra.api.world.chunk.generation.ChunkGenerator> generatorMap = new HashMap<>();
|
private final Map<String, com.dfsek.terra.api.world.chunk.generation.ChunkGenerator> generatorMap = new HashMap<>();
|
||||||
|
|
||||||
|
private final FoliaLib foliaLib = new FoliaLib(this);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
if(!doVersionCheck()) {
|
if(!doVersionCheck()) {
|
||||||
@@ -150,7 +153,7 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
""".strip());
|
""".strip());
|
||||||
};
|
};
|
||||||
runnable.run();
|
runnable.run();
|
||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(this, runnable, 200L);
|
getFoliaLib().getImpl().runLaterAsync(runnable, 200L);
|
||||||
// Bukkit.shutdown(); // we're not *that* evil
|
// Bukkit.shutdown(); // we're not *that* evil
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
return false;
|
return false;
|
||||||
@@ -177,4 +180,8 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
return pack.getGeneratorProvider().newInstance(pack);
|
return pack.getGeneratorProvider().newInstance(pack);
|
||||||
}), platform.getRawConfigRegistry().getByID(id).orElseThrow(), platform.getWorldHandle().air());
|
}), platform.getRawConfigRegistry().getByID(id).orElseThrow(), platform.getWorldHandle().air());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FoliaLib getFoliaLib() {
|
||||||
|
return foliaLib;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.dfsek.terra.bukkit.util;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
|
||||||
|
public class BukkitUtils {
|
||||||
|
public static boolean isLiquid(BlockData blockState) {
|
||||||
|
Material material = blockState.getMaterial();
|
||||||
|
return material == Material.WATER || material == Material.LAVA;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.bukkit.util;
|
package com.dfsek.terra.bukkit.util;
|
||||||
|
|
||||||
|
import com.dfsek.terra.bukkit.TerraBukkitPlugin;
|
||||||
|
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@@ -25,10 +27,10 @@ import static io.papermc.lib.PaperLib.suggestPaper;
|
|||||||
|
|
||||||
|
|
||||||
public final class PaperUtil {
|
public final class PaperUtil {
|
||||||
public static void checkPaper(JavaPlugin main) {
|
public static void checkPaper(TerraBukkitPlugin plugin) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> {
|
plugin.getFoliaLib().getImpl().runLaterAsync(() -> {
|
||||||
if(!PaperLib.isPaper()) {
|
if(!PaperLib.isPaper()) {
|
||||||
suggestPaper(main);
|
suggestPaper(plugin);
|
||||||
}
|
}
|
||||||
}, 100L);
|
}, 100L);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-2
@@ -1,6 +1,9 @@
|
|||||||
package com.dfsek.terra.bukkit.world;
|
package com.dfsek.terra.bukkit.world;
|
||||||
|
|
||||||
|
import com.dfsek.terra.bukkit.util.BukkitUtils;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.generator.LimitedRegion;
|
import org.bukkit.generator.LimitedRegion;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -47,9 +50,14 @@ public class BukkitProtoWorld implements ProtoWorld {
|
|||||||
@Override
|
@Override
|
||||||
public void setBlockState(int x, int y, int z, BlockState data, boolean physics) {
|
public void setBlockState(int x, int y, int z, BlockState data, boolean physics) {
|
||||||
access(x, y, z, () -> {
|
access(x, y, z, () -> {
|
||||||
delegate.setBlockData(x, y, z, BukkitAdapter.adapt(data));
|
BlockData bukkitData = BukkitAdapter.adapt(data);
|
||||||
|
delegate.setBlockData(x, y, z, bukkitData);
|
||||||
if(physics) {
|
if(physics) {
|
||||||
delegate.scheduleBlockUpdate(x, y, z);
|
if (BukkitUtils.isLiquid(bukkitData)) {
|
||||||
|
delegate.scheduleFluidUpdate(x, y, z);
|
||||||
|
} else {
|
||||||
|
delegate.scheduleBlockUpdate(x, y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,3 +6,4 @@ author: dfsek
|
|||||||
website: "@WIKI@"
|
website: "@WIKI@"
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
description: "@DESCRIPTION@"
|
description: "@DESCRIPTION@"
|
||||||
|
folia-supported: true
|
||||||
@@ -7,7 +7,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api(project(":platforms:bukkit:common"))
|
api(project(":platforms:bukkit:common"))
|
||||||
paperDevBundle("1.18.2-R0.1-SNAPSHOT")
|
paperDevBundle("1.18.2-R0.1-SNAPSHOT")
|
||||||
implementation("xyz.jpenilla", "reflection-remapper", "0.1.0-SNAPSHOT")
|
implementation("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api(project(":platforms:bukkit:common"))
|
api(project(":platforms:bukkit:common"))
|
||||||
paperDevBundle("1.19-R0.1-SNAPSHOT")
|
paperDevBundle("1.19-R0.1-SNAPSHOT")
|
||||||
implementation("xyz.jpenilla", "reflection-remapper", "0.1.0-SNAPSHOT")
|
implementation("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api(project(":platforms:bukkit:common"))
|
api(project(":platforms:bukkit:common"))
|
||||||
paperDevBundle("1.19.3-R0.1-SNAPSHOT")
|
paperDevBundle("1.19.3-R0.1-SNAPSHOT")
|
||||||
implementation("xyz.jpenilla", "reflection-remapper", "0.1.0-SNAPSHOT")
|
implementation("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api(project(":platforms:bukkit:common"))
|
api(project(":platforms:bukkit:common"))
|
||||||
paperDevBundle("1.19.4-R0.1-SNAPSHOT")
|
paperDevBundle("1.19.4-R0.1-SNAPSHOT")
|
||||||
implementation("xyz.jpenilla", "reflection-remapper", "0.1.0-SNAPSHOT")
|
implementation("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api(project(":platforms:bukkit:common"))
|
api(project(":platforms:bukkit:common"))
|
||||||
paperDevBundle(Versions.Bukkit.paperDevBundle)
|
paperDevBundle("1.20.1-R0.1-SNAPSHOT")
|
||||||
implementation("xyz.jpenilla", "reflection-remapper", "0.1.0-SNAPSHOT")
|
implementation("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apply(plugin = "io.papermc.paperweight.userdev")
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(project(":platforms:bukkit:common"))
|
||||||
|
paperDevBundle(Versions.Bukkit.paperDevBundle)
|
||||||
|
implementation("xyz.jpenilla", "reflection-remapper", Versions.Bukkit.reflectionRemapper)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
assemble {
|
||||||
|
dependsOn("reobfJar")
|
||||||
|
}
|
||||||
|
}
|
||||||
+101
@@ -0,0 +1,101 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.mojang.serialization.Lifecycle;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.Holder.Reference;
|
||||||
|
import net.minecraft.core.MappedRegistry;
|
||||||
|
import net.minecraft.core.WritableRegistry;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.tags.TagKey;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
|
||||||
|
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||||
|
|
||||||
|
|
||||||
|
public class AwfulBukkitHacks {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(AwfulBukkitHacks.class);
|
||||||
|
|
||||||
|
private static final Map<ResourceLocation, List<ResourceLocation>> terraBiomeMap = new HashMap<>();
|
||||||
|
|
||||||
|
public static void registerBiomes(ConfigRegistry configRegistry) {
|
||||||
|
try {
|
||||||
|
LOGGER.info("Hacking biome registry...");
|
||||||
|
WritableRegistry<Biome> biomeRegistry = (WritableRegistry<Biome>) RegistryFetcher.biomeRegistry();
|
||||||
|
|
||||||
|
Reflection.MAPPED_REGISTRY.setFrozen((MappedRegistry<?>) biomeRegistry, false);
|
||||||
|
|
||||||
|
configRegistry.forEach(pack -> pack.getRegistry(com.dfsek.terra.api.world.biome.Biome.class).forEach((key, biome) -> {
|
||||||
|
try {
|
||||||
|
BukkitPlatformBiome platformBiome = (BukkitPlatformBiome) biome.getPlatformBiome();
|
||||||
|
NamespacedKey vanillaBukkitKey = platformBiome.getHandle().getKey();
|
||||||
|
ResourceLocation vanillaMinecraftKey = new ResourceLocation(vanillaBukkitKey.getNamespace(), vanillaBukkitKey.getKey());
|
||||||
|
Biome platform = NMSBiomeInjector.createBiome(biome, Objects.requireNonNull(biomeRegistry.get(vanillaMinecraftKey)));
|
||||||
|
|
||||||
|
ResourceKey<Biome> delegateKey = ResourceKey.create(
|
||||||
|
Registries.BIOME,
|
||||||
|
new ResourceLocation("terra", NMSBiomeInjector.createBiomeID(pack, key))
|
||||||
|
);
|
||||||
|
|
||||||
|
Reference<Biome> holder = biomeRegistry.register(delegateKey, platform, Lifecycle.stable());
|
||||||
|
Reflection.REFERENCE.invokeBindValue(holder, platform); // IMPORTANT: bind holder.
|
||||||
|
|
||||||
|
platformBiome.getContext().put(new NMSBiomeInfo(delegateKey));
|
||||||
|
|
||||||
|
terraBiomeMap.computeIfAbsent(vanillaMinecraftKey, i -> new ArrayList<>()).add(delegateKey.location());
|
||||||
|
|
||||||
|
LOGGER.debug("Registered biome: " + delegateKey);
|
||||||
|
} catch(NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
Reflection.MAPPED_REGISTRY.setFrozen((MappedRegistry<?>) biomeRegistry, true); // freeze registry again :)
|
||||||
|
|
||||||
|
LOGGER.info("Doing tag garbage....");
|
||||||
|
Map<TagKey<Biome>, List<Holder<Biome>>> collect = biomeRegistry
|
||||||
|
.getTags() // streamKeysAndEntries
|
||||||
|
.collect(HashMap::new,
|
||||||
|
(map, pair) ->
|
||||||
|
map.put(pair.getFirst(), new ArrayList<>(pair.getSecond().stream().toList())),
|
||||||
|
HashMap::putAll);
|
||||||
|
|
||||||
|
terraBiomeMap
|
||||||
|
.forEach((vb, terraBiomes) ->
|
||||||
|
NMSBiomeInjector.getEntry(biomeRegistry, vb).ifPresentOrElse(
|
||||||
|
vanilla -> terraBiomes.forEach(
|
||||||
|
tb -> NMSBiomeInjector.getEntry(biomeRegistry, tb).ifPresentOrElse(
|
||||||
|
terra -> {
|
||||||
|
LOGGER.debug("{} (vanilla for {}): {}",
|
||||||
|
vanilla.unwrapKey().orElseThrow().location(),
|
||||||
|
terra.unwrapKey().orElseThrow().location(),
|
||||||
|
vanilla.tags().toList());
|
||||||
|
vanilla.tags()
|
||||||
|
.forEach(tag -> collect
|
||||||
|
.computeIfAbsent(tag, t -> new ArrayList<>())
|
||||||
|
.add(terra));
|
||||||
|
},
|
||||||
|
() -> LOGGER.error("No such biome: {}", tb))),
|
||||||
|
() -> LOGGER.error("No vanilla biome: {}", vb)));
|
||||||
|
|
||||||
|
biomeRegistry.resetTags();
|
||||||
|
biomeRegistry.bindTags(ImmutableMap.copyOf(collect));
|
||||||
|
|
||||||
|
} catch(SecurityException | IllegalArgumentException exception) {
|
||||||
|
throw new RuntimeException(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.properties.Properties;
|
||||||
|
|
||||||
|
|
||||||
|
public record NMSBiomeInfo(ResourceKey<Biome> biomeKey) implements Properties {
|
||||||
|
}
|
||||||
+78
@@ -0,0 +1,78 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import net.minecraft.world.level.biome.BiomeSpecialEffects;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
|
import com.dfsek.terra.bukkit.config.VanillaBiomeProperties;
|
||||||
|
|
||||||
|
|
||||||
|
public class NMSBiomeInjector {
|
||||||
|
|
||||||
|
public static <T> Optional<Holder<T>> getEntry(Registry<T> registry, ResourceLocation identifier) {
|
||||||
|
return registry.getOptional(identifier)
|
||||||
|
.flatMap(registry::getResourceKey)
|
||||||
|
.flatMap(registry::getHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Biome createBiome(com.dfsek.terra.api.world.biome.Biome biome, Biome vanilla)
|
||||||
|
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||||
|
Biome.BiomeBuilder builder = new Biome.BiomeBuilder();
|
||||||
|
|
||||||
|
builder
|
||||||
|
.downfall(vanilla.climateSettings.downfall())
|
||||||
|
.temperature(vanilla.getBaseTemperature())
|
||||||
|
.mobSpawnSettings(vanilla.getMobSettings())
|
||||||
|
.generationSettings(vanilla.getGenerationSettings());
|
||||||
|
|
||||||
|
|
||||||
|
BiomeSpecialEffects.Builder effects = new BiomeSpecialEffects.Builder();
|
||||||
|
|
||||||
|
effects.grassColorModifier(vanilla.getSpecialEffects().getGrassColorModifier());
|
||||||
|
|
||||||
|
VanillaBiomeProperties vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||||
|
|
||||||
|
effects.fogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getFogColor(), vanilla.getFogColor()))
|
||||||
|
|
||||||
|
.waterColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterColor(), vanilla.getWaterColor()))
|
||||||
|
|
||||||
|
.waterFogColor(Objects.requireNonNullElse(vanillaBiomeProperties.getWaterFogColor(), vanilla.getWaterFogColor()))
|
||||||
|
|
||||||
|
.skyColor(Objects.requireNonNullElse(vanillaBiomeProperties.getSkyColor(), vanilla.getSkyColor()));
|
||||||
|
|
||||||
|
if(vanillaBiomeProperties.getFoliageColor() == null) {
|
||||||
|
vanilla.getSpecialEffects().getFoliageColorOverride().ifPresent(effects::foliageColorOverride);
|
||||||
|
} else {
|
||||||
|
effects.foliageColorOverride(vanillaBiomeProperties.getFoliageColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vanillaBiomeProperties.getGrassColor() == null) {
|
||||||
|
vanilla.getSpecialEffects().getGrassColorOverride().ifPresent(effects::grassColorOverride);
|
||||||
|
} else {
|
||||||
|
// grass
|
||||||
|
effects.grassColorOverride(vanillaBiomeProperties.getGrassColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
vanilla.getAmbientLoop().ifPresent(effects::ambientLoopSound);
|
||||||
|
vanilla.getAmbientAdditions().ifPresent(effects::ambientAdditionsSound);
|
||||||
|
vanilla.getAmbientMood().ifPresent(effects::ambientMoodSound);
|
||||||
|
vanilla.getBackgroundMusic().ifPresent(effects::backgroundMusic);
|
||||||
|
vanilla.getAmbientParticle().ifPresent(effects::ambientParticle);
|
||||||
|
|
||||||
|
builder.specialEffects(effects.build());
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String createBiomeID(ConfigPack pack, com.dfsek.terra.api.registry.key.RegistryKey biomeID) {
|
||||||
|
return pack.getID()
|
||||||
|
.toLowerCase() + "/" + biomeID.getNamespace().toLowerCase(Locale.ROOT) + "/" + biomeID.getID().toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
+47
@@ -0,0 +1,47 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
|
import net.minecraft.world.level.biome.Climate.Sampler;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
|
import com.dfsek.terra.bukkit.world.BukkitPlatformBiome;
|
||||||
|
|
||||||
|
|
||||||
|
public class NMSBiomeProvider extends BiomeSource {
|
||||||
|
private final BiomeProvider delegate;
|
||||||
|
private final long seed;
|
||||||
|
private final Registry<Biome> biomeRegistry = RegistryFetcher.biomeRegistry();
|
||||||
|
|
||||||
|
public NMSBiomeProvider(BiomeProvider delegate, long seed) {
|
||||||
|
super();
|
||||||
|
this.delegate = delegate;
|
||||||
|
this.seed = seed;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected Stream<Holder<Biome>> collectPossibleBiomes() {
|
||||||
|
return delegate.stream()
|
||||||
|
.map(biome -> RegistryFetcher.biomeRegistry()
|
||||||
|
.getHolderOrThrow(((BukkitPlatformBiome) biome.getPlatformBiome()).getContext()
|
||||||
|
.get(NMSBiomeInfo.class)
|
||||||
|
.biomeKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected @NotNull Codec<? extends BiomeSource> codec() {
|
||||||
|
return BiomeSource.CODEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Holder<Biome> getNoiseBiome(int x, int y, int z, @NotNull Sampler sampler) {
|
||||||
|
return biomeRegistry.getHolderOrThrow(((BukkitPlatformBiome) delegate.getBiome(x << 2, y << 2, z << 2, seed)
|
||||||
|
.getPlatformBiome()).getContext()
|
||||||
|
.get(NMSBiomeInfo.class)
|
||||||
|
.biomeKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
+170
@@ -0,0 +1,170 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.server.level.WorldGenRegion;
|
||||||
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
|
import net.minecraft.world.level.NoiseColumn;
|
||||||
|
import net.minecraft.world.level.StructureManager;
|
||||||
|
import net.minecraft.world.level.WorldGenLevel;
|
||||||
|
import net.minecraft.world.level.biome.BiomeManager;
|
||||||
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
|
import net.minecraft.world.level.levelgen.Beardifier;
|
||||||
|
import net.minecraft.world.level.levelgen.DensityFunction.SinglePointContext;
|
||||||
|
import net.minecraft.world.level.levelgen.GenerationStep.Carving;
|
||||||
|
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
||||||
|
import net.minecraft.world.level.levelgen.RandomState;
|
||||||
|
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.block.data.CraftBlockData;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
|
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||||
|
import com.dfsek.terra.bukkit.config.PreLoadCompatibilityOptions;
|
||||||
|
import com.dfsek.terra.bukkit.world.BukkitWorldProperties;
|
||||||
|
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
|
||||||
|
|
||||||
|
|
||||||
|
public class NMSChunkGeneratorDelegate extends ChunkGenerator {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(NMSChunkGeneratorDelegate.class);
|
||||||
|
private final com.dfsek.terra.api.world.chunk.generation.ChunkGenerator delegate;
|
||||||
|
|
||||||
|
private final ChunkGenerator vanilla;
|
||||||
|
private final ConfigPack pack;
|
||||||
|
|
||||||
|
private final long seed;
|
||||||
|
|
||||||
|
public NMSChunkGeneratorDelegate(ChunkGenerator vanilla, ConfigPack pack, NMSBiomeProvider biomeProvider, long seed) {
|
||||||
|
super(biomeProvider);
|
||||||
|
this.delegate = pack.getGeneratorProvider().newInstance(pack);
|
||||||
|
this.vanilla = vanilla;
|
||||||
|
this.pack = pack;
|
||||||
|
this.seed = seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected @NotNull Codec<? extends ChunkGenerator> codec() {
|
||||||
|
return ChunkGenerator.CODEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyCarvers(@NotNull WorldGenRegion chunkRegion, long seed, @NotNull RandomState noiseConfig, @NotNull BiomeManager world,
|
||||||
|
@NotNull StructureManager structureAccessor, @NotNull ChunkAccess chunk, @NotNull Carving carverStep) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void buildSurface(@NotNull WorldGenRegion region, @NotNull StructureManager structures, @NotNull RandomState noiseConfig,
|
||||||
|
@NotNull ChunkAccess chunk) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyBiomeDecoration(@NotNull WorldGenLevel world, @NotNull ChunkAccess chunk,
|
||||||
|
@NotNull StructureManager structureAccessor) {
|
||||||
|
vanilla.applyBiomeDecoration(world, chunk, structureAccessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void spawnOriginalMobs(@NotNull WorldGenRegion region) {
|
||||||
|
vanilla.spawnOriginalMobs(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGenDepth() {
|
||||||
|
return vanilla.getGenDepth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull CompletableFuture<ChunkAccess> fillFromNoise(@NotNull Executor executor, @NotNull Blender blender,
|
||||||
|
@NotNull RandomState noiseConfig,
|
||||||
|
@NotNull StructureManager structureAccessor, @NotNull ChunkAccess chunk) {
|
||||||
|
return vanilla.fillFromNoise(executor, blender, noiseConfig, structureAccessor, chunk)
|
||||||
|
.thenApply(c -> {
|
||||||
|
LevelAccessor level = Reflection.STRUCTURE_MANAGER.getLevel(structureAccessor);
|
||||||
|
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||||
|
PreLoadCompatibilityOptions compatibilityOptions = pack.getContext().get(PreLoadCompatibilityOptions.class);
|
||||||
|
if(compatibilityOptions.isBeard()) {
|
||||||
|
beard(structureAccessor, chunk, new BukkitWorldProperties(level.getMinecraftWorld().getWorld()), biomeProvider, compatibilityOptions);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void beard(StructureManager structureAccessor, ChunkAccess chunk, WorldProperties world, BiomeProvider biomeProvider,
|
||||||
|
PreLoadCompatibilityOptions compatibilityOptions) {
|
||||||
|
Beardifier structureWeightSampler = Beardifier.forStructuresInChunk(structureAccessor, chunk.getPos());
|
||||||
|
double threshold = compatibilityOptions.getBeardThreshold();
|
||||||
|
double airThreshold = compatibilityOptions.getAirThreshold();
|
||||||
|
int xi = chunk.getPos().x << 4;
|
||||||
|
int zi = chunk.getPos().z << 4;
|
||||||
|
for(int x = 0; x < 16; x++) {
|
||||||
|
for(int z = 0; z < 16; z++) {
|
||||||
|
int depth = 0;
|
||||||
|
for(int y = world.getMaxHeight(); y >= world.getMinHeight(); y--) {
|
||||||
|
double noise = structureWeightSampler.compute(new SinglePointContext(x + xi, y, z + zi));
|
||||||
|
if(noise > threshold) {
|
||||||
|
chunk.setBlockState(new BlockPos(x, y, z), ((CraftBlockData) ((BukkitBlockState) delegate
|
||||||
|
.getPalette(x + xi, y, z + zi, world, biomeProvider)
|
||||||
|
.get(depth, x + xi, y, z + zi, world.getSeed())).getHandle()).getState(), false);
|
||||||
|
depth++;
|
||||||
|
} else if(noise < airThreshold) {
|
||||||
|
chunk.setBlockState(new BlockPos(x, y, z), Blocks.AIR.defaultBlockState(), false);
|
||||||
|
} else {
|
||||||
|
depth = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSeaLevel() {
|
||||||
|
return vanilla.getSeaLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinY() {
|
||||||
|
return vanilla.getMinY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBaseHeight(int x, int z, @NotNull Types heightmap, @NotNull LevelHeightAccessor world, @NotNull RandomState noiseConfig) {
|
||||||
|
WorldProperties properties = new NMSWorldProperties(seed, world);
|
||||||
|
int y = properties.getMaxHeight();
|
||||||
|
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||||
|
while(y >= getMinY() && !heightmap.isOpaque().test(
|
||||||
|
((CraftBlockData) delegate.getBlock(properties, x, y - 1, z, biomeProvider).getHandle()).getState())) {
|
||||||
|
y--;
|
||||||
|
}
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull NoiseColumn getBaseColumn(int x, int z, @NotNull LevelHeightAccessor world, @NotNull RandomState noiseConfig) {
|
||||||
|
BlockState[] array = new BlockState[world.getHeight()];
|
||||||
|
WorldProperties properties = new NMSWorldProperties(seed, world);
|
||||||
|
BiomeProvider biomeProvider = pack.getBiomeProvider();
|
||||||
|
for(int y = properties.getMaxHeight() - 1; y >= properties.getMinHeight(); y--) {
|
||||||
|
array[y - properties.getMinHeight()] = ((CraftBlockData) delegate.getBlock(properties, x, y, z, biomeProvider)
|
||||||
|
.getHandle()).getState();
|
||||||
|
}
|
||||||
|
return new NoiseColumn(getMinY(), array);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDebugScreenInfo(@NotNull List<String> text, @NotNull RandomState noiseConfig, @NotNull BlockPos pos) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import com.dfsek.terra.bukkit.PlatformImpl;
|
||||||
|
import com.dfsek.terra.bukkit.nms.Initializer;
|
||||||
|
|
||||||
|
|
||||||
|
public class NMSInitializer implements Initializer {
|
||||||
|
@Override
|
||||||
|
public void initialize(PlatformImpl platform) {
|
||||||
|
AwfulBukkitHacks.registerBiomes(platform.getRawConfigRegistry());
|
||||||
|
Bukkit.getPluginManager().registerEvents(new NMSInjectListener(), platform.getPlugin());
|
||||||
|
}
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.world.WorldInitEvent;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
|
import com.dfsek.terra.bukkit.generator.BukkitChunkGeneratorWrapper;
|
||||||
|
|
||||||
|
|
||||||
|
public class NMSInjectListener implements Listener {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(NMSInjectListener.class);
|
||||||
|
private static final Set<World> INJECTED = new HashSet<>();
|
||||||
|
private static final ReentrantLock INJECT_LOCK = new ReentrantLock();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onWorldInit(WorldInitEvent event) {
|
||||||
|
if(!INJECTED.contains(event.getWorld()) &&
|
||||||
|
event.getWorld().getGenerator() instanceof BukkitChunkGeneratorWrapper bukkitChunkGeneratorWrapper) {
|
||||||
|
INJECT_LOCK.lock();
|
||||||
|
INJECTED.add(event.getWorld());
|
||||||
|
LOGGER.info("Preparing to take over the world: {}", event.getWorld().getName());
|
||||||
|
CraftWorld craftWorld = (CraftWorld) event.getWorld();
|
||||||
|
ServerLevel serverWorld = craftWorld.getHandle();
|
||||||
|
|
||||||
|
ConfigPack pack = bukkitChunkGeneratorWrapper.getPack();
|
||||||
|
|
||||||
|
ChunkGenerator vanilla = serverWorld.getChunkSource().getGenerator();
|
||||||
|
NMSBiomeProvider provider = new NMSBiomeProvider(pack.getBiomeProvider(), craftWorld.getSeed());
|
||||||
|
|
||||||
|
serverWorld.getChunkSource().chunkMap.generator = new NMSChunkGeneratorDelegate(vanilla, pack, provider, craftWorld.getSeed());
|
||||||
|
|
||||||
|
LOGGER.info("Successfully injected into world.");
|
||||||
|
|
||||||
|
INJECT_LOCK.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.LevelHeightAccessor;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||||
|
|
||||||
|
|
||||||
|
public class NMSWorldProperties implements WorldProperties {
|
||||||
|
private final long seed;
|
||||||
|
private final LevelHeightAccessor height;
|
||||||
|
|
||||||
|
public NMSWorldProperties(long seed, LevelHeightAccessor height) {
|
||||||
|
this.seed = seed;
|
||||||
|
this.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getHandle() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSeed() {
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHeight() {
|
||||||
|
return height.getMaxBuildHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinHeight() {
|
||||||
|
return height.getMinBuildHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.Holder.Reference;
|
||||||
|
import net.minecraft.core.MappedRegistry;
|
||||||
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
|
import net.minecraft.world.level.StructureManager;
|
||||||
|
import xyz.jpenilla.reflectionremapper.ReflectionRemapper;
|
||||||
|
import xyz.jpenilla.reflectionremapper.proxy.ReflectionProxyFactory;
|
||||||
|
import xyz.jpenilla.reflectionremapper.proxy.annotation.FieldGetter;
|
||||||
|
import xyz.jpenilla.reflectionremapper.proxy.annotation.FieldSetter;
|
||||||
|
import xyz.jpenilla.reflectionremapper.proxy.annotation.MethodName;
|
||||||
|
import xyz.jpenilla.reflectionremapper.proxy.annotation.Proxies;
|
||||||
|
|
||||||
|
|
||||||
|
public class Reflection {
|
||||||
|
public static final MappedRegistryProxy MAPPED_REGISTRY;
|
||||||
|
public static final StructureManagerProxy STRUCTURE_MANAGER;
|
||||||
|
|
||||||
|
public static final ReferenceProxy REFERENCE;
|
||||||
|
|
||||||
|
static {
|
||||||
|
ReflectionRemapper reflectionRemapper = ReflectionRemapper.forReobfMappingsInPaperJar();
|
||||||
|
ReflectionProxyFactory reflectionProxyFactory = ReflectionProxyFactory.create(reflectionRemapper,
|
||||||
|
Reflection.class.getClassLoader());
|
||||||
|
|
||||||
|
MAPPED_REGISTRY = reflectionProxyFactory.reflectionProxy(MappedRegistryProxy.class);
|
||||||
|
STRUCTURE_MANAGER = reflectionProxyFactory.reflectionProxy(StructureManagerProxy.class);
|
||||||
|
REFERENCE = reflectionProxyFactory.reflectionProxy(ReferenceProxy.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Proxies(MappedRegistry.class)
|
||||||
|
public interface MappedRegistryProxy {
|
||||||
|
@FieldSetter("frozen")
|
||||||
|
void setFrozen(MappedRegistry<?> instance, boolean frozen);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Proxies(StructureManager.class)
|
||||||
|
public interface StructureManagerProxy {
|
||||||
|
@FieldGetter("level")
|
||||||
|
LevelAccessor getLevel(StructureManager instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Proxies(Holder.Reference.class)
|
||||||
|
public interface ReferenceProxy {
|
||||||
|
@MethodName("bindValue")
|
||||||
|
<T> void invokeBindValue(Reference<T> instance, T value);
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.dfsek.terra.bukkit.nms.v1_20_R2;
|
||||||
|
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.craftbukkit.v1_20_R2.CraftServer;
|
||||||
|
|
||||||
|
|
||||||
|
public class RegistryFetcher {
|
||||||
|
private static <T> Registry<T> getRegistry(ResourceKey<Registry<T>> key) {
|
||||||
|
CraftServer craftserver = (CraftServer) Bukkit.getServer();
|
||||||
|
DedicatedServer dedicatedserver = craftserver.getServer();
|
||||||
|
return dedicatedserver
|
||||||
|
.registryAccess()
|
||||||
|
.registryOrThrow(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Registry<Biome> biomeRegistry() {
|
||||||
|
return getRegistry(Registries.BIOME);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,10 +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("commons-io:commons-io:${Versions.Libraries.Internal.apacheIO}")
|
||||||
shadedApi("com.github.Querz:NBT:${Versions.CLI.nbt}")
|
shadedApi("com.github.Querz:NBT:${Versions.CLI.nbt}")
|
||||||
|
|
||||||
shadedImplementation("com.google.guava:guava:${Versions.CLI.guava}")
|
shadedImplementation("com.google.guava:guava:${Versions.Libraries.Internal.guava}")
|
||||||
|
|
||||||
shadedImplementation("ch.qos.logback:logback-classic:${Versions.CLI.logback}")
|
shadedImplementation("ch.qos.logback:logback-classic:${Versions.CLI.logback}")
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
id("io.github.juuxel.loom-vineflower") version Versions.Mod.loomVineflower
|
||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
@@ -23,7 +23,7 @@ dependencies {
|
|||||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||||
|
|
||||||
modImplementation("net.fabricmc:fabric-loader:${Versions.Fabric.fabricLoader}")
|
modImplementation("net.fabricmc:fabric-loader:${Versions.Mod.fabricLoader}")
|
||||||
|
|
||||||
setOf(
|
setOf(
|
||||||
"fabric-lifecycle-events-v1",
|
"fabric-lifecycle-events-v1",
|
||||||
@@ -48,14 +48,6 @@ loom {
|
|||||||
defaultRefmapName.set("terra.fabric.refmap.json")
|
defaultRefmapName.set("terra.fabric.refmap.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
launches {
|
|
||||||
named("client") {
|
|
||||||
property("fabric.log.level", "debug")
|
|
||||||
}
|
|
||||||
named("server") {
|
|
||||||
property("fabric.log.level", "debug")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,35 +17,16 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.fabric;
|
package com.dfsek.terra.fabric;
|
||||||
|
|
||||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
|
||||||
import cloud.commandframework.fabric.FabricServerCommandManager;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.command.CommandSender;
|
import com.dfsek.terra.lifecycle.LifecycleEntryPoint;
|
||||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
|
||||||
|
|
||||||
|
|
||||||
public class FabricEntryPoint implements ModInitializer {
|
public class FabricEntryPoint extends LifecycleEntryPoint implements ModInitializer {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FabricEntryPoint.class);
|
|
||||||
|
|
||||||
private static final FabricPlatform TERRA_PLUGIN = new FabricPlatform();
|
private static final FabricPlatform TERRA_PLUGIN = new FabricPlatform();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
logger.info("Initializing Terra Fabric mod...");
|
initialize("Fabric", TERRA_PLUGIN);
|
||||||
|
|
||||||
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
|
||||||
CommandExecutionCoordinator.simpleCoordinator(),
|
|
||||||
serverCommandSource -> (CommandSender) serverCommandSource,
|
|
||||||
commandSender -> (ServerCommandSource) commandSender
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
manager.brigadierManager().setNativeNumberSuggestions(false);
|
|
||||||
|
|
||||||
TERRA_PLUGIN.getEventManager().callEvent(new CommandRegistrationEvent(manager));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,43 +17,24 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.fabric;
|
package com.dfsek.terra.fabric;
|
||||||
|
|
||||||
import ca.solostudios.strata.Versions;
|
|
||||||
import ca.solostudios.strata.parser.tokenizer.ParseException;
|
|
||||||
import ca.solostudios.strata.version.Version;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import com.dfsek.terra.addon.EphemeralAddon;
|
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
||||||
|
|
||||||
|
|
||||||
public class FabricPlatform extends LifecyclePlatform {
|
public class FabricPlatform extends LifecyclePlatform {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(FabricPlatform.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<BaseAddon> getPlatformMods() {
|
protected Collection<BaseAddon> getPlatformMods() {
|
||||||
return FabricLoader.getInstance().getAllMods().stream().flatMap(mod -> {
|
return FabricLoader.getInstance().getAllMods().stream().flatMap(
|
||||||
String id = mod.getMetadata().getId();
|
mod -> parseModData(mod.getMetadata().getId(), mod.getMetadata().getVersion().getFriendlyString(), "fabric")).collect(
|
||||||
if(id.equals("terra") || id.equals("minecraft") || id.equals("java")) return Stream.empty();
|
Collectors.toList());
|
||||||
try {
|
|
||||||
Version version = Versions.parseVersion(mod.getMetadata().getVersion().getFriendlyString());
|
|
||||||
return Stream.<BaseAddon>of(new EphemeralAddon(version, "fabric:" + id));
|
|
||||||
} catch(ParseException e) {
|
|
||||||
LOGGER.warn(
|
|
||||||
"Mod {}, version {} does not follow semantic versioning specification, Terra addons will be unable to depend on " +
|
|
||||||
"it.",
|
|
||||||
id, mod.getMetadata().getVersion().getFriendlyString());
|
|
||||||
}
|
|
||||||
return Stream.empty();
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
id("io.github.juuxel.loom-vineflower") version Versions.Mod.loomVineflower
|
||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
@@ -37,16 +37,16 @@ loom {
|
|||||||
defaultRefmapName.set("terra.forge.refmap.json")
|
defaultRefmapName.set("terra.forge.refmap.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
launches {
|
// launches {
|
||||||
named("client") {
|
// named("client") {
|
||||||
property("fabric.log.level", "debug")
|
// property("fabric.log.level", "info")
|
||||||
property("mixin.env.disableRefMap", "true")
|
// property("mixin.env.disableRefMap", "true")
|
||||||
}
|
// }
|
||||||
named("server") {
|
// named("server") {
|
||||||
property("fabric.log.level", "debug")
|
// property("fabric.log.level", "info")
|
||||||
property("mixin.env.disableRefMap", "true")
|
// property("mixin.env.disableRefMap", "true")
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
forge {
|
forge {
|
||||||
convertAccessWideners.set(true)
|
convertAccessWideners.set(true)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# mixin-common
|
# mixin-common
|
||||||
|
|
||||||
This project contains mixins shared between Forge, Fabric and Quilt, as
|
This project contains mixins shared between Forge, Fabric and formerly Quilt, as
|
||||||
well as glue code.
|
well as glue code.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
id("io.github.juuxel.loom-vineflower") version Versions.Mod.loomVineflower
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
@@ -24,7 +24,8 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
common("fabric", "forge", "quilt")
|
// common("fabric", "forge", "quilt")
|
||||||
|
common("fabric", "forge")
|
||||||
minecraft = Versions.Mod.minecraft
|
minecraft = Versions.Mod.minecraft
|
||||||
}
|
}
|
||||||
|
|
||||||
+17
-1
@@ -17,8 +17,11 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.mod.mixin.implementations.terra.chunk;
|
package com.dfsek.terra.mod.mixin.implementations.terra.chunk;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.chunk.Chunk.TickSchedulers;
|
||||||
import net.minecraft.world.chunk.WorldChunk;
|
import net.minecraft.world.chunk.WorldChunk;
|
||||||
|
import net.minecraft.world.tick.OrderedTick;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
@@ -47,8 +50,21 @@ public abstract class WorldChunkMixin {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public abstract net.minecraft.block.BlockState setBlockState(BlockPos pos, net.minecraft.block.BlockState state, boolean moved);
|
public abstract net.minecraft.block.BlockState setBlockState(BlockPos pos, net.minecraft.block.BlockState state, boolean moved);
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract TickSchedulers getTickSchedulers();
|
||||||
|
|
||||||
public void terra$setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
public void terra$setBlock(int x, int y, int z, BlockState data, boolean physics) {
|
||||||
setBlockState(new BlockPos(x, y, z), (net.minecraft.block.BlockState) data, false);
|
BlockPos blockPos = new BlockPos(x, y, z);
|
||||||
|
setBlockState(blockPos, (net.minecraft.block.BlockState) data, false);
|
||||||
|
if (physics) {
|
||||||
|
net.minecraft.block.BlockState state = ((net.minecraft.block.BlockState) data);
|
||||||
|
if (state.isLiquid()) {
|
||||||
|
world.getFluidTickScheduler().scheduleTick(OrderedTick.create(state.getFluidState().getFluid(), blockPos));
|
||||||
|
} else {
|
||||||
|
world.getBlockTickScheduler().scheduleTick(OrderedTick.create(state.getBlock(), blockPos));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
public void terra$setBlock(int x, int y, int z, @NotNull BlockState blockState) {
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
# mixin-lifecycle
|
# mixin-lifecycle
|
||||||
|
|
||||||
This project contains lifecycle mixins shared between Fabric and Quilt.
|
This project contains lifecycle mixins shared between Fabric and formerly Quilt.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
id("io.github.juuxel.loom-vineflower") version Versions.Mod.loomVineflower
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -15,6 +15,11 @@ dependencies {
|
|||||||
|
|
||||||
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
minecraft("com.mojang:minecraft:${Versions.Mod.minecraft}")
|
||||||
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
mappings("net.fabricmc:yarn:${Versions.Mod.yarn}:v2")
|
||||||
|
|
||||||
|
modImplementation("cloud.commandframework", "cloud-fabric", Versions.Libraries.cloud) {
|
||||||
|
exclude("net.fabricmc")
|
||||||
|
exclude("net.fabricmc.fabric-api")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loom {
|
loom {
|
||||||
@@ -36,6 +41,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
common("fabric", "quilt")
|
// common("fabric", "quilt")
|
||||||
|
common("fabric")
|
||||||
minecraft = Versions.Mod.minecraft
|
minecraft = Versions.Mod.minecraft
|
||||||
}
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package com.dfsek.terra.lifecycle;
|
||||||
|
|
||||||
|
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||||
|
|
||||||
|
import cloud.commandframework.fabric.FabricServerCommandManager;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.command.CommandSender;
|
||||||
|
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||||
|
|
||||||
|
import com.dfsek.terra.mod.MinecraftAddon;
|
||||||
|
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
public class LifecycleEntryPoint {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(LifecycleEntryPoint.class);
|
||||||
|
|
||||||
|
protected static void initialize(String modName, LifecyclePlatform platform) {
|
||||||
|
logger.info("Initializing Terra {} mod...", modName);
|
||||||
|
|
||||||
|
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
||||||
|
CommandExecutionCoordinator.simpleCoordinator(),
|
||||||
|
serverCommandSource -> (CommandSender) serverCommandSource,
|
||||||
|
commandSender -> (ServerCommandSource) commandSender
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
manager.brigadierManager().setNativeNumberSuggestions(false);
|
||||||
|
|
||||||
|
platform.getEventManager().callEvent(new CommandRegistrationEvent(manager));
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -2,6 +2,7 @@ package com.dfsek.terra.lifecycle;
|
|||||||
|
|
||||||
import ca.solostudios.strata.Versions;
|
import ca.solostudios.strata.Versions;
|
||||||
import ca.solostudios.strata.parser.tokenizer.ParseException;
|
import ca.solostudios.strata.parser.tokenizer.ParseException;
|
||||||
|
import ca.solostudios.strata.version.Version;
|
||||||
|
|
||||||
import com.dfsek.terra.lifecycle.util.BiomeUtil;
|
import com.dfsek.terra.lifecycle.util.BiomeUtil;
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import com.dfsek.terra.addon.EphemeralAddon;
|
import com.dfsek.terra.addon.EphemeralAddon;
|
||||||
@@ -109,6 +111,20 @@ public abstract class LifecyclePlatform extends ModPlatform {
|
|||||||
return addons;
|
return addons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Stream<EphemeralAddon> parseModData(String id, String modVersion, String platform) {
|
||||||
|
if(id.equals("terra") || id.equals("minecraft") || id.equals("java")) return Stream.empty();
|
||||||
|
try {
|
||||||
|
Version version = Versions.parseVersion(modVersion);
|
||||||
|
return Stream.of(new EphemeralAddon(version, platform + ":" + id));
|
||||||
|
} catch(ParseException e) {
|
||||||
|
LOGGER.warn(
|
||||||
|
"Mod {}, version {} does not follow semantic versioning specification, Terra addons will be unable to depend on " +
|
||||||
|
"it.",
|
||||||
|
id, modVersion);
|
||||||
|
}
|
||||||
|
return Stream.empty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Registry<DimensionType> dimensionTypeRegistry() {
|
public Registry<DimensionType> dimensionTypeRegistry() {
|
||||||
return DIMENSIONS.get();
|
return DIMENSIONS.get();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
id("dev.architectury.loom") version Versions.Mod.architecuryLoom
|
||||||
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
id("architectury-plugin") version Versions.Mod.architecturyPlugin
|
||||||
id("io.github.juuxel.loom-quiltflower") version Versions.Mod.loomQuiltflower
|
id("io.github.juuxel.loom-vineflower") version Versions.Mod.loomVineflower
|
||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
@@ -47,15 +47,6 @@ loom {
|
|||||||
mixin {
|
mixin {
|
||||||
defaultRefmapName.set("terra.quilt.refmap.json")
|
defaultRefmapName.set("terra.quilt.refmap.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
launches {
|
|
||||||
named("client") {
|
|
||||||
property("fabric.log.level", "debug")
|
|
||||||
}
|
|
||||||
named("server") {
|
|
||||||
property("fabric.log.level", "debug")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -17,36 +17,17 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.quilt;
|
package com.dfsek.terra.quilt;
|
||||||
|
|
||||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
|
||||||
import cloud.commandframework.fabric.FabricServerCommandManager;
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
|
||||||
import org.quiltmc.loader.api.ModContainer;
|
import org.quiltmc.loader.api.ModContainer;
|
||||||
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
|
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.command.CommandSender;
|
import com.dfsek.terra.lifecycle.LifecycleEntryPoint;
|
||||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
|
||||||
|
|
||||||
|
|
||||||
public class QuiltEntryPoint implements ModInitializer {
|
public class QuiltEntryPoint extends LifecycleEntryPoint implements ModInitializer {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(QuiltEntryPoint.class);
|
|
||||||
|
|
||||||
private static final QuiltPlatform TERRA_PLUGIN = new QuiltPlatform();
|
private static final QuiltPlatform TERRA_PLUGIN = new QuiltPlatform();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize(ModContainer container) {
|
public void onInitialize(ModContainer container) {
|
||||||
logger.info("Initializing Terra Quilt mod...");
|
initialize("Quilt", TERRA_PLUGIN);
|
||||||
|
|
||||||
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
|
||||||
CommandExecutionCoordinator.simpleCoordinator(),
|
|
||||||
serverCommandSource -> (CommandSender) serverCommandSource,
|
|
||||||
commandSender -> (ServerCommandSource) commandSender
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
manager.brigadierManager().setNativeNumberSuggestions(false);
|
|
||||||
|
|
||||||
TERRA_PLUGIN.getEventManager().callEvent(new CommandRegistrationEvent(manager));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,43 +17,23 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.quilt;
|
package com.dfsek.terra.quilt;
|
||||||
|
|
||||||
import ca.solostudios.strata.Versions;
|
|
||||||
import ca.solostudios.strata.parser.tokenizer.ParseException;
|
|
||||||
import ca.solostudios.strata.version.Version;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.quiltmc.loader.api.QuiltLoader;
|
import org.quiltmc.loader.api.QuiltLoader;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import com.dfsek.terra.addon.EphemeralAddon;
|
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
import com.dfsek.terra.lifecycle.LifecyclePlatform;
|
||||||
|
|
||||||
|
|
||||||
public class QuiltPlatform extends LifecyclePlatform {
|
public class QuiltPlatform extends LifecyclePlatform {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(QuiltPlatform.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<BaseAddon> getPlatformMods() {
|
protected Collection<BaseAddon> getPlatformMods() {
|
||||||
return QuiltLoader.getAllMods().stream().flatMap(mod -> {
|
return QuiltLoader.getAllMods().stream().flatMap(mod -> parseModData(mod.metadata().id(), mod.metadata().version().raw(), "quilt")).collect(
|
||||||
String id = mod.metadata().id();
|
Collectors.toList());
|
||||||
if(id.equals("terra") || id.equals("minecraft") || id.equals("java")) return Stream.empty();
|
|
||||||
try {
|
|
||||||
Version version = Versions.parseVersion(mod.metadata().version().raw());
|
|
||||||
return Stream.of(new EphemeralAddon(version, "quilt:" + id));
|
|
||||||
} catch(ParseException e) {
|
|
||||||
LOGGER.warn(
|
|
||||||
"Mod {}, version {} does not follow semantic versioning specification, Terra addons will be unable to depend on " +
|
|
||||||
"it.",
|
|
||||||
id, mod.metadata().version().raw());
|
|
||||||
}
|
|
||||||
return Stream.empty();
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "minecraft",
|
"id": "minecraft",
|
||||||
"version": "1.19.x"
|
"version": "1.20.x"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "quilted_fabric_api",
|
"id": "quilted_fabric_api",
|
||||||
|
|||||||
Reference in new issue
Block a user