Refactoring.
This commit is contained in:
parent
67a93fff5b
commit
35e52ae61b
@ -8,7 +8,7 @@ import ca.recrown.islandsurvivalcraft.pathfinding.CoordinateTargetValidatable;
|
|||||||
import ca.recrown.islandsurvivalcraft.pathfinding.DepthFirstSearch;
|
import ca.recrown.islandsurvivalcraft.pathfinding.DepthFirstSearch;
|
||||||
|
|
||||||
public class BiomePerIslandGenerator implements IslandBiomeGenerator, CoordinateTargetValidatable {
|
public class BiomePerIslandGenerator implements IslandBiomeGenerator, CoordinateTargetValidatable {
|
||||||
private IslandMapGenerator islandMapGenerator;
|
private IslandLocationGenerator islandLocator;
|
||||||
private BiomeSelector biomeSelector;
|
private BiomeSelector biomeSelector;
|
||||||
private TemperatureMapGenerator temperatureMapGenerator;
|
private TemperatureMapGenerator temperatureMapGenerator;
|
||||||
private int buildHeight;
|
private int buildHeight;
|
||||||
@ -20,12 +20,12 @@ public class BiomePerIslandGenerator implements IslandBiomeGenerator, Coordinate
|
|||||||
|
|
||||||
public BiomePerIslandGenerator() {
|
public BiomePerIslandGenerator() {
|
||||||
this.temperatureMapGenerator = new TemperatureMapGenerator();
|
this.temperatureMapGenerator = new TemperatureMapGenerator();
|
||||||
dfs = new DepthFirstSearch(islandMapGenerator);
|
dfs = new DepthFirstSearch(islandLocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(IslandMapGenerator mapGenerator, BiomeSelector biomeSelector) {
|
public void initialize(IslandLocationGenerator mapGenerator, BiomeSelector biomeSelector) {
|
||||||
this.islandMapGenerator = mapGenerator;
|
this.islandLocator = mapGenerator;
|
||||||
this.biomeSelector = biomeSelector;
|
this.biomeSelector = biomeSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public class BiomePerIslandGenerator implements IslandBiomeGenerator, Coordinate
|
|||||||
public boolean isCoordinateTarget(int x, int y) {
|
public boolean isCoordinateTarget(int x, int y) {
|
||||||
if (world.isChunkGenerated(x/16, y/16)) {
|
if (world.isChunkGenerated(x/16, y/16)) {
|
||||||
Biome foundBiome = world.getBiome(x, 0, y);
|
Biome foundBiome = world.getBiome(x, 0, y);
|
||||||
if (islandMapGenerator.isShore(x, y)) {
|
if (islandLocator.isShore(x, y)) {
|
||||||
shoreBiome = foundBiome;
|
shoreBiome = foundBiome;
|
||||||
} else {
|
} else {
|
||||||
mainBiome = foundBiome;
|
mainBiome = foundBiome;
|
||||||
@ -58,7 +58,7 @@ public class BiomePerIslandGenerator implements IslandBiomeGenerator, Coordinate
|
|||||||
int worldX = chunkX * 16 + localX;
|
int worldX = chunkX * 16 + localX;
|
||||||
int worldZ = chunkZ * 16 + localZ;
|
int worldZ = chunkZ * 16 + localZ;
|
||||||
|
|
||||||
if (islandMapGenerator.isIsland(worldX, worldZ)) {
|
if (islandLocator.isIsland(worldX, worldZ)) {
|
||||||
if (mainBiome == null && shoreBiome == null) {
|
if (mainBiome == null && shoreBiome == null) {
|
||||||
if (!dfs.findTarget(this)) {
|
if (!dfs.findTarget(this)) {
|
||||||
temperature = temperatureMapGenerator.getTemperature(worldX, worldZ);
|
temperature = temperatureMapGenerator.getTemperature(worldX, worldZ);
|
||||||
@ -75,7 +75,7 @@ public class BiomePerIslandGenerator implements IslandBiomeGenerator, Coordinate
|
|||||||
Biome designatedBiome = mainBiome;
|
Biome designatedBiome = mainBiome;
|
||||||
if (mainBiome == null) {
|
if (mainBiome == null) {
|
||||||
designatedBiome = Biome.OCEAN;
|
designatedBiome = Biome.OCEAN;
|
||||||
} else if (islandMapGenerator.isShore(worldX, worldZ)) {
|
} else if (islandLocator.isShore(worldX, worldZ)) {
|
||||||
designatedBiome = shoreBiome;
|
designatedBiome = shoreBiome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||||
|
|
||||||
public interface IslandBiomeGenerator {
|
public interface IslandBiomeGenerator {
|
||||||
public void initialize(IslandMapGenerator mapGenerator, BiomeSelector biome);
|
public void initialize(IslandLocationGenerator mapGenerator, BiomeSelector biome);
|
||||||
public void setWorld(World world);
|
public void setWorld(World world);
|
||||||
public void GenerateBiome(int chunkX, int chunkZ, int localX, int localZ, BiomeGrid biome);
|
public void GenerateBiome(int chunkX, int chunkZ, int localX, int localZ, BiomeGrid biome);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.util.noise.SimplexOctaveGenerator;
|
|||||||
import ca.recrown.islandsurvivalcraft.pathfinding.CoordinateValidatable;
|
import ca.recrown.islandsurvivalcraft.pathfinding.CoordinateValidatable;
|
||||||
import ca.recrown.islandsurvivalcraft.pathfinding.DepthFirstSearch;
|
import ca.recrown.islandsurvivalcraft.pathfinding.DepthFirstSearch;
|
||||||
|
|
||||||
public class IslandMapGenerator implements CoordinateValidatable {
|
public class IslandLocationGenerator implements CoordinateValidatable {
|
||||||
private Random random;
|
private Random random;
|
||||||
private SimplexOctaveGenerator noiseGenerator;
|
private SimplexOctaveGenerator noiseGenerator;
|
||||||
private final int noiseOctaves = 8;
|
private final int noiseOctaves = 8;
|
||||||
@ -22,7 +22,7 @@ public class IslandMapGenerator implements CoordinateValidatable {
|
|||||||
private int shallowDepth;
|
private int shallowDepth;
|
||||||
private final DepthFirstSearch dfs;
|
private final DepthFirstSearch dfs;
|
||||||
|
|
||||||
public IslandMapGenerator() {
|
public IslandLocationGenerator() {
|
||||||
dfs = new DepthFirstSearch(this);
|
dfs = new DepthFirstSearch(this);
|
||||||
}
|
}
|
||||||
|
|
@ -10,12 +10,12 @@ public class IslandSurvivalCraftWorldGenerator extends ChunkGenerator {
|
|||||||
private final BedrockGenerator bedrockGenerator;
|
private final BedrockGenerator bedrockGenerator;
|
||||||
private final BiomeSelector biomeSelector;
|
private final BiomeSelector biomeSelector;
|
||||||
private final IslandBiomeGenerator biomeGenerator;
|
private final IslandBiomeGenerator biomeGenerator;
|
||||||
private final IslandMapGenerator islandMapGenerator;
|
private final IslandLocationGenerator islandMapGenerator;
|
||||||
|
|
||||||
public IslandSurvivalCraftWorldGenerator(IslandBiomeGenerator generator) {
|
public IslandSurvivalCraftWorldGenerator(IslandBiomeGenerator generator) {
|
||||||
this.biomeSelector = new BiomeSelector();
|
this.biomeSelector = new BiomeSelector();
|
||||||
this.bedrockGenerator = new BedrockGenerator();
|
this.bedrockGenerator = new BedrockGenerator();
|
||||||
this.islandMapGenerator = new IslandMapGenerator();
|
this.islandMapGenerator = new IslandLocationGenerator();
|
||||||
this.biomeGenerator = generator;
|
this.biomeGenerator = generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user