mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 18:42:30 +00:00
Make NoiseBuilder actually follow builder pattern
This commit is contained in:
parent
00c933c06e
commit
b8441b6903
@ -12,32 +12,32 @@ public class NoiseConfig {
|
|||||||
public NoiseConfig(ConfigurationSection section) throws ConfigException {
|
public NoiseConfig(ConfigurationSection section) throws ConfigException {
|
||||||
NoiseBuilder builder = new NoiseBuilder();
|
NoiseBuilder builder = new NoiseBuilder();
|
||||||
try {
|
try {
|
||||||
builder.setType(FastNoiseLite.NoiseType.valueOf(section.getString("type", "OpenSimplex2")));
|
builder.setType(FastNoiseLite.NoiseType.valueOf(section.getString("type", "OpenSimplex2")))
|
||||||
builder.setFrequency(section.getDouble("frequency", 0.02D));
|
.setFrequency(section.getDouble("frequency", 0.02D))
|
||||||
|
.setRotationType3D(FastNoiseLite.RotationType3D.valueOf(section.getString("rotation", "None")));
|
||||||
|
|
||||||
dimensions = section.getInt("dimensions", 3);
|
dimensions = section.getInt("dimensions", 3);
|
||||||
if(dimensions != 2 && dimensions != 3)
|
if(dimensions != 2 && dimensions != 3)
|
||||||
throw new ConfigException("Invalid number of dimensions: " + dimensions, "Noise");
|
throw new ConfigException("Invalid number of dimensions: " + dimensions, "Noise");
|
||||||
|
|
||||||
builder.setRotationType3D(FastNoiseLite.RotationType3D.valueOf(section.getString("rotation", "None")));
|
|
||||||
|
|
||||||
if(section.contains("fractal")) {
|
if(section.contains("fractal")) {
|
||||||
builder.setFractalType(FastNoiseLite.FractalType.valueOf(section.getString("fractal.type", "FBm")));
|
builder.setFractalType(FastNoiseLite.FractalType.valueOf(section.getString("fractal.type", "FBm")))
|
||||||
builder.setOctaves(section.getInt("fractal.octaves", 1));
|
.setOctaves(section.getInt("fractal.octaves", 1))
|
||||||
builder.setFractalGain(section.getDouble("fractal.gain", 0.5D));
|
.setFractalGain(section.getDouble("fractal.gain", 0.5D))
|
||||||
builder.setFractalLacunarity(section.getDouble("fractal.lacunarity", 2.0D));
|
.setFractalLacunarity(section.getDouble("fractal.lacunarity", 2.0D))
|
||||||
builder.setPingPong(section.getDouble("fractal.ping-pong", 2.0D));
|
.setPingPong(section.getDouble("fractal.ping-pong", 2.0D))
|
||||||
builder.setWeightedStrength(section.getDouble("fractal.weighted-strength", 0.0D));
|
.setWeightedStrength(section.getDouble("fractal.weighted-strength", 0.0D));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(section.contains("cellular")) {
|
if(section.contains("cellular")) {
|
||||||
builder.setCellularDistanceFunction(FastNoiseLite.CellularDistanceFunction.valueOf(section.getString("cellular.distance", "EuclideanSq")));
|
builder.setCellularDistanceFunction(FastNoiseLite.CellularDistanceFunction.valueOf(section.getString("cellular.distance", "EuclideanSq")))
|
||||||
builder.setCellularReturnType(FastNoiseLite.CellularReturnType.valueOf(section.getString("cellular.return", "Distance")));
|
.setCellularReturnType(FastNoiseLite.CellularReturnType.valueOf(section.getString("cellular.return", "Distance")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(section.contains("warp")) {
|
if(section.contains("warp")) {
|
||||||
builder.setDomainWarpType(FastNoiseLite.DomainWarpType.valueOf(section.getString("warp.type", "OpenSimplex2")));
|
builder.setDomainWarpType(FastNoiseLite.DomainWarpType.valueOf(section.getString("warp.type", "OpenSimplex2")))
|
||||||
builder.setDomainWarpAmp(section.getDouble("warp.amplitude", 1.0D));
|
.setDomainWarpAmp(section.getDouble("warp.amplitude", 1.0D));
|
||||||
}
|
}
|
||||||
this.builder = builder;
|
this.builder = builder;
|
||||||
} catch(IllegalArgumentException | ClassCastException e) {
|
} catch(IllegalArgumentException | ClassCastException e) {
|
||||||
|
@ -48,64 +48,78 @@ public class NoiseBuilder {
|
|||||||
return noise;
|
return noise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFrequency(double frequency) {
|
public NoiseBuilder setFrequency(double frequency) {
|
||||||
this.frequency = frequency;
|
this.frequency = frequency;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFractalGain(double fractalGain) {
|
public NoiseBuilder setFractalGain(double fractalGain) {
|
||||||
this.fractalGain = fractalGain;
|
this.fractalGain = fractalGain;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFractalLacunarity(double fractalLacunarity) {
|
public NoiseBuilder setFractalLacunarity(double fractalLacunarity) {
|
||||||
this.fractalLacunarity = fractalLacunarity;
|
this.fractalLacunarity = fractalLacunarity;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFractalType(FastNoiseLite.FractalType fractalType) {
|
public NoiseBuilder setFractalType(FastNoiseLite.FractalType fractalType) {
|
||||||
this.fractalType = fractalType;
|
this.fractalType = fractalType;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOctaves(int octaves) {
|
public NoiseBuilder setOctaves(int octaves) {
|
||||||
this.octaves = octaves;
|
this.octaves = octaves;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPingPong(double pingPong) {
|
public NoiseBuilder setPingPong(double pingPong) {
|
||||||
this.pingPong = pingPong;
|
this.pingPong = pingPong;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWeightedStrength(double weightedStrength) {
|
public NoiseBuilder setWeightedStrength(double weightedStrength) {
|
||||||
this.weightedStrength = weightedStrength;
|
this.weightedStrength = weightedStrength;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FastNoiseLite.NoiseType getType() {
|
public FastNoiseLite.NoiseType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(FastNoiseLite.NoiseType type) {
|
public NoiseBuilder setType(FastNoiseLite.NoiseType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCellularDistanceFunction(FastNoiseLite.CellularDistanceFunction cellularDistanceFunction) {
|
public NoiseBuilder setCellularDistanceFunction(FastNoiseLite.CellularDistanceFunction cellularDistanceFunction) {
|
||||||
this.cellularDistanceFunction = cellularDistanceFunction;
|
this.cellularDistanceFunction = cellularDistanceFunction;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCellularReturnType(FastNoiseLite.CellularReturnType cellularReturnType) {
|
public NoiseBuilder setCellularReturnType(FastNoiseLite.CellularReturnType cellularReturnType) {
|
||||||
this.cellularReturnType = cellularReturnType;
|
this.cellularReturnType = cellularReturnType;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCellularJitter(double cellularJitter) {
|
public NoiseBuilder setCellularJitter(double cellularJitter) {
|
||||||
this.cellularJitter = cellularJitter;
|
this.cellularJitter = cellularJitter;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDomainWarpAmp(double domainWarpAmp) {
|
public NoiseBuilder setDomainWarpAmp(double domainWarpAmp) {
|
||||||
this.domainWarpAmp = domainWarpAmp;
|
this.domainWarpAmp = domainWarpAmp;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDomainWarpType(FastNoiseLite.DomainWarpType domainWarpType) {
|
public NoiseBuilder setDomainWarpType(FastNoiseLite.DomainWarpType domainWarpType) {
|
||||||
this.domainWarpType = domainWarpType;
|
this.domainWarpType = domainWarpType;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRotationType3D(FastNoiseLite.RotationType3D rotationType3D) {
|
public NoiseBuilder setRotationType3D(FastNoiseLite.RotationType3D rotationType3D) {
|
||||||
this.rotationType3D = rotationType3D;
|
this.rotationType3D = rotationType3D;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FastNoiseLite.CellularDistanceFunction getCellularDistanceFunction() {
|
public FastNoiseLite.CellularDistanceFunction getCellularDistanceFunction() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user