Adding Codecs to Custom SurfaceRules (paulevsGitch/BetterNether#503)
This commit is contained in:
parent
d78319802d
commit
7b789ba57a
3 changed files with 9 additions and 10 deletions
|
@ -9,11 +9,6 @@ import net.minecraft.world.level.levelgen.SurfaceRules.LazyXZCondition;
|
|||
import ru.bclib.mixin.common.SurfaceRulesContextAccessor;
|
||||
|
||||
public abstract class SurfaceNoiseCondition implements NoiseCondition{
|
||||
@Override
|
||||
public Codec<? extends ConditionSource> codec() {
|
||||
return SurfaceRules.ConditionSource.CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition apply(Context context2) {
|
||||
final SurfaceNoiseCondition self = this;
|
||||
|
|
|
@ -9,10 +9,7 @@ import net.minecraft.world.level.levelgen.SurfaceRules.LazyCondition;
|
|||
import ru.bclib.mixin.common.SurfaceRulesContextAccessor;
|
||||
|
||||
public abstract class VolumeNoiseCondition implements NoiseCondition{
|
||||
@Override
|
||||
public Codec<? extends ConditionSource> codec() {
|
||||
return SurfaceRules.ConditionSource.CODEC;
|
||||
}
|
||||
public abstract Codec<? extends ConditionSource> codec();
|
||||
|
||||
@Override
|
||||
public final Condition apply(Context context2) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ru.bclib.world.surface;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||
import ru.bclib.api.surface.rules.SurfaceNoiseCondition;
|
||||
import ru.bclib.mixin.common.SurfaceRulesContextAccessor;
|
||||
import ru.bclib.noise.OpenSimplexNoise;
|
||||
|
@ -8,12 +10,17 @@ 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);
|
||||
|
||||
public static final Codec<DoubleBlockSurfaceNoiseCondition> CODEC = Codec.DOUBLE.fieldOf("threshold").xmap(DoubleBlockSurfaceNoiseCondition::new, obj -> obj.threshold).codec();
|
||||
private final double threshold;
|
||||
public DoubleBlockSurfaceNoiseCondition(double threshold){
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<? extends SurfaceRules.ConditionSource> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
private static int lastX = Integer.MIN_VALUE;
|
||||
private static int lastZ = Integer.MIN_VALUE;
|
||||
private static double lastValue = 0;
|
||||
|
|
Loading…
Reference in a new issue