mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
add resolution parameter to Column#forRanges
This commit is contained in:
parent
5799b81414
commit
eac8d3b4e8
@ -51,7 +51,7 @@ class BiomePipelineColumn implements Column<Biome> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forRanges(IntIntObjConsumer<Biome> consumer) {
|
||||
public void forRanges(int resolution, IntIntObjConsumer<Biome> consumer) {
|
||||
consumer.accept(min, max, biome);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
int tz = cz + chunkZ;
|
||||
world.getBiomeProvider()
|
||||
.getColumn(tx, tz, world)
|
||||
.forRanges((min, max, biome) -> {
|
||||
.forRanges(resolution, (min, max, biome) -> {
|
||||
for(int subChunkX = 0; subChunkX < resolution; subChunkX++) {
|
||||
for(int subChunkZ = 0; subChunkZ < resolution; subChunkZ++) {
|
||||
int x = subChunkX + tx;
|
||||
|
@ -3,10 +3,6 @@ package com.dfsek.terra.api.util;
|
||||
import com.dfsek.terra.api.util.function.IntIntObjConsumer;
|
||||
import com.dfsek.terra.api.util.function.IntObjConsumer;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@ -18,6 +14,7 @@ public interface Column<T> {
|
||||
int getMaxY();
|
||||
|
||||
int getX();
|
||||
|
||||
int getZ();
|
||||
|
||||
T get(int y);
|
||||
@ -33,7 +30,8 @@ public interface Column<T> {
|
||||
consumer.accept(y, get(y));
|
||||
}
|
||||
}
|
||||
default void forRanges(IntIntObjConsumer<T> consumer) {
|
||||
|
||||
default void forRanges(int resolution, IntIntObjConsumer<T> consumer) {
|
||||
int min = getMinY();
|
||||
|
||||
int y = min;
|
||||
@ -45,7 +43,7 @@ public interface Column<T> {
|
||||
int max = getMaxY() - 1;
|
||||
|
||||
while(y < max) {
|
||||
y++;
|
||||
y += resolution;
|
||||
T current = get(y);
|
||||
|
||||
if(!current.equals(runningObj)) {
|
||||
|
@ -38,7 +38,7 @@ public class ColumnTest {
|
||||
public void testForRanges() {
|
||||
List<Pair<Pair<Integer, Integer>, Boolean>> list = new ArrayList<>();
|
||||
|
||||
returnPositive.forRanges((min, max, p) -> list.add(Pair.of(Pair.of(min, max), p)));
|
||||
returnPositive.forRanges(1, (min, max, p) -> list.add(Pair.of(Pair.of(min, max), p)));
|
||||
|
||||
assertEquals(List.of(
|
||||
Pair.of(Pair.of(-10, 0), false),
|
||||
@ -51,7 +51,7 @@ public class ColumnTest {
|
||||
public void testForRangesIndividual() {
|
||||
List<Pair<Pair<Integer, Integer>, Integer>> list = new ArrayList<>();
|
||||
|
||||
returnY.forRanges((min, max, p) -> list.add(Pair.of(Pair.of(min, max), p)));
|
||||
returnY.forRanges(1, (min, max, p) -> list.add(Pair.of(Pair.of(min, max), p)));
|
||||
|
||||
assertEquals(IntStream.range(-10, 10).mapToObj(i -> Pair.of(Pair.of(i, i + 1), i)).collect(Collectors.toList()),
|
||||
list);
|
||||
@ -61,7 +61,7 @@ public class ColumnTest {
|
||||
public void testForRangesContiguous() {
|
||||
List<Pair<Pair<Integer, Integer>, Boolean>> list = new ArrayList<>();
|
||||
|
||||
returnTrue.forRanges((min, max, p) -> list.add(Pair.of(Pair.of(min, max), p)));
|
||||
returnTrue.forRanges(1, (min, max, p) -> list.add(Pair.of(Pair.of(min, max), p)));
|
||||
|
||||
assertEquals(List.of(Pair.of(Pair.of(-10, 10), true)),
|
||||
list);
|
||||
|
Loading…
x
Reference in New Issue
Block a user