Skip to content

Commit

Permalink
Merge branch 'ver/6.5.0' into dev/7.0-2
Browse files Browse the repository at this point in the history
  • Loading branch information
duplexsystem committed Sep 24, 2024
2 parents 2df2755 + 13782bb commit c95b3c0
Show file tree
Hide file tree
Showing 30 changed files with 1,125 additions and 86 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.dfsek.terra.addons.biome.extrusion.api;

import java.util.Collection;

import com.dfsek.terra.api.world.biome.Biome;

import java.util.Collection;


public interface Extrusion {
Biome extrude(Biome original, int x, int y, int z, long seed);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.dfsek.terra.addons.biome.pipeline.api.biome;

import com.dfsek.terra.api.world.biome.Biome;

import java.util.Collections;
import java.util.Set;

import com.dfsek.terra.api.world.biome.Biome;


final class SelfPipelineBiome implements PipelineBiome {
public static final SelfPipelineBiome INSTANCE = new SelfPipelineBiome();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

package com.dfsek.terra.addons.biome.holder;

import com.dfsek.terra.api.world.chunk.generation.util.Palette;

import java.util.Map;
import java.util.TreeMap;

import com.dfsek.terra.api.world.chunk.generation.util.Palette;


public class PaletteHolderBuilder {
private final TreeMap<Integer, Palette> paletteMap = new TreeMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

package com.dfsek.terra.addons.feature.distributor.distributors;

import java.util.Set;

import com.dfsek.terra.addons.feature.distributor.util.Point;
import com.dfsek.terra.api.structure.feature.Distributor;

import java.util.Set;


public class PointSetDistributor implements Distributor {
private final Set<Point> points;
Expand Down
2 changes: 1 addition & 1 deletion common/addons/config-noise-function/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = version("1.1.0")
version = version("1.2.0")

dependencies {
compileOnlyApi(project(":common:addons:manifest-addon-loader"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,46 @@

import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Supplier;

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.templates.*;
import com.dfsek.terra.addons.noise.config.templates.noise.*;
import com.dfsek.terra.addons.noise.config.templates.BinaryArithmeticTemplate;
import com.dfsek.terra.addons.noise.config.templates.DerivativeNoiseSamplerTemplate;
import com.dfsek.terra.addons.noise.config.templates.DomainWarpTemplate;
import com.dfsek.terra.addons.noise.config.templates.FunctionTemplate;
import com.dfsek.terra.addons.noise.config.templates.ImageSamplerTemplate;
import com.dfsek.terra.addons.noise.config.templates.KernelTemplate;
import com.dfsek.terra.addons.noise.config.templates.LinearHeightmapSamplerTemplate;
import com.dfsek.terra.addons.noise.config.templates.TranslateSamplerTemplate;
import com.dfsek.terra.addons.noise.config.templates.noise.CellularNoiseTemplate;
import com.dfsek.terra.addons.noise.config.templates.noise.ConstantNoiseTemplate;
import com.dfsek.terra.addons.noise.config.templates.noise.DistanceSamplerTemplate;
import com.dfsek.terra.addons.noise.config.templates.noise.ExpressionFunctionTemplate;
import com.dfsek.terra.addons.noise.config.templates.noise.GaborNoiseTemplate;
import com.dfsek.terra.addons.noise.config.templates.noise.PseudoErosionTemplate;
import com.dfsek.terra.addons.noise.config.templates.noise.SimpleNoiseTemplate;
import com.dfsek.terra.addons.noise.config.templates.noise.fractal.BrownianMotionTemplate;
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.*;
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.LinearNormalizerTemplate;
import com.dfsek.terra.addons.noise.config.templates.normalizer.NormalNormalizerTemplate;
import com.dfsek.terra.addons.noise.config.templates.normalizer.PosterizationNormalizerTemplate;
import com.dfsek.terra.addons.noise.config.templates.normalizer.ProbabilityNormalizerTemplate;
import com.dfsek.terra.addons.noise.config.templates.normalizer.ScaleNormalizerTemplate;
import com.dfsek.terra.addons.noise.math.CubicSpline;
import com.dfsek.terra.addons.noise.samplers.arithmetic.*;
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.MaxSampler;
import com.dfsek.terra.addons.noise.samplers.arithmetic.MinSampler;
import com.dfsek.terra.addons.noise.samplers.arithmetic.MultiplicationSampler;
import com.dfsek.terra.addons.noise.samplers.arithmetic.SubtractionSampler;
import com.dfsek.terra.addons.noise.samplers.noise.CellularSampler;
import com.dfsek.terra.addons.noise.samplers.noise.DistanceSampler;
import com.dfsek.terra.addons.noise.samplers.noise.random.GaussianNoiseSampler;
Expand All @@ -36,14 +65,11 @@
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.noise.DerivativeNoiseSampler;
import com.dfsek.terra.api.noise.NoiseSampler;
import com.dfsek.terra.api.registry.CheckedRegistry;
import com.dfsek.terra.api.util.reflection.TypeKey;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Supplier;


public class NoiseAddon implements AddonInitializer {
public static final TypeKey<Supplier<ObjectTemplate<NoiseSampler>>> NOISE_SAMPLER_TOKEN = new TypeKey<>() {
Expand Down Expand Up @@ -71,7 +97,8 @@ public void initialize() {
(type, o, loader, depthTracker) -> DistanceSampler.DistanceFunction.valueOf((String) o))
.applyLoader(DimensionApplicableNoiseSampler.class, DimensionApplicableNoiseSampler::new)
.applyLoader(FunctionTemplate.class, FunctionTemplate::new)
.applyLoader(CubicSpline.Point.class, CubicSplinePointTemplate::new);
.applyLoader(CubicSpline.Point.class, CubicSplinePointTemplate::new)
.applyLoader(DerivativeNoiseSampler.class, DerivativeNoiseSamplerTemplate::new);

noiseRegistry.register(addon.key("LINEAR"), LinearNormalizerTemplate::new);
noiseRegistry.register(addon.key("LINEAR_MAP"), LinearMapNormalizerTemplate::new);
Expand All @@ -95,7 +122,7 @@ public void initialize() {
noiseRegistry.register(addon.key("PERLIN"), () -> new SimpleNoiseTemplate(PerlinSampler::new));
noiseRegistry.register(addon.key("SIMPLEX"), () -> new SimpleNoiseTemplate(SimplexSampler::new));
noiseRegistry.register(addon.key("GABOR"), GaborNoiseTemplate::new);

noiseRegistry.register(addon.key("PSEUDOEROSION"), PseudoErosionTemplate::new);

noiseRegistry.register(addon.key("VALUE"), () -> new SimpleNoiseTemplate(ValueSampler::new));
noiseRegistry.register(addon.key("VALUE_CUBIC"), () -> new SimpleNoiseTemplate(ValueCubicSampler::new));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;

import java.util.LinkedHashMap;
import java.util.Map;

import com.dfsek.terra.addons.noise.config.DimensionApplicableNoiseSampler;
import com.dfsek.terra.addons.noise.config.templates.FunctionTemplate;
import com.dfsek.terra.api.config.meta.Meta;
import com.dfsek.terra.api.properties.Properties;

import java.util.LinkedHashMap;
import java.util.Map;


@SuppressWarnings("FieldMayBeFinal")
public class NoiseConfigPackTemplate implements ConfigTemplate, Properties {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.dfsek.terra.addons.noise.config.templates;

import com.dfsek.tectonic.api.config.template.annotations.Value;
import com.dfsek.tectonic.api.exception.ValidationException;

import com.dfsek.terra.api.noise.DerivativeNoiseSampler;
import com.dfsek.terra.api.noise.NoiseSampler;


public class DerivativeNoiseSamplerTemplate extends SamplerTemplate<DerivativeNoiseSampler> {

@Value(".")
private NoiseSampler sampler;

@Override
public boolean validate() throws ValidationException {
if(!DerivativeNoiseSampler.isDifferentiable(sampler)) throw new ValidationException(
"Provided sampler does not support calculating a derivative");
return super.validate();
}

@Override
public DerivativeNoiseSampler get() {
return (DerivativeNoiseSampler) sampler;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
package com.dfsek.terra.addons.noise.config.templates;

import com.dfsek.tectonic.api.config.template.annotations.Value;

import com.dfsek.terra.addons.noise.samplers.ImageSampler;
import com.dfsek.terra.api.config.meta.Meta;
import com.dfsek.terra.api.noise.NoiseSampler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.awt.image.BufferedImage;

import com.dfsek.terra.addons.noise.samplers.ImageSampler;
import com.dfsek.terra.api.config.meta.Meta;
import com.dfsek.terra.api.noise.NoiseSampler;


@SuppressWarnings({ "unused", "FieldMayBeFinal" })
public class ImageSamplerTemplate extends SamplerTemplate<ImageSampler> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.dfsek.terra.addons.noise.config.templates.noise;

import com.dfsek.terra.addons.noise.samplers.noise.DerivativeNoiseFunction;


public abstract class DerivativeNoiseTemplate<T extends DerivativeNoiseFunction> extends NoiseTemplate<T> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.dfsek.terra.addons.noise.config.templates.noise;

import com.dfsek.tectonic.api.config.template.annotations.Default;
import com.dfsek.tectonic.api.config.template.annotations.Value;

import com.dfsek.terra.addons.noise.samplers.noise.PseudoErosionSampler;
import com.dfsek.terra.addons.noise.samplers.noise.simplex.OpenSimplex2Sampler;
import com.dfsek.terra.api.config.meta.Meta;
import com.dfsek.terra.api.noise.DerivativeNoiseSampler;


public class PseudoErosionTemplate extends NoiseTemplate<PseudoErosionSampler> {
@Value("frequency")
@Default
protected @Meta double frequency = 1d;

@Value("octaves")
@Default
private int octaves = 4;

@Value("lacunarity")
@Default
private double lacunarity = 2.0;

@Value("gain")
@Default
private double gain = 0.5;

@Value("slope-strength")
@Default
private double slopeStrength = 1.0;


@Value("branch-strength")
@Default
private double branchStrength = 1.0;

@Value("strength")
@Default
private double strength = 0.04;

@Value("erosion-frequency")
@Default
private double erosionFrequency = 0.02;

@Value("sampler")
@Default
private DerivativeNoiseSampler heightSampler = new OpenSimplex2Sampler();

@Value("slope-mask.enable")
@Default
private boolean slopeMask = true;

@Value("slope-mask.none")
@Default
private double slopeMaskNone = -0.5;

@Value("slope-mask.full")
@Default
private double slopeMaskFull = 1;

@Value("jitter")
@Default
private double jitterModifier = 1;

@Value("average-impulses")
@Default
private boolean averageErosionImpulses = true;

@Override
public PseudoErosionSampler get() {
PseudoErosionSampler pseudoErosion = new PseudoErosionSampler(octaves, gain, lacunarity,
slopeStrength, branchStrength, strength,
erosionFrequency, heightSampler, slopeMask, slopeMaskFull, slopeMaskNone, jitterModifier, averageErosionImpulses);
pseudoErosion.setFrequency(frequency);
pseudoErosion.setSalt(salt);
return pseudoErosion;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.dfsek.terra.addons.noise.samplers.noise;

import com.dfsek.terra.api.noise.DerivativeNoiseSampler;


public abstract class DerivativeNoiseFunction extends NoiseFunction implements DerivativeNoiseSampler {
@Override
public boolean isDifferentiable() {
return true;
}

@Override
public double[] noised(long seed, double x, double y) {
return getNoiseDerivativeRaw(seed + salt, x * frequency, y * frequency);
}

@Override
public double[] noised(long seed, double x, double y, double z) {
return getNoiseDerivativeRaw(seed + salt, x * frequency, y * frequency, z * frequency);
}

public abstract double[] getNoiseDerivativeRaw(long seed, double x, double y);

public abstract double[] getNoiseDerivativeRaw(long seed, double x, double y, double z);
}
Loading

0 comments on commit c95b3c0

Please sign in to comment.