mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 14:56:28 +00:00
Merge remote-tracking branch 'origin/ver/7.0.0' into dev/pure
This commit is contained in:
@@ -52,8 +52,8 @@ fun Project.configureDependencies() {
|
||||
maven("https://jitpack.io") {
|
||||
name = "JitPack"
|
||||
}
|
||||
maven("Modrinth") {
|
||||
url = uri("https://api.modrinth.com/maven")
|
||||
maven("https://api.modrinth.com/maven") {
|
||||
name = "Modrinth"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ 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.RidgedFractalTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.ClampNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearMapNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.LinearNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.NormalNormalizerTemplate;
|
||||
import com.dfsek.terra.addons.noise.config.templates.normalizer.PosterizationNormalizerTemplate;
|
||||
@@ -88,6 +89,7 @@ public class NoiseAddon implements MonadAddonInitializer {
|
||||
.applyLoader(FunctionTemplate.class, FunctionTemplate::new);
|
||||
|
||||
noiseRegistry.register(base.key("LINEAR"), LinearNormalizerTemplate::new);
|
||||
noiseRegistry.register(base.key("LINEAR_MAP"), LinearMapNormalizerTemplate::new);
|
||||
noiseRegistry.register(base.key("NORMAL"), NormalNormalizerTemplate::new);
|
||||
noiseRegistry.register(base.key("CLAMP"), ClampNormalizerTemplate::new);
|
||||
noiseRegistry.register(base.key("PROBABILITY"), ProbabilityNormalizerTemplate::new);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.dfsek.terra.addons.noise.config.templates.normalizer;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Default;
|
||||
import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
|
||||
import com.dfsek.terra.addons.noise.normalizer.LinearMapNormalizer;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class LinearMapNormalizerTemplate extends NormalizerTemplate<LinearMapNormalizer> {
|
||||
|
||||
@Value("from.a")
|
||||
@Default
|
||||
private @Meta double aFrom = -1;
|
||||
|
||||
@Value("from.b")
|
||||
@Default
|
||||
private @Meta double bFrom = 1;
|
||||
|
||||
@Value("to.a")
|
||||
private @Meta double aTo;
|
||||
|
||||
@Value("to.b")
|
||||
private @Meta double bTo;
|
||||
|
||||
@Override
|
||||
public NoiseSampler get() {
|
||||
return new LinearMapNormalizer(function, aFrom, aTo, bFrom, bTo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.dfsek.terra.addons.noise.normalizer;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
|
||||
public class LinearMapNormalizer extends Normalizer {
|
||||
|
||||
private final double aFrom;
|
||||
|
||||
private final double aTo;
|
||||
|
||||
private final double bFrom;
|
||||
|
||||
private final double bTo;
|
||||
|
||||
public LinearMapNormalizer(NoiseSampler sampler, double aFrom, double aTo, double bFrom, double bTo) {
|
||||
super(sampler);
|
||||
this.aFrom = aFrom;
|
||||
this.aTo = aTo;
|
||||
this.bFrom = bFrom;
|
||||
this.bTo = bTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double normalize(double in) {
|
||||
return (in - aFrom) * (aTo - bTo) / (aFrom - bFrom) + aTo;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -66,20 +68,24 @@ public class StructureFunction implements Function<Boolean> {
|
||||
|
||||
|
||||
String app = id.apply(implementationArguments, scope);
|
||||
int xValue = FastMath.roundToInt(xz.getX());
|
||||
int yValue = y.apply(implementationArguments, scope).intValue();
|
||||
int zValue = FastMath.roundToInt(xz.getZ());
|
||||
Vector3Int origin = Vector3Int.of(xValue, yValue, zValue);
|
||||
return registry.getByID(app).map(script -> {
|
||||
if(script instanceof StructureScript structureScript) {
|
||||
return structureScript.generate(arguments.getOrigin(),
|
||||
return structureScript.generate(origin,
|
||||
arguments.getWorld()
|
||||
.buffer(FastMath.roundToInt(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())),
|
||||
.buffer(xValue,
|
||||
yValue,
|
||||
zValue),
|
||||
arguments.getRotation(), arguments.getRecursions() + 1);
|
||||
}
|
||||
return script.generate(arguments.getOrigin(),
|
||||
arguments.getWorld()
|
||||
.buffer(FastMath.roundToInt(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
FastMath.roundToInt(xz.getZ())),
|
||||
.buffer(xValue,
|
||||
yValue,
|
||||
zValue),
|
||||
arguments.getRotation());
|
||||
}).orElseGet(() -> {
|
||||
LOGGER.error("No such structure {}", app);
|
||||
|
||||
@@ -74,6 +74,7 @@ mod_lazy-dfu = { module = "maven.modrinth:lazydfu", version.ref = "mod_lazy-dfu"
|
||||
mod_cloud-fabric = { module = "cloud.commandframework:cloud-fabric", version.ref = "libraries_cloud" }
|
||||
|
||||
mod_fabric_fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "mod_fabric_fabric-loader" }
|
||||
mod_fabric_fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "mod_fabric_fabric-api" }
|
||||
|
||||
mod_quilt_quilt-loader = { module = "org.quiltmc:quilt-loader", version.ref = "mod_quilt_quilt-loader" }
|
||||
mod_quilt_fabric-api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "mod_quilt_fabric-api" }
|
||||
|
||||
@@ -19,6 +19,8 @@ dependencies {
|
||||
"developmentFabric"(project(path = ":platforms:mixin-lifecycle", configuration = "namedElements")) { isTransitive = false }
|
||||
shaded(project(path = ":platforms:mixin-lifecycle", configuration = "transformProductionFabric")) { isTransitive = false }
|
||||
|
||||
modRuntimeOnly(libs.mod.fabric.fabric.api)
|
||||
|
||||
minecraft(libs.mod.minecraft)
|
||||
mappings("net.fabricmc", "yarn", libs.versions.mod.yarn.get(), classifier = "v2")
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import ca.solostudios.strata.version.Version;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.mod.config.VanillaWorldProperties;
|
||||
|
||||
import com.dfsek.terra.mod.util.MinecraftUtil;
|
||||
@@ -52,12 +53,8 @@ public abstract class MinecraftAddon implements BaseAddon {
|
||||
public void initialize() {
|
||||
modPlatform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
if(event.is(ConfigPack.class)) {
|
||||
event.getLoadedObject(ConfigPack.class).getContext().put(event.load(new VanillaWorldProperties()));
|
||||
}
|
||||
})
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.loadTemplate(new VanillaWorldProperties()))
|
||||
.global();
|
||||
modPlatform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
|
||||
@@ -51,7 +51,7 @@ public class VanillaWorldProperties implements ConfigTemplate, Properties {
|
||||
@Default
|
||||
private Boolean respawnAnchorWorks = false;
|
||||
|
||||
@Value("minecraft.height")
|
||||
@Value("minecraft.height.range")
|
||||
@Default
|
||||
private Range height = new ConstantRange(0, 16);
|
||||
|
||||
|
||||
@@ -40,12 +40,18 @@ public class BiomeUtil {
|
||||
logger.info("Terra biomes registered.");
|
||||
}
|
||||
|
||||
public static RegistryKey<net.minecraft.world.biome.Biome> registerKey(Identifier identifier) {
|
||||
return RegistryKey.of(Registry.BIOME_KEY, identifier);
|
||||
}
|
||||
|
||||
protected static RegistryKey<net.minecraft.world.biome.Biome> registerBiome(Identifier identifier,
|
||||
net.minecraft.world.biome.Biome biome) {
|
||||
BuiltinRegistries.add(BuiltinRegistries.BIOME,
|
||||
MinecraftUtil.registerKey(identifier)
|
||||
.getValue(),
|
||||
biome);
|
||||
RegistryKey key = registerKey(identifier);
|
||||
if(!BuiltinRegistries.BIOME.contains(key)) {
|
||||
BuiltinRegistries.add(BuiltinRegistries.BIOME,
|
||||
key.getValue(),
|
||||
biome);
|
||||
}
|
||||
return getBiomeKey(identifier);
|
||||
}
|
||||
|
||||
@@ -62,11 +68,7 @@ public class BiomeUtil {
|
||||
protected static void registerBiome(Biome biome, ConfigPack pack,
|
||||
com.dfsek.terra.api.registry.key.RegistryKey id) {
|
||||
VanillaBiomeProperties vanillaBiomeProperties;
|
||||
if (biome.getContext().has(VanillaBiomeProperties.class)) {
|
||||
vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
} else {
|
||||
vanillaBiomeProperties = new VanillaBiomeProperties();
|
||||
}
|
||||
vanillaBiomeProperties = biome.getContext().get(VanillaBiomeProperties.class);
|
||||
|
||||
|
||||
net.minecraft.world.biome.Biome minecraftBiome = MinecraftUtil.createBiome(vanillaBiomeProperties);
|
||||
|
||||
@@ -18,10 +18,13 @@ import java.util.OptionalLong;
|
||||
public class DimensionUtil {
|
||||
protected static RegistryKey<DimensionType> registerDimension(Identifier identifier,
|
||||
DimensionType dimension) {
|
||||
BuiltinRegistries.add(BuiltinRegistries.DIMENSION_TYPE,
|
||||
registerKey(identifier)
|
||||
.getValue(),
|
||||
dimension);
|
||||
RegistryKey key = registerKey(identifier);
|
||||
if(!BuiltinRegistries.BIOME.contains(key)) {
|
||||
BuiltinRegistries.add(BuiltinRegistries.DIMENSION_TYPE,
|
||||
key
|
||||
.getValue(),
|
||||
dimension);
|
||||
}
|
||||
return getDimensionKey(identifier);
|
||||
}
|
||||
|
||||
@@ -34,11 +37,7 @@ public class DimensionUtil {
|
||||
|
||||
protected static RegistryKey<DimensionType> registerDimension(ConfigPack pack) {
|
||||
VanillaWorldProperties vanillaWorldProperties;
|
||||
if (pack.getContext().has(VanillaBiomeProperties.class)) {
|
||||
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
|
||||
} else {
|
||||
vanillaWorldProperties = new VanillaWorldProperties();
|
||||
}
|
||||
vanillaWorldProperties = pack.getContext().get(VanillaWorldProperties.class);
|
||||
|
||||
DimensionType overworldDimensionType = new DimensionType(
|
||||
vanillaWorldProperties.getFixedTime() == null ? OptionalLong.empty() : OptionalLong.of(vanillaWorldProperties.getFixedTime()),
|
||||
|
||||
@@ -68,10 +68,6 @@ public final class MinecraftUtil {
|
||||
TerraIntProvider.TERRA_RANGE_TYPE_TO_INT_PROVIDER_TYPE.put(ConstantRange.class, CONSTANT);
|
||||
}
|
||||
|
||||
public static RegistryKey<Biome> registerKey(Identifier identifier) {
|
||||
return RegistryKey.of(Registry.BIOME_KEY, identifier);
|
||||
}
|
||||
|
||||
public static Biome createBiome(VanillaBiomeProperties vanillaBiomeProperties) {
|
||||
|
||||
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"package": "com.dfsek.terra.mod.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"access.BiomeAccessor",
|
||||
"access.MobSpawnerLogicAccessor",
|
||||
"access.StateAccessor",
|
||||
"access.StructureAccessorAccessor",
|
||||
|
||||
Reference in New Issue
Block a user