mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
add BiomeProvider#getColumn
This commit is contained in:
parent
c46f84a00e
commit
84cb428b6c
@ -1,5 +1,9 @@
|
|||||||
package com.dfsek.terra.api.util;
|
package com.dfsek.terra.api.util;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
@ -15,4 +19,10 @@ public interface Column<T> {
|
|||||||
consumer.accept(get(y));
|
consumer.accept(get(y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<? extends T> asList() {
|
||||||
|
List<T> list = new ArrayList<>();
|
||||||
|
forEach(list::add);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.dfsek.terra.api.world.biome.generation;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.util.Column;
|
||||||
|
import com.dfsek.terra.api.world.biome.Biome;
|
||||||
|
|
||||||
|
|
||||||
|
class BiomeColumn implements Column<Biome> {
|
||||||
|
private final BiomeProvider biomeProvider;
|
||||||
|
private final int min;
|
||||||
|
private final int max;
|
||||||
|
|
||||||
|
private final int x;
|
||||||
|
private final int z;
|
||||||
|
private final long seed;
|
||||||
|
|
||||||
|
protected BiomeColumn(BiomeProvider biomeProvider, int min, int max, int x, int z, long seed) {
|
||||||
|
this.biomeProvider = biomeProvider;
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
this.x = x;
|
||||||
|
this.z = z;
|
||||||
|
this.seed = seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinY() {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxY() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Biome get(int y) {
|
||||||
|
return biomeProvider.getBiome(x, y, z, seed);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.world.biome.generation;
|
package com.dfsek.terra.api.world.biome.generation;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.util.Column;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
import com.dfsek.terra.api.util.vector.Vector3;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3Int;
|
import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||||
import com.dfsek.terra.api.world.biome.Biome;
|
import com.dfsek.terra.api.world.biome.Biome;
|
||||||
@ -62,6 +63,14 @@ public interface BiomeProvider {
|
|||||||
return getBiome(vector3.getX(), vector3.getY(), vector3.getZ(), seed);
|
return getBiome(vector3.getX(), vector3.getY(), vector3.getZ(), seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Column<Biome> getColumn(int x, int z, int min, int max, long seed) {
|
||||||
|
return new BiomeColumn(this, min, max, x, z, seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
default Column<Biome> getColumn(int x, int z, WorldProperties properties) {
|
||||||
|
return getColumn(x, z, properties.getMinHeight(), properties.getMaxHeight(), properties.getSeed());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all biomes this {@link BiomeProvider} is capable of generating in the world.
|
* Get all biomes this {@link BiomeProvider} is capable of generating in the world.
|
||||||
* <p>
|
* <p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user