Use JNoise instead of FastNoise

This commit is contained in:
Lukas Mansour (Articdive) 2020-05-02 23:16:41 +02:00
parent bfc3975750
commit 9682246f4f
3 changed files with 15 additions and 2200 deletions

View File

@ -36,6 +36,9 @@ dependencies {
compile 'com.github.TheMode:CommandBuilder:f893cfbfe4' compile 'com.github.TheMode:CommandBuilder:f893cfbfe4'
compile 'com.github.Minestom:minecraft-text:69fd808e92' 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 // https://mvnrepository.com/artifact/javax.vecmath/vecmath
compile group: 'javax.vecmath', name: 'vecmath', version: '1.5.2' // Used for Fastnoise compile group: 'javax.vecmath', name: 'vecmath', version: '1.5.2' // Used for Fastnoise

View File

@ -1,31 +1,27 @@
package fr.themode.demo.generator; 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.Biome;
import net.minestom.server.instance.Chunk; import net.minestom.server.instance.Chunk;
import net.minestom.server.instance.ChunkGenerator; import net.minestom.server.instance.ChunkGenerator;
import net.minestom.server.instance.batch.ChunkBatch; import net.minestom.server.instance.batch.ChunkBatch;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;
import net.minestom.server.utils.noise.FastNoise;
import java.util.Random; import java.util.Random;
public class NoiseTestGenerator extends ChunkGenerator { public class NoiseTestGenerator extends ChunkGenerator {
private Random random = new Random(); private Random random = new Random();
private FastNoise fastNoise = new FastNoise(); private JNoise jNoise = JNoise.newBuilder().perlin().setInterpolationType(InterpolationType.LINEAR).setSeed(141414).setFrequency(0.5).build();
{
fastNoise.SetNoiseType(FastNoise.NoiseType.Simplex);
fastNoise.SetInterp(FastNoise.Interp.Linear);
}
@Override @Override
public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) { public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) {
for (byte x = 0; x < Chunk.CHUNK_SIZE_X; x++) { for (int x = 0; x < Chunk.CHUNK_SIZE_X; x++) {
for (byte z = 0; z < Chunk.CHUNK_SIZE_Z; z++) { for (int 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; double height = jNoise.getNoise((x + chunkX * 16) / 16.0, (z + chunkZ * 16) /16.0) * 15 + 40;
height = Math.max(height, 70); System.out.println(height);
for (byte y = 0; y < height; y++) { for (int y = 0; y < height; y++) {
if (random.nextInt(100) > 10) { if (random.nextInt(100) > 10) {
batch.setCustomBlock(x, y, z, "custom_block"); batch.setCustomBlock(x, y, z, "custom_block");
} else { } else {

File diff suppressed because it is too large Load Diff