Example implementation of custom noise for SurfaceRules

This commit is contained in:
Frank 2021-12-08 19:50:26 +01:00
parent 1c79354e13
commit e8a40246b4
3 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,28 @@
package ru.betterend.world.surface;
import ru.bclib.api.biomes.SurfaceNoiseCondition;
import ru.bclib.mixin.common.SurfaceRulesContextAccessor;
import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
public class SulphuricSurfaceNoiseCondition extends SurfaceNoiseCondition {
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(5123);
private final double threshold;
public SulphuricSurfaceNoiseCondition(double threshold){
this.threshold = threshold;
}
@Override
public boolean test(SurfaceRulesContextAccessor context) {
final int x = context.getBlockX();
final int z = context.getBlockZ();
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
);
return value < threshold;
}
}