Migrated to SurfaceBuilder

This commit is contained in:
Frank 2021-12-15 10:25:01 +01:00
parent ce727b2633
commit 65dd58d86f
23 changed files with 137 additions and 94 deletions

View file

@ -1,39 +1,29 @@
package ru.betterend.world.surface;
import ru.bclib.api.surface.rules.SurfaceNoiseCondition;
import ru.bclib.interfaces.NumericProvider;
import ru.bclib.mixin.common.SurfaceRulesContextAccessor;
import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
public class UmbraSurfaceNoiseCondition extends SurfaceNoiseCondition {
/**
* Noise source that returns a value in [0, 4]
*/
public class UmbraSurfaceNoiseCondition implements NumericProvider {
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(1512);
private final double threshold;
public UmbraSurfaceNoiseCondition(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) {
public int getNumber(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.03, z * 0.03) + NOISE.eval(x * 0.1, z * 0.1) * 0.3 + MHelper.randRange(
final double value = NOISE.eval(x * 0.03, z * 0.03) + NOISE.eval(x * 0.1, z * 0.1) * 0.3 + MHelper.randRange(
-0.1,
0.1,
MHelper.RANDOM
);
lastX=x;
lastZ=z;
lastValue=value;
return value > threshold;
//int depth = (int) (NOISE.eval(x * 0.1, z * 0.1) * 20 + NOISE.eval(x * 0.5, z * 0.5) * 10 + 60);
//SurfaceBuilder.DEFAULT.apply(random, chunk, biome, x, z, height, noise + depth, defaultBlock, defaultFluid, seaLevel, seed, n, config);
if (value > 0.4) return 0;
if (value > 0.15) return 1;
if (value > -0.15) return 2;
if (value > -0.4) return 3;
return 4;
}
}