Ported old noise generator for double-block biomes
This commit is contained in:
parent
45a24d4f8e
commit
8db15979a0
2 changed files with 36 additions and 1 deletions
|
@ -39,6 +39,7 @@ import ru.bclib.util.ColorUtil;
|
|||
import ru.bclib.world.biomes.BCLBiome;
|
||||
import ru.bclib.world.features.BCLFeature;
|
||||
import ru.bclib.world.structures.BCLStructureFeature;
|
||||
import ru.bclib.world.surface.DoubleBlockSurfaceNoiseCondition;
|
||||
|
||||
public class BCLBiomeBuilder {
|
||||
private static final BCLBiomeBuilder INSTANCE = new BCLBiomeBuilder();
|
||||
|
@ -538,7 +539,7 @@ public class BCLBiomeBuilder {
|
|||
SurfaceRules.sequence(
|
||||
SurfaceRules.ifTrue(SurfaceRules.ON_FLOOR,
|
||||
SurfaceRules.sequence(
|
||||
SurfaceRules.ifTrue(SurfaceRules.noiseCondition(Noises.SURFACE, -0.1818, 0.1818), surfaceBlockA),
|
||||
SurfaceRules.ifTrue(DoubleBlockSurfaceNoiseCondition.CONDITION, surfaceBlockA),
|
||||
surfaceBlockB
|
||||
)
|
||||
),
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package ru.bclib.world.surface;
|
||||
|
||||
import ru.bclib.api.biomes.SurfaceNoiseCondition;
|
||||
import ru.bclib.mixin.common.SurfaceRulesContextAccessor;
|
||||
import ru.bclib.noise.OpenSimplexNoise;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
public class DoubleBlockSurfaceNoiseCondition extends SurfaceNoiseCondition {
|
||||
public static final DoubleBlockSurfaceNoiseCondition CONDITION = new DoubleBlockSurfaceNoiseCondition(0);
|
||||
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(4141);
|
||||
|
||||
private final double threshold;
|
||||
public DoubleBlockSurfaceNoiseCondition(double threshold){
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
private static int lastX = Integer.MIN_VALUE;
|
||||
private static int lastZ = Integer.MIN_VALUE;
|
||||
private static double lastValue = 0;
|
||||
|
||||
@Override
|
||||
public boolean test(SurfaceRulesContextAccessor context) {
|
||||
final int x = context.getBlockX();
|
||||
final int z = context.getBlockZ();
|
||||
if (lastX==x && lastZ==z) return lastValue > threshold;
|
||||
|
||||
double value = NOISE.eval(x * 0.1, z * 0.1) + MHelper.randRange(-0.4, 0.4, MHelper.RANDOM);
|
||||
|
||||
lastX=x;
|
||||
lastZ=z;
|
||||
lastValue=value;
|
||||
return value > threshold;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue