mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-08 16:56:07 +00:00
build chunk generator addon
This commit is contained in:
@@ -8,6 +8,7 @@ import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.util.seeded.BiomeProviderBuilder;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -46,4 +47,6 @@ public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolde
|
||||
boolean vanillaFlora();
|
||||
|
||||
RegistryFactory getRegistryFactory();
|
||||
|
||||
ChunkGeneratorProvider getGeneratorProvider();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
import com.dfsek.terra.api.world.ChunkAccess;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public interface Carver {
|
||||
void carve(World world, int chunkX, int chunkZ, ChunkAccess chunk);
|
||||
}
|
||||
@@ -3,5 +3,5 @@ package com.dfsek.terra.api.world.generator;
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
public interface ChunkGeneratorProvider {
|
||||
ChunkGenerator newInstance(ConfigPack pack);
|
||||
TerraChunkGenerator newInstance(ConfigPack pack);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.dfsek.terra.api.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.util.mutable.MutableInteger;
|
||||
import com.dfsek.terra.api.world.biome.Generator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ChunkInterpolator {
|
||||
/**
|
||||
* Gets the noise at a pair of internal chunk coordinates.
|
||||
*
|
||||
* @param x The internal X coordinate (0-15).
|
||||
* @param z The internal Z coordinate (0-15).
|
||||
* @return double - The interpolated noise at the coordinates.
|
||||
*/
|
||||
double getNoise(double x, double y, double z);
|
||||
|
||||
default double getNoise(int x, int y, int z) { // Floating-point modulus operations are expensive. This allows implementations to optionally handle integers separately.
|
||||
return getNoise((double) x, y, z);
|
||||
}
|
||||
|
||||
|
||||
default double computeNoise(Map<Generator, MutableInteger> gens, double x, double y, double z) {
|
||||
double n = 0;
|
||||
double div = 0;
|
||||
for(Map.Entry<Generator, MutableInteger> entry : gens.entrySet()) {
|
||||
Generator gen = entry.getKey();
|
||||
int weight = entry.getValue().get();
|
||||
double noise = computeNoise(gen, x, y, z);
|
||||
|
||||
n += noise * weight;
|
||||
div += gen.getWeight() * weight;
|
||||
}
|
||||
return n / div;
|
||||
}
|
||||
|
||||
double computeNoise(Generator generator, double x, double y, double z);
|
||||
}
|
||||
Reference in New Issue
Block a user