mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-06 15:56:14 +00:00
improve ProbabilityCollection#map impl
This commit is contained in:
@@ -49,12 +49,7 @@ public class ProbabilityCollection<E> implements Collection<E> {
|
||||
|
||||
public <T> ProbabilityCollection<T> map(Function<E, T> mapper, boolean carryNull) {
|
||||
ProbabilityCollection<T> newCollection = new ProbabilityCollection<>();
|
||||
newCollection.array = new Object[array.length];
|
||||
|
||||
for(int i = 0; i < array.length; i++) {
|
||||
if(carryNull && array[i] == null) continue;
|
||||
newCollection.array[i] = mapper.apply((E) array[i]);
|
||||
}
|
||||
cont.forEach((o, count) -> newCollection.add(mapper.apply(o), count.get()));
|
||||
return newCollection;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.dfsek.terra.config.loaders.config.biome.templates.stage;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.api.config.meta.MetaValue;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
||||
import com.dfsek.terra.api.util.seeded.SeededBuilder;
|
||||
import com.dfsek.terra.api.util.seeded.StageSeeded;
|
||||
@@ -9,7 +10,7 @@ import com.dfsek.terra.api.world.biome.pipeline.stages.Stage;
|
||||
|
||||
public abstract class StageTemplate implements ObjectTemplate<SeededBuilder<Stage>>, StageSeeded {
|
||||
@Value("noise")
|
||||
protected NoiseSeeded noise;
|
||||
protected MetaValue<NoiseSeeded> noise;
|
||||
|
||||
@Override
|
||||
public StageSeeded get() {
|
||||
|
||||
@@ -8,6 +8,6 @@ import com.dfsek.terra.config.loaders.config.biome.templates.stage.StageTemplate
|
||||
public class ExpanderStageTemplate extends StageTemplate {
|
||||
@Override
|
||||
public Stage apply(Long seed) {
|
||||
return new ExpanderStage(new FractalExpander(noise.apply(seed)));
|
||||
return new ExpanderStage(new FractalExpander(noise.get().apply(seed)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ public class BorderListMutatorTemplate extends MutatorStageTemplate {
|
||||
|
||||
replace.forEach((keyBuilder, replacements) -> replaceMap.put(keyBuilder.apply(seed), replacements.map(replacement -> replacement.apply(seed), true)));
|
||||
|
||||
return new BorderListMutator(replaceMap, from, defaultReplace, noise.apply(seed), defaultTo.map(biomeBuilder -> biomeBuilder.apply(seed), true));
|
||||
return new BorderListMutator(replaceMap, from, defaultReplace, noise.get().apply(seed), defaultTo.map(biomeBuilder -> biomeBuilder.apply(seed), true));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user