mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-08-29 21:30:43 +00:00
improve ProbabilityCollection#map impl
This commit is contained in:
+1
-6
@@ -49,12 +49,7 @@ public class ProbabilityCollection<E> implements Collection<E> {
|
|||||||
|
|
||||||
public <T> ProbabilityCollection<T> map(Function<E, T> mapper, boolean carryNull) {
|
public <T> ProbabilityCollection<T> map(Function<E, T> mapper, boolean carryNull) {
|
||||||
ProbabilityCollection<T> newCollection = new ProbabilityCollection<>();
|
ProbabilityCollection<T> newCollection = new ProbabilityCollection<>();
|
||||||
newCollection.array = new Object[array.length];
|
cont.forEach((o, count) -> newCollection.add(mapper.apply(o), count.get()));
|
||||||
|
|
||||||
for(int i = 0; i < array.length; i++) {
|
|
||||||
if(carryNull && array[i] == null) continue;
|
|
||||||
newCollection.array[i] = mapper.apply((E) array[i]);
|
|
||||||
}
|
|
||||||
return newCollection;
|
return newCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -2,6 +2,7 @@ package com.dfsek.terra.config.loaders.config.biome.templates.stage;
|
|||||||
|
|
||||||
import com.dfsek.tectonic.annotations.Value;
|
import com.dfsek.tectonic.annotations.Value;
|
||||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
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.NoiseSeeded;
|
||||||
import com.dfsek.terra.api.util.seeded.SeededBuilder;
|
import com.dfsek.terra.api.util.seeded.SeededBuilder;
|
||||||
import com.dfsek.terra.api.util.seeded.StageSeeded;
|
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 {
|
public abstract class StageTemplate implements ObjectTemplate<SeededBuilder<Stage>>, StageSeeded {
|
||||||
@Value("noise")
|
@Value("noise")
|
||||||
protected NoiseSeeded noise;
|
protected MetaValue<NoiseSeeded> noise;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StageSeeded get() {
|
public StageSeeded get() {
|
||||||
|
|||||||
+1
-1
@@ -8,6 +8,6 @@ import com.dfsek.terra.config.loaders.config.biome.templates.stage.StageTemplate
|
|||||||
public class ExpanderStageTemplate extends StageTemplate {
|
public class ExpanderStageTemplate extends StageTemplate {
|
||||||
@Override
|
@Override
|
||||||
public Stage apply(Long seed) {
|
public Stage apply(Long seed) {
|
||||||
return new ExpanderStage(new FractalExpander(noise.apply(seed)));
|
return new ExpanderStage(new FractalExpander(noise.get().apply(seed)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -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)));
|
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