mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 06:46:21 +00:00
BooleanOperator -> RelationalOperator
This commit is contained in:
@@ -38,7 +38,7 @@ import com.dfsek.terra.addons.chunkgenerator.config.sampler.SimpleLayerSamplerTe
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.LayeredChunkGenerator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.layer.palette.BiomeDefinedLayerPalette;
|
||||
import com.dfsek.terra.addons.chunkgenerator.layer.sampler.BiomeDefinedLayerSampler;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.BooleanOperator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.RelationalOperator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.pointset.PointSet;
|
||||
import com.dfsek.terra.addons.chunkgenerator.util.InstanceWrapper;
|
||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||
@@ -95,8 +95,8 @@ public class LayeredChunkGeneratorAddon implements AddonInitializer {
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.priority(1000)
|
||||
.then(event -> {
|
||||
event.getPack().applyLoader(BooleanOperator.class,
|
||||
(type, o, loader, depthTracker) -> BooleanOperator.valueOf((String) o));
|
||||
event.getPack().applyLoader(RelationalOperator.class,
|
||||
(type, o, loader, depthTracker) -> RelationalOperator.valueOf((String) o));
|
||||
|
||||
CheckedRegistry<Supplier<ObjectTemplate<PointSet>>> pointSetTypeRegistry = event.getPack().getOrCreateRegistry(
|
||||
POINT_SET_TYPE_TOKEN);
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.api.LayerPredicate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.api.LayerSampler;
|
||||
import com.dfsek.terra.addons.chunkgenerator.layer.predicate.SamplerLayerPredicate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.BooleanOperator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.RelationalOperator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.util.InstanceWrapper;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SamplerLayerPredicateTemplate implements ObjectTemplate<LayerPredic
|
||||
|
||||
@Value("operator")
|
||||
@Default
|
||||
private BooleanOperator operator = BooleanOperator.GreaterThan;
|
||||
private RelationalOperator operator = RelationalOperator.GreaterThan;
|
||||
|
||||
@Override
|
||||
public LayerPredicate get() {
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.dfsek.tectonic.api.config.template.object.ObjectTemplate;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.api.LayerPredicate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.api.LayerSampler;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.BooleanOperator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.RelationalOperator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.layer.predicate.SamplerListLayerPredicate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.util.InstanceWrapper;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.pointset.PointSet;
|
||||
@@ -27,7 +27,7 @@ public class SamplerListLayerPredicateTemplate implements ObjectTemplate<LayerPr
|
||||
|
||||
@Value("operator")
|
||||
@Default
|
||||
private BooleanOperator defaultOperator = BooleanOperator.GreaterThan;
|
||||
private RelationalOperator defaultOperator = RelationalOperator.GreaterThan;
|
||||
|
||||
@Override
|
||||
public LayerPredicate get() {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.addons.chunkgenerator.layer.predicate;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.api.LayerPredicate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.api.LayerSampler;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.BooleanOperator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.RelationalOperator;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
@@ -13,9 +13,9 @@ public class SamplerLayerPredicate implements LayerPredicate {
|
||||
|
||||
private final double threshold;
|
||||
|
||||
private final BooleanOperator operator;
|
||||
private final RelationalOperator operator;
|
||||
|
||||
public SamplerLayerPredicate(LayerSampler sampler, BooleanOperator operator, double threshold) {
|
||||
public SamplerLayerPredicate(LayerSampler sampler, RelationalOperator operator, double threshold) {
|
||||
this.sampler = sampler;
|
||||
this.operator = operator;
|
||||
this.threshold = threshold;
|
||||
@@ -23,7 +23,7 @@ public class SamplerLayerPredicate implements LayerPredicate {
|
||||
|
||||
@Override
|
||||
public boolean test(int x, int y, int z, WorldProperties worldProperties, BiomeProvider biomeProvider) {
|
||||
return operator.evaluate(sampler.sample(x, y, z, worldProperties, biomeProvider), threshold);
|
||||
return operator.test(sampler.sample(x, y, z, worldProperties, biomeProvider), threshold);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.addons.chunkgenerator.layer.predicate;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.api.LayerPredicate;
|
||||
import com.dfsek.terra.addons.chunkgenerator.api.LayerSampler;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.BooleanOperator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.RelationalOperator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.math.pointset.PointSet;
|
||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
@@ -12,11 +12,11 @@ import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
public class SamplerListLayerPredicate implements LayerPredicate {
|
||||
|
||||
private final Vector3Int[] points;
|
||||
private final BooleanOperator operator;
|
||||
private final RelationalOperator operator;
|
||||
private final LayerSampler sampler;
|
||||
private final double threshold;
|
||||
|
||||
public SamplerListLayerPredicate(LayerSampler sampler, double threshold, BooleanOperator operator, PointSet points) {
|
||||
public SamplerListLayerPredicate(LayerSampler sampler, double threshold, RelationalOperator operator, PointSet points) {
|
||||
this.sampler = sampler;
|
||||
this.threshold = threshold;
|
||||
this.operator = operator;
|
||||
@@ -26,7 +26,7 @@ public class SamplerListLayerPredicate implements LayerPredicate {
|
||||
@Override
|
||||
public boolean test(int x, int y, int z, WorldProperties worldProperties, BiomeProvider biomeProvider) {
|
||||
for (Vector3Int point : points) {
|
||||
if (operator.evaluate(sampler.sample(x + point.getX(), y + point.getY(), z + point.getZ(), worldProperties, biomeProvider), threshold)) return true;
|
||||
if (operator.test(sampler.sample(x + point.getX(), y + point.getY(), z + point.getZ(), worldProperties, biomeProvider), threshold)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,42 +1,45 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.math;
|
||||
|
||||
public enum BooleanOperator {
|
||||
import com.dfsek.terra.addons.chunkgenerator.util.DoubleBiPredicate;
|
||||
|
||||
|
||||
public enum RelationalOperator implements DoubleBiPredicate {
|
||||
GreaterThan {
|
||||
@Override
|
||||
public boolean evaluate(double a, double b) {
|
||||
public boolean test(double a, double b) {
|
||||
return a > b;
|
||||
}
|
||||
},
|
||||
GreaterThanOrEqual {
|
||||
@Override
|
||||
public boolean evaluate(double a, double b) {
|
||||
public boolean test(double a, double b) {
|
||||
return a >= b;
|
||||
}
|
||||
},
|
||||
LessThan {
|
||||
@Override
|
||||
public boolean evaluate(double a, double b) {
|
||||
public boolean test(double a, double b) {
|
||||
return a < b;
|
||||
}
|
||||
},
|
||||
LessThanOrEqual {
|
||||
@Override
|
||||
public boolean evaluate(double a, double b) {
|
||||
public boolean test(double a, double b) {
|
||||
return a <= b;
|
||||
}
|
||||
},
|
||||
Equals {
|
||||
@Override
|
||||
public boolean evaluate(double a, double b) {
|
||||
public boolean test(double a, double b) {
|
||||
return a == b;
|
||||
}
|
||||
},
|
||||
NotEquals {
|
||||
@Override
|
||||
public boolean evaluate(double a, double b) {
|
||||
public boolean test(double a, double b) {
|
||||
return a != b;
|
||||
}
|
||||
};
|
||||
|
||||
public abstract boolean evaluate(double a, double b);
|
||||
public abstract boolean test(double a, double b);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.dfsek.terra.addons.chunkgenerator.util;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface DoubleBiPredicate {
|
||||
boolean test(double a, double b);
|
||||
}
|
||||
Reference in New Issue
Block a user