mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-16 22:01:07 +00:00
configurable blend weight
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
package com.dfsek.terra.api.util.mutable;
|
||||||
|
|
||||||
|
public class MutableBoolean implements MutablePrimitive<Boolean> {
|
||||||
|
private boolean value;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean get() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(Boolean value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean invert() {
|
||||||
|
value = !value;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.dfsek.terra.api.util.mutable;
|
||||||
|
|
||||||
|
public class MutableDouble extends MutableNumber<Double> {
|
||||||
|
public MutableDouble(Double value) {
|
||||||
|
super(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void increment() {
|
||||||
|
add(1d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decrement() {
|
||||||
|
subtract(1d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(Double add) {
|
||||||
|
value += add;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void multiply(Double mul) {
|
||||||
|
value *= mul;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void subtract(Double sub) {
|
||||||
|
value -= sub;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void divide(Double divide) {
|
||||||
|
value /= divide;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ public class MutableInteger extends MutableNumber<Integer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void decrement() {
|
public void decrement() {
|
||||||
add(-1);
|
subtract(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -40,12 +40,18 @@ public class GeneratorBuilder {
|
|||||||
|
|
||||||
private int blendStep;
|
private int blendStep;
|
||||||
|
|
||||||
|
private double blendWeight;
|
||||||
|
|
||||||
public WorldGenerator build(long seed) {
|
public WorldGenerator build(long seed) {
|
||||||
synchronized(gens) {
|
synchronized(gens) {
|
||||||
return gens.computeIfAbsent(seed, k -> new WorldGenerator(seed, noiseEquation, elevationEquation, varScope, noiseBuilderMap, palettes, slantPalettes, noise2d, base, biomeNoise.build((int) seed), elevationWeight, blendDistance, blendStep));
|
return gens.computeIfAbsent(seed, k -> new WorldGenerator(seed, noiseEquation, elevationEquation, varScope, noiseBuilderMap, palettes, slantPalettes, noise2d, base, biomeNoise.build((int) seed), elevationWeight, blendDistance, blendStep, blendWeight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBlendWeight(double blendWeight) {
|
||||||
|
this.blendWeight = blendWeight;
|
||||||
|
}
|
||||||
|
|
||||||
public void setBlendStep(int blendStep) {
|
public void setBlendStep(int blendStep) {
|
||||||
this.blendStep = blendStep;
|
this.blendStep = blendStep;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public class BiomeFactory implements TerraFactory<BiomeTemplate, TerraBiome> {
|
|||||||
generatorBuilder.setBiomeNoise(template.getBiomeNoise());
|
generatorBuilder.setBiomeNoise(template.getBiomeNoise());
|
||||||
generatorBuilder.setBlendDistance(template.getBlendDistance());
|
generatorBuilder.setBlendDistance(template.getBlendDistance());
|
||||||
generatorBuilder.setBlendStep(template.getBlendStep());
|
generatorBuilder.setBlendStep(template.getBlendStep());
|
||||||
|
generatorBuilder.setBlendWeight(template.getBlendWeight());
|
||||||
|
|
||||||
|
|
||||||
return new UserDefinedBiome(template.getVanilla(), generatorBuilder, template);
|
return new UserDefinedBiome(template.getVanilla(), generatorBuilder, template);
|
||||||
|
|||||||
@@ -75,7 +75,13 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
|||||||
@Default
|
@Default
|
||||||
private int blendDistance = 3;
|
private int blendDistance = 3;
|
||||||
|
|
||||||
|
@Value("blend.weight")
|
||||||
|
@Abstractable
|
||||||
|
@Default
|
||||||
|
private double blendWeight = 1;
|
||||||
|
|
||||||
@Value("blend.step")
|
@Value("blend.step")
|
||||||
|
@Abstractable
|
||||||
@Default
|
@Default
|
||||||
private int blendStep = 4;
|
private int blendStep = 4;
|
||||||
|
|
||||||
@@ -170,6 +176,10 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
|||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getBlendWeight() {
|
||||||
|
return blendWeight;
|
||||||
|
}
|
||||||
|
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ public class WorldGenerator implements Generator {
|
|||||||
private final double elevationWeight;
|
private final double elevationWeight;
|
||||||
private final int blendDistance;
|
private final int blendDistance;
|
||||||
private final int blendStep;
|
private final int blendStep;
|
||||||
|
private final double blendWeight;
|
||||||
|
|
||||||
public WorldGenerator(long seed, String equation, String elevateEquation, Scope vScope, Map<String, NoiseBuilder> noiseBuilders, PaletteHolder palettes, PaletteHolder slantPalettes, boolean noise2d, double base, NoiseSampler biomeNoise, double elevationWeight, int blendDistance, int blendStep) {
|
public WorldGenerator(long seed, String equation, String elevateEquation, Scope vScope, Map<String, NoiseBuilder> noiseBuilders, PaletteHolder palettes, PaletteHolder slantPalettes, boolean noise2d, double base, NoiseSampler biomeNoise, double elevationWeight, int blendDistance, int blendStep, double blendWeight) {
|
||||||
this.palettes = palettes;
|
this.palettes = palettes;
|
||||||
this.slantPalettes = slantPalettes;
|
this.slantPalettes = slantPalettes;
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ public class WorldGenerator implements Generator {
|
|||||||
this.elevationWeight = elevationWeight;
|
this.elevationWeight = elevationWeight;
|
||||||
this.blendDistance = blendDistance;
|
this.blendDistance = blendDistance;
|
||||||
this.blendStep = blendStep;
|
this.blendStep = blendStep;
|
||||||
|
this.blendWeight = blendWeight;
|
||||||
|
|
||||||
Parser p = new Parser();
|
Parser p = new Parser();
|
||||||
p.registerFunction("rand", new RandomFunction());
|
p.registerFunction("rand", new RandomFunction());
|
||||||
@@ -104,7 +106,7 @@ public class WorldGenerator implements Generator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getWeight() {
|
public double getWeight() {
|
||||||
return 1;
|
return blendWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user