Deleted old code.
This commit is contained in:
parent
d506b60f07
commit
6cf1f6dcc1
@ -1,101 +0,0 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
import org.bukkit.util.noise.SimplexOctaveGenerator;
|
||||
|
||||
import nl.rutgerkok.worldgeneratorapi.BaseTerrainGenerator;
|
||||
import nl.rutgerkok.worldgeneratorapi.BaseNoiseGenerator.TerrainSettings;
|
||||
|
||||
public class IslandBaseTerrainGenerator implements BaseTerrainGenerator {
|
||||
private TerrainSettings settings;
|
||||
private SimplexOctaveGenerator baseNoiseGenerator;
|
||||
private SimplexOctaveGenerator islandShapeGenerator;
|
||||
private final int scale = 100;
|
||||
private final int maximumHeight = 65;
|
||||
private final int minimumHeight = 3;
|
||||
private Random random;
|
||||
private World world;
|
||||
|
||||
public IslandBaseTerrainGenerator(World world) {
|
||||
this.random = new Random(world.getSeed());
|
||||
this.baseNoiseGenerator = new SimplexOctaveGenerator(random, 4);
|
||||
this.baseNoiseGenerator.setScale(0.0125D);
|
||||
this.islandShapeGenerator = new SimplexOctaveGenerator(random, 8);
|
||||
this.islandShapeGenerator.setScale(0.02D);
|
||||
this.settings = new TerrainSettings();
|
||||
this.settings.seaLevel = world.getSeaLevel();
|
||||
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlocksInChunk(GeneratingChunk chunk) {
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int worldX = 16 * chunk.getChunkX() + x;
|
||||
int worldZ = 16 * chunk.getChunkZ() + z;
|
||||
|
||||
int height = baseHeight(worldX, worldZ);
|
||||
Biome biome = chunk.getBiomesForChunk().getBiome(x, height, z);
|
||||
height += additionalHeight(worldX, worldZ, biome);
|
||||
fillChunkColumn(x, z, height, chunk.getBlocksForChunk());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fillChunkColumn(int x, int z, int height, ChunkData chunkData) {
|
||||
if (height <= settings.seaLevel) {
|
||||
chunkData.setRegion(x, height, z, x+1, settings.seaLevel, z+1, Material.WATER);
|
||||
chunkData.setRegion(x, 0, z, x+1, height, z+1, Material.STONE);
|
||||
} else {
|
||||
chunkData.setRegion(x, 0, z, x+1, height, z+1, Material.STONE);
|
||||
}
|
||||
}
|
||||
|
||||
private int baseHeight(int x, int z) {
|
||||
return Math.min((int) ((baseNoiseGenerator.noise(x, z, 0.2D, 0.3D, true) + 1D) * scale/2D) + minimumHeight, maximumHeight);
|
||||
}
|
||||
|
||||
private int additionalHeight(int worldX, int worldZ, Biome biome) {
|
||||
int height = 0;
|
||||
String biomeName = biome.name();
|
||||
if (biomeName.contains("hills")) {
|
||||
height += islandHeight(worldX, worldZ, 0.5D, 0.5D, 15);
|
||||
} else if (biomeName.contains("mountains")) {
|
||||
height += islandHeight(worldX, worldZ, 0.5D, 0.5D, 60);
|
||||
} else if (biomeName.contains("plateau")) {
|
||||
height *= 1.2f;
|
||||
height += Math.min(55, islandHeight(worldX, worldZ, 0.3D, 0.3D, 5));
|
||||
} else if (biomeName.contains("modified")) {
|
||||
height += islandHeight(worldX, worldZ, 0.5D, 0.5D, 20);
|
||||
} else if (biomeName.contains("shattered")) {
|
||||
height += islandHeight(worldX, worldZ, 0.5D, 0.5D, 20);
|
||||
} else if (biomeName.contains("tall")) {
|
||||
height += islandHeight(worldX, worldZ, 0.5D, 0.5D, 30);
|
||||
} else {
|
||||
height += islandHeight(worldX, worldZ, 0.5D, 0.5D, 8);
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
private int islandHeight(int x, int z, double freq, double amp, int maximumHeight) {
|
||||
return (int) ((islandShapeGenerator.noise(x, z, freq, amp, true) + 1D) * maximumHeight/2D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(int x, int z, HeightType type) {
|
||||
// TODO FIX THIS. Innacurate readings. Due to innacurate biomes.
|
||||
Biome biome = world.getBiome(x, settings.seaLevel, z);
|
||||
int totalHeight = additionalHeight(x, z, biome) + baseHeight(x, z);
|
||||
if (totalHeight <= settings.seaLevel && type == HeightType.OCEAN_FLOOR) {
|
||||
return totalHeight;
|
||||
}
|
||||
return totalHeight;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user