diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/BiomeSelector.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/BiomeSelector.java index c6c90a1..be65a31 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/BiomeSelector.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/BiomeSelector.java @@ -10,12 +10,12 @@ import org.bukkit.block.Biome; import ca.recrown.islandsurvivalcraft.Utilities; public class BiomeSelector { - private boolean initialized = false; + private volatile boolean initialized = false; private final HashMap lands = new HashMap<>(); - private HashMap> temperaturesForLand = new HashMap<>(); + private volatile HashMap> temperaturesForLand = new HashMap<>(); private final HashMap> temperaturePartitionedLandBiomes = new HashMap<>(); private final HashMap oceans = new HashMap<>(); - private HashMap> temperaturesForOcean = new HashMap<>(); + private volatile HashMap> temperaturesForOcean = new HashMap<>(); private final HashMap> temperaturePartitionedOceanBiomes = new HashMap<>(); @@ -26,6 +26,7 @@ public class BiomeSelector { temperaturePartitionedLandBiomes.put(2f, new ArrayList<>()); temperaturePartitionedOceanBiomes.put(0.00f, new ArrayList<>()); + temperaturePartitionedOceanBiomes.put(0.3f, new ArrayList<>()); temperaturePartitionedOceanBiomes.put(0.5f, new ArrayList<>()); } @@ -91,17 +92,15 @@ public class BiomeSelector { private void registerOceanBiomeTemperatures() { oceans.put(Biome.WARM_OCEAN, 0.5f); oceans.put(Biome.LUKEWARM_OCEAN, 0.5f); - oceans.put(Biome.DEEP_LUKEWARM_OCEAN, 0.5f); - oceans.put(Biome.OCEAN, 0.5f); - oceans.put(Biome.DEEP_OCEAN, 0.5f); - oceans.put(Biome.COLD_OCEAN, 0.5f); - oceans.put(Biome.DEEP_COLD_OCEAN, 0.5f); + oceans.put(Biome.OCEAN, 0.3f); + oceans.put(Biome.COLD_OCEAN, 0.3f); oceans.put(Biome.FROZEN_OCEAN, 0f); - oceans.put(Biome.DEEP_FROZEN_OCEAN, 0.5f); temperaturesForOcean = Utilities.invertHashMap(oceans); for (Entry> entry : temperaturesForOcean.entrySet()) { if (entry.getKey() <= 0.00f) { temperaturePartitionedOceanBiomes.get(0.0f).addAll(entry.getValue()); + } else if (entry.getKey() <= 0.3f) { + temperaturePartitionedOceanBiomes.get(0.3f).addAll(entry.getValue()); } else { temperaturePartitionedOceanBiomes.get(0.5f).addAll(entry.getValue()); } @@ -188,9 +187,10 @@ public class BiomeSelector { /** * Randomly selects a land biome that fits in given temperature. * @param temperature Minecraft temperature to select biome from. + * @param seed The seed to use to select the biome. * @return The randomly selected biome. */ - public Biome getLandBiome(float temperature, Random random) { + public Biome getLandBiome(float temperature, long seed) { if (!initialized) throw new IllegalStateException("Biome selector is not initialized."); ArrayList biomes = null; if (temperature <= 0.05f) { @@ -202,25 +202,32 @@ public class BiomeSelector { } else { biomes = temperaturePartitionedLandBiomes.get(2.00f); } - + Random random = new Random(seed); return biomes.get((int) random.nextFloat() * biomes.size()); } /** * Randomly selects an ocean biome that fits in given temperature. + * * @param temperature Minecraft temperature to select biome from. + * @param isDeep If this ocean should be of the deep variant. + * @param seed The seed to use to select the biome. * @return The randomly selected biome. */ - public Biome getOceanBiome(float temperature, Random random) { + public Biome getOceanBiome(float temperature, boolean isDeep, long seed) { if (!initialized) throw new IllegalStateException("Biome selector is not initialized."); ArrayList biomes = null; if (temperature <= 0.00f) { biomes = temperaturePartitionedOceanBiomes.get(0.0f); + } else if (temperature <= 0.3) { + biomes = temperaturePartitionedOceanBiomes.get(0.3f); } else { biomes = temperaturePartitionedOceanBiomes.get(0.5f); } - - return biomes.get((int) random.nextFloat() * biomes.size()); + Random random = new Random(seed); + Biome oceanBiome = biomes.get((int) random.nextFloat() * biomes.size()); + if (isDeep) oceanBiome = Biome.valueOf("DEEP_" + oceanBiome.name()); + return oceanBiome; } } \ No newline at end of file