mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 03:57:50 +01:00
Use JNoise instead of FastNoise
This commit is contained in:
parent
bfc3975750
commit
9682246f4f
@ -36,6 +36,9 @@ dependencies {
|
||||
compile 'com.github.TheMode:CommandBuilder:f893cfbfe4'
|
||||
compile 'com.github.Minestom:minecraft-text:69fd808e92'
|
||||
|
||||
// https://jitpack.io/#Articdive/Jnoise/1.0-SNAPSHOT
|
||||
compile 'com.github.Articdive:Jnoise:1.0-SNAPSHOT'
|
||||
|
||||
// https://mvnrepository.com/artifact/javax.vecmath/vecmath
|
||||
compile group: 'javax.vecmath', name: 'vecmath', version: '1.5.2' // Used for Fastnoise
|
||||
|
||||
|
@ -1,41 +1,37 @@
|
||||
package fr.themode.demo.generator;
|
||||
|
||||
import de.articdive.jnoise.JNoise;
|
||||
import de.articdive.jnoise.interpolation.InterpolationType;
|
||||
import net.minestom.server.instance.Biome;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.ChunkGenerator;
|
||||
import net.minestom.server.instance.batch.ChunkBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.utils.noise.FastNoise;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class NoiseTestGenerator extends ChunkGenerator {
|
||||
|
||||
|
||||
private Random random = new Random();
|
||||
private FastNoise fastNoise = new FastNoise();
|
||||
|
||||
{
|
||||
fastNoise.SetNoiseType(FastNoise.NoiseType.Simplex);
|
||||
fastNoise.SetInterp(FastNoise.Interp.Linear);
|
||||
}
|
||||
|
||||
private JNoise jNoise = JNoise.newBuilder().perlin().setInterpolationType(InterpolationType.LINEAR).setSeed(141414).setFrequency(0.5).build();
|
||||
|
||||
@Override
|
||||
public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) {
|
||||
for (byte x = 0; x < Chunk.CHUNK_SIZE_X; x++) {
|
||||
for (byte z = 0; z < Chunk.CHUNK_SIZE_Z; z++) {
|
||||
float height = fastNoise.GetSimplex(x + Chunk.CHUNK_SIZE_X * chunkX, z + Chunk.CHUNK_SIZE_Z * chunkZ) * 135;
|
||||
height = Math.max(height, 70);
|
||||
for (byte y = 0; y < height; y++) {
|
||||
for (int x = 0; x < Chunk.CHUNK_SIZE_X; x++) {
|
||||
for (int z = 0; z < Chunk.CHUNK_SIZE_Z; z++) {
|
||||
double height = jNoise.getNoise((x + chunkX * 16) / 16.0, (z + chunkZ * 16) /16.0) * 15 + 40;
|
||||
System.out.println(height);
|
||||
for (int y = 0; y < height; y++) {
|
||||
if (random.nextInt(100) > 10) {
|
||||
batch.setCustomBlock(x, y, z, "custom_block");
|
||||
} else {
|
||||
batch.setBlock(x, y, z, Block.DIAMOND_BLOCK);
|
||||
batch.setBlock(x, y, z, Block.DIAMOND_BLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int chunkX, int chunkZ) {
|
||||
return Biome.PLAINS;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user