mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-18 22:30:00 +00:00
pass seed to noise functions
This commit is contained in:
@@ -13,7 +13,7 @@ configureDependencies()
|
||||
group = "com.dfsek.terra.common"
|
||||
|
||||
dependencies {
|
||||
"shadedApi"("com.dfsek:Paralithic:0.3.2")
|
||||
"shadedApi"("com.dfsek:Paralithic:0.4.0")
|
||||
|
||||
"shadedApi"("com.dfsek.tectonic:common:2.1.1")
|
||||
"shadedApi"("com.dfsek.tectonic:yaml:2.1.1")
|
||||
|
||||
@@ -8,50 +8,26 @@ public interface NoiseSampler {
|
||||
static NoiseSampler zero() {
|
||||
return new NoiseSampler() {
|
||||
@Override
|
||||
public double getNoise(double x, double y) {
|
||||
public double getNoiseSeeded(long seed, double x, double y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoise(double x, double y, double z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(int seed, double x, double y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(int seed, double x, double y, double z) {
|
||||
public double getNoiseSeeded(long seed, double x, double y, double z) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 2D noise at given position using current settings
|
||||
* <p>
|
||||
* Noise output bounded between -1...1
|
||||
*/
|
||||
double getNoise(double x, double y);
|
||||
|
||||
/**
|
||||
* 3D noise at given position using current settings
|
||||
* <p>
|
||||
* Noise output bounded between -1...1
|
||||
*/
|
||||
double getNoise(double x, double y, double z);
|
||||
|
||||
default double getNoise(Vector3 vector3) {
|
||||
return getNoise(vector3.getX(), vector3.getY(), vector3.getZ());
|
||||
default double getNoiseSeeded(Vector3 vector3, long seed) {
|
||||
return getNoiseSeeded(seed, vector3.getX(), vector3.getY(), vector3.getZ());
|
||||
}
|
||||
|
||||
default double getNoise(Vector2 vector2) {
|
||||
return getNoise(vector2.getX(), vector2.getZ());
|
||||
default double getNoiseSeeded(Vector2 vector2, long seed) {
|
||||
return getNoiseSeeded(seed, vector2.getX(), vector2.getZ());
|
||||
}
|
||||
|
||||
double getNoiseSeeded(int seed, double x, double y);
|
||||
double getNoiseSeeded(long seed, double x, double y);
|
||||
|
||||
double getNoiseSeeded(int seed, double x, double y, double z);
|
||||
double getNoiseSeeded(long seed, double x, double y, double z);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.api.structure.feature;
|
||||
|
||||
public interface Distributor {
|
||||
boolean matches(int x, int z);
|
||||
boolean matches(int x, int z, long seed);
|
||||
|
||||
default Distributor and(Distributor other) {
|
||||
return (x, z) -> this.matches(x, z) && other.matches(x, z);
|
||||
return (x, z, seed) -> this.matches(x, z, seed) && other.matches(x, z, seed);
|
||||
}
|
||||
|
||||
default Distributor or(Distributor other) {
|
||||
return (x, z) -> this.matches(x, z) || other.matches(x, z);
|
||||
return (x, z, seed) -> this.matches(x, z, seed) || other.matches(x, z, seed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,15 +38,15 @@ public class ProbabilityCollection<E> implements Collection<E> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E get(NoiseSampler n, double x, double y, double z) {
|
||||
public E get(NoiseSampler n, double x, double y, double z, long seed) {
|
||||
if(array.length == 0) return null;
|
||||
return (E) array[MathUtil.normalizeIndex(n.getNoise(x, y, z), array.length)];
|
||||
return (E) array[MathUtil.normalizeIndex(n.getNoiseSeeded(seed, x, y, z), array.length)];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E get(NoiseSampler n, double x, double z) {
|
||||
public E get(NoiseSampler n, double x, double z, long seed) {
|
||||
if(array.length == 0) return null;
|
||||
return (E) array[MathUtil.normalizeIndex(n.getNoise(x, z), array.length)];
|
||||
return (E) array[MathUtil.normalizeIndex(n.getNoiseSeeded(seed, x, z), array.length)];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -183,12 +183,12 @@ public class ProbabilityCollection<E> implements Collection<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(NoiseSampler n, double x, double y, double z) {
|
||||
public T get(NoiseSampler n, double x, double y, double z, long seed) {
|
||||
return single;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(NoiseSampler n, double x, double z) {
|
||||
public T get(NoiseSampler n, double x, double z, long seed) {
|
||||
return single;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,18 +5,13 @@ import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public interface BiomeProvider {
|
||||
TerraBiome getBiome(int x, int z);
|
||||
TerraBiome getBiome(int x, int z, long seed);
|
||||
|
||||
default TerraBiome getBiome(Vector2 vector2) {
|
||||
return getBiome(vector2.getBlockX(), vector2.getBlockZ());
|
||||
default TerraBiome getBiome(Vector2 vector2, long seed) {
|
||||
return getBiome(vector2.getBlockX(), vector2.getBlockZ(), seed);
|
||||
}
|
||||
|
||||
default TerraBiome getBiome(Vector3 vector3) {
|
||||
return getBiome(vector3.getBlockX(), vector3.getBlockZ());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
enum Type {
|
||||
IMAGE, PIPELINE, SINGLE
|
||||
default TerraBiome getBiome(Vector3 vector3, long seed) {
|
||||
return getBiome(vector3.getBlockX(), vector3.getBlockZ(), seed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.api.world.biome.generation.pipeline;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
|
||||
public interface BiomeSource {
|
||||
TerraBiome getBiome(double x, double z);
|
||||
TerraBiome getBiome(double x, double z, long seed);
|
||||
|
||||
enum Type {
|
||||
NOISE
|
||||
|
||||
@@ -15,7 +15,7 @@ public interface Palette {
|
||||
* @param layer - The layer at which to fetch the material.
|
||||
* @return BlockData - The material fetched.
|
||||
*/
|
||||
BlockState get(int layer, double x, double y, double z);
|
||||
BlockState get(int layer, double x, double y, double z, long seed);
|
||||
|
||||
int getSize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user