Refactoring.
This commit is contained in:
parent
740ca812ae
commit
a077ec6c0e
@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.world.generation;
|
||||
package ca.recrown.islandsurvivalcraft.world;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -7,18 +7,18 @@ import org.bukkit.util.noise.SimplexOctaveGenerator;
|
||||
import ca.recrown.islandsurvivalcraft.datatypes.Point2;
|
||||
import ca.recrown.islandsurvivalcraft.caching.Cache;
|
||||
|
||||
class TemperatureMapGenerator {
|
||||
public class TemperatureMap {
|
||||
private final Cache<Point2, Float> temperatureCache;
|
||||
private final double frequency = 0.5D;
|
||||
private final double amplitude = 0.5D;
|
||||
|
||||
private volatile SimplexOctaveGenerator noiseGenerator;
|
||||
|
||||
public TemperatureMapGenerator() {
|
||||
public TemperatureMap() {
|
||||
temperatureCache = new Cache<>(1024);
|
||||
}
|
||||
|
||||
public TemperatureMapGenerator(long seed) {
|
||||
public TemperatureMap(long seed) {
|
||||
this();
|
||||
setSeed(seed);
|
||||
}
|
@ -23,6 +23,9 @@ import ca.recrown.islandsurvivalcraft.caching.Cache;
|
||||
import ca.recrown.islandsurvivalcraft.datatypes.Point2;
|
||||
import ca.recrown.islandsurvivalcraft.world.BiomeSelector;
|
||||
import ca.recrown.islandsurvivalcraft.world.IslandWorldMapper;
|
||||
import ca.recrown.islandsurvivalcraft.world.TemperatureMap;
|
||||
import ca.recrown.islandsurvivalcraft.world.generation.biomes.BiomeGenerator;
|
||||
import ca.recrown.islandsurvivalcraft.world.generation.biomes.UniBiomeIslandGenerator;
|
||||
import ca.recrown.islandsurvivalcraft.world.shaders.WorldHeightShader;
|
||||
import ca.recrown.islandsurvivalcraft.world.shaders.WorldLayerShader;
|
||||
|
||||
@ -46,7 +49,7 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene
|
||||
int maxHeight = world.getMaxHeight();
|
||||
int seaLevel = world.getSeaLevel();
|
||||
IslandWorldMapper mapper = new IslandWorldMapper(seed, blockValueCache);
|
||||
TemperatureMapGenerator temperatureMapGenerator = new TemperatureMapGenerator(seed);
|
||||
TemperatureMap temperatureMapGenerator = new TemperatureMap(seed);
|
||||
WorldHeightShader heightShader = new WorldHeightShader(seed, mapper, seaLevel, world.getMaxHeight(), 3);
|
||||
WorldLayerShader layerShader = new WorldLayerShader(seed, seaLevel, maxHeight, mapper);
|
||||
BiomeGenerator biomeGenerator = new UniBiomeIslandGenerator();
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.world.generation;
|
||||
package ca.recrown.islandsurvivalcraft.world.generation.biomes;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -7,6 +7,7 @@ import ca.recrown.islandsurvivalcraft.caching.Cache;
|
||||
import ca.recrown.islandsurvivalcraft.datatypes.Point2;
|
||||
import ca.recrown.islandsurvivalcraft.world.BiomeSelector;
|
||||
import ca.recrown.islandsurvivalcraft.world.IslandWorldMapper;
|
||||
import ca.recrown.islandsurvivalcraft.world.TemperatureMap;
|
||||
|
||||
public interface BiomeGenerator {
|
||||
|
||||
@ -28,5 +29,5 @@ public interface BiomeGenerator {
|
||||
* @param chunkGenCache Cache for whether or not the chunk is generated.
|
||||
* @param seed The seed to use for the biome for this column.
|
||||
*/
|
||||
public void generateBiomeColumn(Biome[][][] chunkBiomeSets, World world, int chunkX, int chunkZ, int localX, int localZ, IslandWorldMapper mapper, BiomeSelector biomeSelector, TemperatureMapGenerator tempGenerator, Cache<Point2, Biome[]> biomeCache, Cache<Point2, Boolean> chunkGenCache, long seed);
|
||||
public void generateBiomeColumn(Biome[][][] chunkBiomeSets, World world, int chunkX, int chunkZ, int localX, int localZ, IslandWorldMapper mapper, BiomeSelector biomeSelector, TemperatureMap tempGenerator, Cache<Point2, Biome[]> biomeCache, Cache<Point2, Boolean> chunkGenCache, long seed);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.world.generation;
|
||||
package ca.recrown.islandsurvivalcraft.world.generation.biomes;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
@ -12,10 +12,11 @@ import ca.recrown.islandsurvivalcraft.pathfinding.CoordinateTargetValidatable;
|
||||
import ca.recrown.islandsurvivalcraft.pathfinding.DepthFirstSearch;
|
||||
import ca.recrown.islandsurvivalcraft.world.BiomeSelector;
|
||||
import ca.recrown.islandsurvivalcraft.world.IslandWorldMapper;
|
||||
import ca.recrown.islandsurvivalcraft.world.TemperatureMap;
|
||||
|
||||
public class UniBiomeIslandGenerator implements BiomeGenerator {
|
||||
@Override
|
||||
public void generateBiomeColumn(Biome[][][] chunkBiomeSets, World world, int chunkX, int chunkZ, int localX, int localZ, IslandWorldMapper mapper, BiomeSelector biomeSelector, TemperatureMapGenerator tempGen, Cache<Point2, Biome[]> biomeCache, Cache<Point2, Boolean> chunkGenCache, long seed) {
|
||||
public void generateBiomeColumn(Biome[][][] chunkBiomeSets, World world, int chunkX, int chunkZ, int localX, int localZ, IslandWorldMapper mapper, BiomeSelector biomeSelector, TemperatureMap tempGen, Cache<Point2, Biome[]> biomeCache, Cache<Point2, Boolean> chunkGenCache, long seed) {
|
||||
int worldX = 16 * chunkX + localX;
|
||||
int worldZ = 16 * chunkZ + localZ;
|
||||
Point2 chunkCoords = Utilities.worldToChunkCoordinates(new Point2(worldX, worldZ));
|
@ -0,0 +1,18 @@
|
||||
package ca.recrown.islandsurvivalcraft.world.generation.populators;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
public class TreePopulator extends BlockPopulator {
|
||||
|
||||
@Override
|
||||
public void populate(World world, Random random, Chunk source) {
|
||||
if (random.nextBoolean()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.world.generation;
|
||||
package ca.recrown.islandsurvivalcraft.world.generation.biomes;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
@ -23,6 +23,8 @@ import ca.recrown.islandsurvivalcraft.caching.Cache;
|
||||
import ca.recrown.islandsurvivalcraft.datatypes.Point2;
|
||||
import ca.recrown.islandsurvivalcraft.world.BiomeSelector;
|
||||
import ca.recrown.islandsurvivalcraft.world.IslandWorldMapper;
|
||||
import ca.recrown.islandsurvivalcraft.world.TemperatureMap;
|
||||
import ca.recrown.islandsurvivalcraft.world.generation.DummyWorld;
|
||||
|
||||
@TestInstance(Lifecycle.PER_CLASS)
|
||||
public class UniBiomeIslandGeneratorTest {
|
||||
@ -53,7 +55,7 @@ public class UniBiomeIslandGeneratorTest {
|
||||
|
||||
public void generateBiome(int chunkX, int chunkZ) {
|
||||
IslandWorldMapper mapper = new IslandWorldMapper(SEED, blockValueCache);
|
||||
TemperatureMapGenerator temperatureMapGenerator = new TemperatureMapGenerator(SEED);
|
||||
TemperatureMap temperatureMapGenerator = new TemperatureMap(SEED);
|
||||
BiomeGenerator biomeGenerator = new UniBiomeIslandGenerator();
|
||||
|
||||
Biome[][][] biomes = new Biome[Utilities.CHUNK_SIZE][Utilities.CHUNK_SIZE][4];
|
Loading…
Reference in New Issue
Block a user