mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-02 22:06:17 +00:00
add toggle to offset noise types fixing seeds
This commit is contained in:
@@ -243,6 +243,7 @@ public class IrisSettings {
|
||||
public int maxBiomeChildDepth = 4;
|
||||
public boolean preventLeafDecay = true;
|
||||
public boolean useMulticore = false;
|
||||
public boolean offsetNoiseTypes = false;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -39,4 +39,8 @@ public interface NoiseGenerator {
|
||||
default ProceduralStream<Double> stream() {
|
||||
return ProceduralStream.of(this::noise, this::noise, Interpolated.DOUBLE);
|
||||
}
|
||||
|
||||
default OffsetNoiseGenerator offset(long seed) {
|
||||
return new OffsetNoiseGenerator(this, seed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.util.noise;
|
||||
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.util.interpolation.InterpolationMethod;
|
||||
|
||||
public enum NoiseType {
|
||||
@@ -77,6 +78,7 @@ public enum NoiseType {
|
||||
}
|
||||
|
||||
public NoiseGenerator create(long seed) {
|
||||
return f.create(seed);
|
||||
if (IrisSettings.get().getGenerator().offsetNoiseTypes) return f.create(seed).offset(seed);
|
||||
else return f.create(seed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.volmit.iris.util.noise;
|
||||
|
||||
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class OffsetNoiseGenerator implements NoiseGenerator {
|
||||
private final NoiseGenerator base;
|
||||
private final double ox, oz;
|
||||
|
||||
public OffsetNoiseGenerator(NoiseGenerator base, long seed) {
|
||||
this.base = base;
|
||||
RNG rng = new RNG(seed);
|
||||
ox = rng.nextInt(Short.MIN_VALUE, Short.MAX_VALUE);
|
||||
oz = rng.nextInt(Short.MIN_VALUE, Short.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
return base.noise(x + ox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
return base.noise(x + ox, z + oz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return base.noise(x + ox, y, z + oz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNoScale() {
|
||||
return base.isNoScale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return base.isStatic();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public NoiseGenerator getBase() {
|
||||
return base;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user