Refactored and updated to JUnit 5. Fixed biome selector.
This commit is contained in:
@@ -4,7 +4,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import ca.recrown.islandsurvivalcraft.worldgen.IslandSurvivalCraftWorldGenerator;
|
||||
import ca.recrown.islandsurvivalcraft.worldgeneration.IslandSurvivalCraftWorldGenerator;
|
||||
|
||||
public class IslandSurvivalCraft extends JavaPlugin {
|
||||
IslandSurvivalCraftWorldGenerator generator;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
package ca.recrown.islandsurvivalcraft.worldgeneration;
|
||||
|
||||
import java.util.Random;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
package ca.recrown.islandsurvivalcraft.worldgeneration;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
@@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
package ca.recrown.islandsurvivalcraft.worldgeneration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -114,26 +114,35 @@ public class BiomeSelector {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the normal temperature for the given biome.
|
||||
* @param biome The given biome.
|
||||
* @return the Minecraft temperature.
|
||||
*/
|
||||
public float getBiomeTemperature(Biome biome) {
|
||||
String biomeName = biome.name().toLowerCase();
|
||||
if (biomeName.endsWith("hills") || biomeName.endsWith("beach") || biomeName.endsWith("shore")) {
|
||||
String biomeTypeName = biomeName;
|
||||
biomeTypeName = biomeTypeName.replace("hills", "");
|
||||
biomeTypeName = biomeTypeName.replace("beach", "");
|
||||
biomeTypeName = biomeTypeName.replace("shore", "");
|
||||
biomeTypeName = biomeTypeName.substring(0, biomeTypeName.length() - 2);
|
||||
biomeTypeName = biomeTypeName.replace("_hills", "");
|
||||
biomeTypeName = biomeTypeName.replace("_beach", "");
|
||||
biomeTypeName = biomeTypeName.replace("_shore", "");
|
||||
|
||||
for (Entry<Biome, Float> entry : lands.entrySet()) {
|
||||
if (entry.getKey().name().startsWith(biomeTypeName)) {
|
||||
if (entry.getKey().name().toLowerCase().startsWith(biomeTypeName)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return lands.get(biome);
|
||||
}
|
||||
|
||||
|
||||
public Biome getTransitionBiome(Biome from) {
|
||||
/**
|
||||
* Attempts to procure a biome that helps transitionfrom one biome to another biome
|
||||
* for given biome.
|
||||
* @param from the biome to transition from.
|
||||
* @return the resulting transition biome.
|
||||
*/
|
||||
public Biome getTransitionalBiome(Biome from) {
|
||||
String biomeName = from.name().toLowerCase();
|
||||
if (biomeName.contains("jungle")) {
|
||||
if (biomeName.contains("modified")) {
|
||||
@@ -146,6 +155,12 @@ public class BiomeSelector {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the shore biome from the given information.
|
||||
* @param from land biome that connects to it.
|
||||
* @param temperature the Minecraft temperature of this shore.
|
||||
* @return the shore biome associated with it.
|
||||
*/
|
||||
public Biome getShoreBiome(Biome from, float temperature) {
|
||||
String biomeName = from.name().toLowerCase();
|
||||
if (biomeName.contains("mushroom")) {
|
||||
@@ -153,12 +168,17 @@ public class BiomeSelector {
|
||||
} else if (biomeName.contains("mountains")) {
|
||||
return Biome.STONE_SHORE;
|
||||
}
|
||||
if (temperature >= 0.8) {
|
||||
return Biome.BEACH;
|
||||
if (temperature < 0.05) {
|
||||
return Biome.SNOWY_BEACH;
|
||||
}
|
||||
return Biome.SNOWY_BEACH;
|
||||
return Biome.BEACH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly selects a land biome that fits in given temperature.
|
||||
* @param temperature Minecraft temperature to select biome from.
|
||||
* @return The randomly selected biome.
|
||||
*/
|
||||
public Biome getLandBiome(float temperature) {
|
||||
ArrayList<Biome> biomes = null;
|
||||
if (temperature <= 0.05f) {
|
||||
@@ -174,6 +194,11 @@ public class BiomeSelector {
|
||||
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.
|
||||
* @return The randomly selected biome.
|
||||
*/
|
||||
public Biome getOceanBiome(float temperature) {
|
||||
ArrayList<Biome> biomes = null;
|
||||
if (temperature <= 0.00f) {
|
@@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
package ca.recrown.islandsurvivalcraft.worldgeneration;
|
||||
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
package ca.recrown.islandsurvivalcraft.worldgeneration;
|
||||
|
||||
import java.util.Random;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
package ca.recrown.islandsurvivalcraft.worldgeneration;
|
||||
|
||||
import java.util.Random;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package ca.recrown.islandsurvivalcraft.worldgen;
|
||||
package ca.recrown.islandsurvivalcraft.worldgeneration;
|
||||
|
||||
import java.util.Random;
|
||||
|
Reference in New Issue
Block a user