Example implementation of custom noise for SurfaceRules
This commit is contained in:
parent
1c79354e13
commit
e8a40246b4
3 changed files with 40 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue