mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
add biome specific vars
This commit is contained in:
parent
f6967be95f
commit
dfec463765
@ -48,12 +48,16 @@ public class GeneratorBuilder {
|
||||
|
||||
private double blendWeight;
|
||||
|
||||
private Map<String, Double> variables = new HashMap<>();
|
||||
|
||||
public WorldGenerator build(long seed) {
|
||||
synchronized(gens) {
|
||||
return gens.computeIfAbsent(seed, k -> {
|
||||
NoiseSampler noise;
|
||||
NoiseSampler elevation;
|
||||
NoiseSampler carving;
|
||||
Scope biomeScope = new Scope().withParent(varScope);
|
||||
variables.forEach((id, val) -> biomeScope.create(id).setValue(val));
|
||||
try {
|
||||
noise = new ExpressionSampler(noiseEquation, varScope, seed, noiseBuilderMap);
|
||||
elevation = elevationEquation == null ? new ConstantSampler(0) : new ExpressionSampler(elevationEquation, varScope, seed, noiseBuilderMap);
|
||||
@ -66,6 +70,10 @@ public class GeneratorBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public void setVariables(Map<String, Double> variables) {
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
public void setBlendWeight(double blendWeight) {
|
||||
this.blendWeight = blendWeight;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import parsii.eval.Parser;
|
||||
import parsii.eval.Scope;
|
||||
import parsii.tokenizer.ParseException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -42,6 +43,11 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
@Default
|
||||
private String extend = null;
|
||||
|
||||
@Value("variables")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<String, Double> variables = new HashMap<>();
|
||||
|
||||
@Value("carving.equation")
|
||||
@Abstractable
|
||||
@Default
|
||||
@ -308,11 +314,18 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
return blendStep;
|
||||
}
|
||||
|
||||
public Map<String, Double> getVariables() {
|
||||
return variables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() throws ValidationException {
|
||||
color |= 0x1fe00000; // Alpha adjustment
|
||||
Parser tester = new Parser();
|
||||
Scope testScope = new Scope().withParent(pack.getVarScope());
|
||||
|
||||
variables.forEach((id, val) -> testScope.create(id).setValue(val));
|
||||
|
||||
testScope.create("x");
|
||||
testScope.create("y");
|
||||
testScope.create("z");
|
||||
|
Loading…
x
Reference in New Issue
Block a user