diff --git a/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/BiomeParameterTarget.java b/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/BiomeParameterTargets.java similarity index 92% rename from common/src/main/java/com/terraformersmc/biolith/api/biome/sub/BiomeParameterTarget.java rename to common/src/main/java/com/terraformersmc/biolith/api/biome/sub/BiomeParameterTargets.java index ad4ff17..9732d6b 100644 --- a/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/BiomeParameterTarget.java +++ b/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/BiomeParameterTargets.java @@ -6,7 +6,7 @@ import net.minecraft.world.biome.source.util.MultiNoiseUtil; /** - * Available noise values in the {@link BiomeParameterTarget} enum: + * Available noise values in the {@link BiomeParameterTargets} enum: * */ -public enum BiomeParameterTarget implements StringIdentifiable { +public enum BiomeParameterTargets implements StringIdentifiable { /* * Do not add before or modify the order of the first six names; * they must be in the same order as Mojang's parameter arrays. @@ -31,10 +31,10 @@ public enum BiomeParameterTarget implements StringIdentifiable { WEIRDNESS("weirdness"), PEAKS_VALLEYS("peaks_valleys"); - public static final Codec CODEC = StringIdentifiable.createCodec(BiomeParameterTarget::values); + public static final Codec CODEC = StringIdentifiable.createCodec(BiomeParameterTargets::values); private final String name; - BiomeParameterTarget(String name) { + BiomeParameterTargets(String name) { this.name = name; } @@ -51,7 +51,7 @@ public long getNoiseValue(MultiNoiseUtil.NoiseValuePoint noisePoint) { case EROSION -> noisePoint.erosionNoise(); case DEPTH -> noisePoint.depth(); case WEIRDNESS -> noisePoint.weirdnessNoise(); - case PEAKS_VALLEYS -> BiomeParameterTarget.getPeaksValleysNoiseLong(noisePoint.weirdnessNoise()); + case PEAKS_VALLEYS -> BiomeParameterTargets.getPeaksValleysNoiseLong(noisePoint.weirdnessNoise()); }; } diff --git a/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/CriterionBuilder.java b/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/CriterionBuilder.java index 2913e52..9312f54 100644 --- a/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/CriterionBuilder.java +++ b/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/CriterionBuilder.java @@ -25,8 +25,8 @@ */ @SuppressWarnings("unused") public class CriterionBuilder { - public static final Criterion NEAR_BORDER = ratioMax(RatioTarget.EDGE, 0.2f); - public static final Criterion NEAR_INTERIOR = ratioMax(RatioTarget.CENTER, 0.2f); + public static final Criterion NEAR_BORDER = ratioMax(RatioTargets.EDGE, 0.2f); + public static final Criterion NEAR_INTERIOR = ratioMax(RatioTargets.CENTER, 0.2f); public static final Criterion BEACHSIDE = allOf(NEAR_BORDER, neighbor(BiomeTags.IS_BEACH)); public static final Criterion OCEANSIDE = allOf(NEAR_BORDER, neighbor(BiomeTags.IS_OCEAN)); @@ -87,15 +87,15 @@ public static Criterion anyOf(Criterion... criteria) { * Creates a numerical {@link Criterion} used to evaluate whether the raw noise value of the * {@link MultiNoiseUtil.NoiseValuePoint} being evaluated is within the provided range. *

- * The available noise values are detailed in {@link BiomeParameterTarget}. + * The available noise values are detailed in {@link BiomeParameterTargets}. *

* - * @param parameter {@link BiomeParameterTarget target} to evaluate + * @param parameter {@link BiomeParameterTargets target} to evaluate * @param min The minimum matching value of the validity range * @param max The maximum matching value of the validity range * @return The created {@link ValueCriterion} */ - public static Criterion value(BiomeParameterTarget parameter, float min, float max) { + public static Criterion value(BiomeParameterTargets parameter, float min, float max) { return new ValueCriterion(parameter, min, max); } @@ -104,14 +104,14 @@ public static Criterion value(BiomeParameterTarget parameter, float min, float m * Creates a numerical {@link Criterion} used to evaluate whether the raw noise value of the * {@link MultiNoiseUtil.NoiseValuePoint} being evaluated is at least the provided minimum. *

- * The available noise values are detailed in {@link BiomeParameterTarget}. + * The available noise values are detailed in {@link BiomeParameterTargets}. *

* - * @param parameter {@link BiomeParameterTarget target} to evaluate + * @param parameter {@link BiomeParameterTargets target} to evaluate * @param min The minimum matching value of the validity range * @return The created {@link ValueCriterion} */ - public static Criterion valueMin(BiomeParameterTarget parameter, float min) { + public static Criterion valueMin(BiomeParameterTargets parameter, float min) { return value(parameter, min, Float.POSITIVE_INFINITY); } @@ -120,14 +120,14 @@ public static Criterion valueMin(BiomeParameterTarget parameter, float min) { * Creates a numerical {@link Criterion} used to evaluate whether the raw noise value of the * {@link MultiNoiseUtil.NoiseValuePoint} being evaluated is no more than the provided maximum. *

- * The available noise values are detailed in {@link BiomeParameterTarget}. + * The available noise values are detailed in {@link BiomeParameterTargets}. *

* - * @param parameter {@link BiomeParameterTarget target} to evaluate + * @param parameter {@link BiomeParameterTargets target} to evaluate * @param max The maximum matching value of the validity range * @return The created {@link ValueCriterion} */ - public static Criterion valueMax(BiomeParameterTarget parameter, float max) { + public static Criterion valueMax(BiomeParameterTargets parameter, float max) { return value(parameter, Float.NEGATIVE_INFINITY, max); } @@ -137,15 +137,15 @@ public static Criterion valueMax(BiomeParameterTarget parameter, float max) { * selected biome's {@link MultiNoiseUtil.ParameterRange} to a selected noise value of the * {@link MultiNoiseUtil.NoiseValuePoint} being evaluated is within the provided range. *

- * The available noise values are detailed in {@link BiomeParameterTarget}. + * The available noise values are detailed in {@link BiomeParameterTargets}. *

* - * @param parameter {@link BiomeParameterTarget target} to evaluate + * @param parameter {@link BiomeParameterTargets target} to evaluate * @param min The minimum matching value of the validity range * @param max The maximum matching value of the validity range * @return The created {@link DeviationCriterion} */ - public static Criterion deviation(BiomeParameterTarget parameter, float min, float max) { + public static Criterion deviation(BiomeParameterTargets parameter, float min, float max) { return new DeviationCriterion(parameter, min, max); } @@ -155,14 +155,14 @@ public static Criterion deviation(BiomeParameterTarget parameter, float min, flo * selected biome's {@link MultiNoiseUtil.ParameterRange} to a selected noise value of the * {@link MultiNoiseUtil.NoiseValuePoint} being evaluated is at least the provided minimum. *

- * The available noise values are detailed in {@link BiomeParameterTarget}. + * The available noise values are detailed in {@link BiomeParameterTargets}. *

* - * @param parameter {@link BiomeParameterTarget target} to evaluate + * @param parameter {@link BiomeParameterTargets target} to evaluate * @param min The minimum matching value of the validity range * @return The created {@link DeviationCriterion} */ - public static Criterion deviationMin(BiomeParameterTarget parameter, float min) { + public static Criterion deviationMin(BiomeParameterTargets parameter, float min) { return deviation(parameter, min, Float.POSITIVE_INFINITY); } @@ -172,14 +172,14 @@ public static Criterion deviationMin(BiomeParameterTarget parameter, float min) * selected biome's {@link MultiNoiseUtil.ParameterRange} to a selected noise value of the * {@link MultiNoiseUtil.NoiseValuePoint} being evaluated is no more than the provided maximum. *

- * The available noise values are detailed in {@link BiomeParameterTarget}. + * The available noise values are detailed in {@link BiomeParameterTargets}. *

* - * @param parameter {@link BiomeParameterTarget target} to evaluate + * @param parameter {@link BiomeParameterTargets target} to evaluate * @param max The maximum matching value of the validity range * @return The created {@link DeviationCriterion} */ - public static Criterion deviationMax(BiomeParameterTarget parameter, float max) { + public static Criterion deviationMax(BiomeParameterTargets parameter, float max) { return deviation(parameter, Float.NEGATIVE_INFINITY, max); } @@ -189,15 +189,15 @@ public static Criterion deviationMax(BiomeParameterTarget parameter, float max) * used to evaluate roughly how close the point being evaluated is to the noise center or edge of the of the * selected noise or replacement biome. *

- * The available noise values are detailed in {@link RatioTarget}. + * The available noise values are detailed in {@link RatioTargets}. *

* - * @param target {@link RatioTarget target} to evaluate + * @param target {@link RatioTargets target} to evaluate * @param min The minimum matching value of the validity range * @param max The maximum matching value of the validity range * @return The created {@link RatioCriterion} */ - public static Criterion ratio(RatioTarget target, float min, float max) { + public static Criterion ratio(RatioTargets target, float min, float max) { return new RatioCriterion(target, min, max); } @@ -207,14 +207,14 @@ public static Criterion ratio(RatioTarget target, float min, float max) { * used to evaluate roughly how close the point being evaluated is to the noise center or edge of the of the * selected noise or replacement biome. *

- * The available noise values are detailed in {@link RatioTarget}. + * The available noise values are detailed in {@link RatioTargets}. *

* - * @param target {@link RatioTarget target} to evaluate + * @param target {@link RatioTargets target} to evaluate * @param min The minimum matching value of the validity range * @return The created {@link RatioCriterion} */ - public static Criterion ratioMin(RatioTarget target, float min) { + public static Criterion ratioMin(RatioTargets target, float min) { return ratio(target, min, Float.POSITIVE_INFINITY); } @@ -224,14 +224,14 @@ public static Criterion ratioMin(RatioTarget target, float min) { * used to evaluate roughly how close the point being evaluated is to the noise center or edge of the of the * selected noise or replacement biome. *

- * The available noise values are detailed in {@link RatioTarget}. + * The available noise values are detailed in {@link RatioTargets}. *

* - * @param target {@link RatioTarget target} to evaluate + * @param target {@link RatioTargets target} to evaluate * @param max The maximum matching value of the validity range * @return The created {@link RatioCriterion} */ - public static Criterion ratioMax(RatioTarget target, float max) { + public static Criterion ratioMax(RatioTargets target, float max) { return ratio(target, Float.NEGATIVE_INFINITY, max); } diff --git a/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/RatioTarget.java b/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/RatioTargets.java similarity index 59% rename from common/src/main/java/com/terraformersmc/biolith/api/biome/sub/RatioTarget.java rename to common/src/main/java/com/terraformersmc/biolith/api/biome/sub/RatioTargets.java index 0097bdc..64f3634 100644 --- a/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/RatioTarget.java +++ b/common/src/main/java/com/terraformersmc/biolith/api/biome/sub/RatioTargets.java @@ -4,20 +4,20 @@ import net.minecraft.util.StringIdentifiable; /** - * Available computed ratios in the {@link RatioTarget} enum: + * Available computed ratios in the {@link RatioTargets} enum: * */ -public enum RatioTarget implements StringIdentifiable { +public enum RatioTargets implements StringIdentifiable { CENTER("center"), EDGE("edge"); - public static final Codec CODEC = StringIdentifiable.createCodec(RatioTarget::values); + public static final Codec CODEC = StringIdentifiable.createCodec(RatioTargets::values); private final String name; - RatioTarget(String name) { + RatioTargets(String name) { this.name = name; } diff --git a/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/AbstractParameterCriterion.java b/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/AbstractParameterCriterion.java index eb4c01c..a67f95b 100644 --- a/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/AbstractParameterCriterion.java +++ b/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/AbstractParameterCriterion.java @@ -4,23 +4,23 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTarget; +import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTargets; import com.terraformersmc.biolith.api.biome.sub.Criterion; import net.minecraft.util.dynamic.Range; public abstract class AbstractParameterCriterion implements Criterion { - protected final BiomeParameterTarget parameter; + protected final BiomeParameterTargets parameter; protected Range allowedValues; - public AbstractParameterCriterion(BiomeParameterTarget parameter, float min, float max) { + public AbstractParameterCriterion(BiomeParameterTargets parameter, float min, float max) { this.parameter = parameter; this.allowedValues = new Range<>(min, max); } - protected static MapCodec buildCodec(Function3 function) { + protected static MapCodec buildCodec(Function3 function) { return RecordCodecBuilder.mapCodec( (instance) -> instance.group( - BiomeParameterTarget.CODEC.fieldOf("parameter") + BiomeParameterTargets.CODEC.fieldOf("parameter") .forGetter(AbstractParameterCriterion::parameter), Codec.FLOAT.optionalFieldOf("min", Float.NEGATIVE_INFINITY) .forGetter(AbstractParameterCriterion::min), @@ -30,7 +30,7 @@ protected static MapCodec buildCodec(F .apply(instance, function)); } - public BiomeParameterTarget parameter() { + public BiomeParameterTargets parameter() { return parameter; } diff --git a/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/DeviationCriterion.java b/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/DeviationCriterion.java index e23cc92..0fa83ae 100644 --- a/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/DeviationCriterion.java +++ b/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/DeviationCriterion.java @@ -1,7 +1,7 @@ package com.terraformersmc.biolith.impl.biome.sub; import com.mojang.serialization.MapCodec; -import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTarget; +import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTargets; import com.terraformersmc.biolith.api.biome.sub.CriterionType; import com.terraformersmc.biolith.api.biome.BiolithFittestNodes; import com.terraformersmc.biolith.impl.biome.DimensionBiomePlacement; @@ -14,7 +14,7 @@ public class DeviationCriterion extends AbstractParameterCriterion { public static final MapCodec CODEC = buildCodec(DeviationCriterion::new); - public DeviationCriterion(BiomeParameterTarget parameter, float min, float max) { + public DeviationCriterion(BiomeParameterTargets parameter, float min, float max) { super(parameter, min, max); } @@ -31,18 +31,18 @@ public MapCodec getCodec() { @Override public boolean matches(BiolithFittestNodes> fittestNodes, DimensionBiomePlacement biomePlacement, MultiNoiseUtil.NoiseValuePoint noisePoint, @Nullable Range replacementRange, float replacementNoise) { long value = parameter.getNoiseValue(noisePoint); - long parameterCenter = BiomeParameterTarget.parameterCenter(getParameterRange(fittestNodes.ultimate().parameters)); + long parameterCenter = BiomeParameterTargets.parameterCenter(getParameterRange(fittestNodes.ultimate().parameters)); return allowedValues.contains(MultiNoiseUtil.toFloat(value - parameterCenter)); } private MultiNoiseUtil.ParameterRange getParameterRange(MultiNoiseUtil.ParameterRange[] parameters) { - if (parameter == BiomeParameterTarget.PEAKS_VALLEYS) { + if (parameter == BiomeParameterTargets.PEAKS_VALLEYS) { // PV is a calculated noise based on folding weirdness twice - long weirdnessMin = parameters[BiomeParameterTarget.WEIRDNESS.ordinal()].min(); - long weirdnessMax = parameters[BiomeParameterTarget.WEIRDNESS.ordinal()].max(); - long point1 = BiomeParameterTarget.getPeaksValleysNoiseLong(weirdnessMin); - long point2 = BiomeParameterTarget.getPeaksValleysNoiseLong(weirdnessMax); + long weirdnessMin = parameters[BiomeParameterTargets.WEIRDNESS.ordinal()].min(); + long weirdnessMax = parameters[BiomeParameterTargets.WEIRDNESS.ordinal()].max(); + long point1 = BiomeParameterTargets.getPeaksValleysNoiseLong(weirdnessMin); + long point2 = BiomeParameterTargets.getPeaksValleysNoiseLong(weirdnessMax); long pvMin; long pvMax; diff --git a/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/RatioCriterion.java b/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/RatioCriterion.java index 57573a3..e1248e4 100644 --- a/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/RatioCriterion.java +++ b/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/RatioCriterion.java @@ -3,11 +3,11 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTarget; +import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTargets; import com.terraformersmc.biolith.api.biome.sub.Criterion; import com.terraformersmc.biolith.api.biome.sub.CriterionType; import com.terraformersmc.biolith.api.biome.BiolithFittestNodes; -import com.terraformersmc.biolith.api.biome.sub.RatioTarget; +import com.terraformersmc.biolith.api.biome.sub.RatioTargets; import com.terraformersmc.biolith.impl.biome.DimensionBiomePlacement; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.dynamic.Range; @@ -16,10 +16,10 @@ import net.minecraft.world.biome.source.util.MultiNoiseUtil; import org.jetbrains.annotations.Nullable; -public record RatioCriterion(RatioTarget target, Range allowedValues) implements Criterion { +public record RatioCriterion(RatioTargets target, Range allowedValues) implements Criterion { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( (instance) -> instance.group( - RatioTarget.CODEC.fieldOf("target") + RatioTargets.CODEC.fieldOf("target") .forGetter(RatioCriterion::target), Codec.FLOAT.optionalFieldOf("min", Float.NEGATIVE_INFINITY) .forGetter(RatioCriterion::min), @@ -28,7 +28,7 @@ public record RatioCriterion(RatioTarget target, Range allowedValues) imp ) .apply(instance, RatioCriterion::new)); - public RatioCriterion(RatioTarget target, float min, float max) { + public RatioCriterion(RatioTargets target, float min, float max) { this(target, new Range<>(min, max)); } @@ -53,10 +53,10 @@ public MapCodec getCodec() { public boolean matches(BiolithFittestNodes> fittestNodes, DimensionBiomePlacement biomePlacement, MultiNoiseUtil.NoiseValuePoint noisePoint, @Nullable Range replacementRange, float replacementNoise) { float comparable; - if (target == RatioTarget.CENTER) { + if (target == RatioTargets.CENTER) { // Vanilla biomes pre-Biolith replacement; /10k is analogous to MultiNoiseUtil.toFloat(); param 6 is offset - comparable = MathHelper.sqrt((float) BiomeParameterTarget.getSquaredDistance( - BiomeParameterTarget.parametersCenterPoint(fittestNodes.ultimate().parameters), + comparable = MathHelper.sqrt((float) BiomeParameterTargets.getSquaredDistance( + BiomeParameterTargets.parametersCenterPoint(fittestNodes.ultimate().parameters), noisePoint, fittestNodes.ultimate().parameters[6].min())) / 10000f; // Post-replacement we need to add in the replacement noise restriction if (replacementRange != null) { @@ -72,7 +72,7 @@ public boolean matches(BiolithFittestNodes> fittestNodes, D (replacementRange.minInclusive() + replacementRange.maxInclusive()) / 2f), comparable); } } - } else if (target == RatioTarget.EDGE) { + } else if (target == RatioTargets.EDGE) { // Vanilla biomes pre-Biolith replacement if (fittestNodes.penultimate() == null) { comparable = 1f; diff --git a/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/ValueCriterion.java b/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/ValueCriterion.java index e4eff9e..64bd735 100644 --- a/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/ValueCriterion.java +++ b/common/src/main/java/com/terraformersmc/biolith/impl/biome/sub/ValueCriterion.java @@ -1,7 +1,7 @@ package com.terraformersmc.biolith.impl.biome.sub; import com.mojang.serialization.MapCodec; -import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTarget; +import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTargets; import com.terraformersmc.biolith.api.biome.sub.CriterionType; import com.terraformersmc.biolith.api.biome.BiolithFittestNodes; import com.terraformersmc.biolith.impl.biome.DimensionBiomePlacement; @@ -14,7 +14,7 @@ public class ValueCriterion extends AbstractParameterCriterion { public static final MapCodec CODEC = buildCodec(ValueCriterion::new); - public ValueCriterion(BiomeParameterTarget parameter, float min, float max) { + public ValueCriterion(BiomeParameterTargets parameter, float min, float max) { super(parameter, min, max); } diff --git a/common/src/main/java/com/terraformersmc/biolith/impl/commands/BiolithDescribeCommand.java b/common/src/main/java/com/terraformersmc/biolith/impl/commands/BiolithDescribeCommand.java index cd7f680..a10231d 100644 --- a/common/src/main/java/com/terraformersmc/biolith/impl/commands/BiolithDescribeCommand.java +++ b/common/src/main/java/com/terraformersmc/biolith/impl/commands/BiolithDescribeCommand.java @@ -3,7 +3,7 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.terraformersmc.biolith.api.biome.BiolithFittestNodes; -import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTarget; +import com.terraformersmc.biolith.api.biome.sub.BiomeParameterTargets; import com.terraformersmc.biolith.impl.Biolith; import com.terraformersmc.biolith.impl.biome.*; import com.terraformersmc.biolith.impl.compat.BiolithCompat; @@ -170,7 +170,7 @@ private static int atBlockPos(CommandContext context, Block ))); context.getSource().sendMessage(Text.literal( String.format("§7PV§r:%+05.3f §4Te§r:%+05.3f §5We§r:%+05.3f §6BR§r:%+05.3f", - MultiNoiseUtil.toFloat(BiomeParameterTarget.getPeaksValleysNoiseLong(noisePoint.weirdnessNoise())), + MultiNoiseUtil.toFloat(BiomeParameterTargets.getPeaksValleysNoiseLong(noisePoint.weirdnessNoise())), MultiNoiseUtil.toFloat(noisePoint.temperatureNoise()), MultiNoiseUtil.toFloat(noisePoint.weirdnessNoise()), replacementNoise