biome source meta-fication

This commit is contained in:
dfsek
2021-06-14 18:06:22 -07:00
parent 64cf6538cb
commit 733b9fab4b
2 changed files with 9 additions and 3 deletions

View File

@@ -58,6 +58,10 @@ public class ProbabilityCollection<E> implements Collection<E> {
return newCollection;
}
public <T> ProbabilityCollection<T> map(Function<E, T> mapper) {
return map(mapper, true);
}
public int getTotalProbability() {
return array.length;
}

View File

@@ -1,21 +1,23 @@
package com.dfsek.terra.config.loaders.config.biome.templates.source;
import com.dfsek.tectonic.annotations.Value;
import com.dfsek.terra.api.config.meta.MetaValue;
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
import com.dfsek.terra.api.world.biome.pipeline.source.BiomeSource;
import com.dfsek.terra.api.world.biome.pipeline.source.RandomSource;
import com.dfsek.terra.config.builder.BiomeBuilder;
@SuppressWarnings("unused")
public class NoiseSourceTemplate extends SourceTemplate {
@Value("noise")
private NoiseSeeded noise;
private MetaValue<NoiseSeeded> noise;
@Value("biomes")
private ProbabilityCollection<BiomeBuilder> biomes;
private ProbabilityCollection<MetaValue<BiomeBuilder>> biomes;
@Override
public BiomeSource apply(Long seed) {
return new RandomSource(biomes.map((biome) -> biome.apply(seed), false), noise.apply(seed));
return new RandomSource(biomes.map((biome) -> biome.get().apply(seed), false), noise.get().apply(seed));
}
}