mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2024-12-03 13:23:32 +01:00
Moved overworld biome placement definition to biome.yml config file
This commit is contained in:
parent
48d6850731
commit
8f109d57ff
@ -1,16 +1,23 @@
|
||||
package world.bentobox.boxed.generators;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Enums;
|
||||
|
||||
import nl.rutgerkok.worldgeneratorapi.BiomeGenerator;
|
||||
import world.bentobox.boxed.Boxed;
|
||||
|
||||
@ -20,72 +27,12 @@ import world.bentobox.boxed.Boxed;
|
||||
*/
|
||||
public class BoxedBiomeGenerator implements BiomeGenerator {
|
||||
|
||||
private static final TreeMap<Double, Biome> NORTH_EAST = new TreeMap<>();
|
||||
static {
|
||||
NORTH_EAST.put(0.05, Biome.PLAINS);
|
||||
NORTH_EAST.put(0.1, Biome.DESERT);
|
||||
NORTH_EAST.put(0.2, Biome.SAVANNA);
|
||||
NORTH_EAST.put(0.4, Biome.JUNGLE_EDGE);
|
||||
NORTH_EAST.put(0.5, Biome.JUNGLE);
|
||||
NORTH_EAST.put(0.6, Biome.JUNGLE_HILLS);
|
||||
NORTH_EAST.put(0.75, Biome.BAMBOO_JUNGLE_HILLS);
|
||||
NORTH_EAST.put(0.8, Biome.BAMBOO_JUNGLE);
|
||||
NORTH_EAST.put(0.9, Biome.BADLANDS_PLATEAU);
|
||||
NORTH_EAST.put(1.0, Biome.BADLANDS);
|
||||
NORTH_EAST.put(1.1, Biome.LUKEWARM_OCEAN);
|
||||
NORTH_EAST.put(20.0, Biome.WARM_OCEAN);
|
||||
}
|
||||
private static final TreeMap<Double, Biome> SOUTH_EAST = new TreeMap<>();
|
||||
static {
|
||||
SOUTH_EAST.put(0.05, Biome.PLAINS);
|
||||
SOUTH_EAST.put(0.3, Biome.SAVANNA);
|
||||
SOUTH_EAST.put(0.4, Biome.DESERT);
|
||||
SOUTH_EAST.put(0.5, Biome.SHATTERED_SAVANNA);
|
||||
SOUTH_EAST.put(0.65, Biome.DESERT_HILLS);
|
||||
SOUTH_EAST.put(0.7, Biome.GRAVELLY_MOUNTAINS);
|
||||
SOUTH_EAST.put(0.9, Biome.BADLANDS_PLATEAU);
|
||||
SOUTH_EAST.put(1.0, Biome.ERODED_BADLANDS);
|
||||
SOUTH_EAST.put(1.1, Biome.MUSHROOM_FIELD_SHORE);
|
||||
SOUTH_EAST.put(20.0, Biome.WARM_OCEAN);
|
||||
}
|
||||
|
||||
private static final TreeMap<Double, Biome> NORTH_WEST = new TreeMap<>();
|
||||
static {
|
||||
NORTH_WEST.put(0.05, Biome.PLAINS);
|
||||
NORTH_WEST.put(0.25, Biome.SUNFLOWER_PLAINS);
|
||||
NORTH_WEST.put(0.3, Biome.FLOWER_FOREST);
|
||||
NORTH_WEST.put(0.4, Biome.DARK_FOREST);
|
||||
NORTH_WEST.put(0.5, Biome.SNOWY_TAIGA);
|
||||
NORTH_WEST.put(0.65, Biome.SNOWY_TAIGA_HILLS);
|
||||
NORTH_WEST.put(0.7, Biome.SNOWY_MOUNTAINS);
|
||||
NORTH_WEST.put(0.9, Biome.MOUNTAIN_EDGE);
|
||||
NORTH_WEST.put(1.1, Biome.BEACH);
|
||||
NORTH_WEST.put(20.0, Biome.COLD_OCEAN);
|
||||
}
|
||||
|
||||
private static final TreeMap<Double, Biome> SOUTH_WEST = new TreeMap<>();
|
||||
static {
|
||||
SOUTH_WEST.put(0.05, Biome.PLAINS);
|
||||
SOUTH_WEST.put(0.25, Biome.SWAMP);
|
||||
SOUTH_WEST.put(0.3, Biome.FOREST);
|
||||
SOUTH_WEST.put(0.4, Biome.DARK_FOREST);
|
||||
SOUTH_WEST.put(0.5, Biome.SNOWY_TAIGA);
|
||||
SOUTH_WEST.put(0.65, Biome.SNOWY_TAIGA_HILLS);
|
||||
SOUTH_WEST.put(0.7, Biome.SNOWY_MOUNTAINS);
|
||||
SOUTH_WEST.put(0.9, Biome.MOUNTAIN_EDGE);
|
||||
SOUTH_WEST.put(1.1, Biome.ICE_SPIKES);
|
||||
SOUTH_WEST.put(20.0, Biome.COLD_OCEAN);
|
||||
}
|
||||
private static final Map<BlockFace, SortedMap<Double, Biome>> QUADRANTS;
|
||||
static {
|
||||
Map<BlockFace, SortedMap<Double, Biome>> q = new EnumMap<>(BlockFace.class);
|
||||
q.put(BlockFace.NORTH_EAST, NORTH_EAST);
|
||||
q.put(BlockFace.NORTH_WEST, NORTH_WEST);
|
||||
q.put(BlockFace.SOUTH_EAST, SOUTH_EAST);
|
||||
q.put(BlockFace.SOUTH_WEST, SOUTH_WEST);
|
||||
QUADRANTS = Collections.unmodifiableMap(q);
|
||||
}
|
||||
private final SortedMap<Double, Biome> northEast;
|
||||
private final SortedMap<Double, Biome> southEast;
|
||||
private final SortedMap<Double, Biome> northWest;
|
||||
private final SortedMap<Double, Biome> southWest;
|
||||
|
||||
private final Map<BlockFace, SortedMap<Double, Biome>> quadrants;
|
||||
|
||||
private final Boxed addon;
|
||||
private final int dist;
|
||||
@ -98,6 +45,50 @@ public class BoxedBiomeGenerator implements BiomeGenerator {
|
||||
dist = addon.getSettings().getIslandDistance();
|
||||
offsetX = addon.getSettings().getIslandXOffset();
|
||||
offsetZ = addon.getSettings().getIslandZOffset();
|
||||
// Load the config
|
||||
File biomeFile = new File(addon.getDataFolder(), "biomes.yml");
|
||||
if (!biomeFile.exists()) {
|
||||
addon.saveResource("biomes.yml", true);
|
||||
}
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(biomeFile);
|
||||
northEast = loadQuad(config, "distribution.overworld.north-east");
|
||||
southEast = loadQuad(config, "distribution.overworld.south-east");
|
||||
northWest = loadQuad(config, "distribution.overworld.north-west");
|
||||
southWest = loadQuad(config, "distribution.overworld.south-west");
|
||||
|
||||
quadrants = new EnumMap<>(BlockFace.class);
|
||||
quadrants.put(BlockFace.NORTH_EAST, northEast);
|
||||
quadrants.put(BlockFace.NORTH_WEST, northWest);
|
||||
quadrants.put(BlockFace.SOUTH_EAST, southEast);
|
||||
quadrants.put(BlockFace.SOUTH_WEST, southWest);
|
||||
}
|
||||
|
||||
|
||||
private SortedMap<Double, Biome> loadQuad(YamlConfiguration config, String string) {
|
||||
SortedMap<Double, Biome> result = new TreeMap<>();
|
||||
if (config.contains(string)) {
|
||||
for (String ring : config.getStringList(string)) {
|
||||
String[] split = ring.split(":");
|
||||
if (split.length == 2 && NumberUtils.isNumber(split[0])) {
|
||||
try {
|
||||
double d = Double.parseDouble(split[0]);
|
||||
Biome biome = Enums.getIfPresent(Biome.class, split[1].toUpperCase(Locale.ENGLISH)).orNull();
|
||||
if (biome == null) {
|
||||
addon.logError(split[1].toUpperCase(Locale.ENGLISH) + " is an unknown biome on this server.");
|
||||
} else {
|
||||
|
||||
addon.log(string + " " + biome + " " + d);
|
||||
result.put(d, biome);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
addon.logError(string + ": " + split[0] + " does not seem to be a double. For integers add a .0 to the end");
|
||||
}
|
||||
} else {
|
||||
addon.logError(ring + " must be in the format ratio:biome where ratio is a double.");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -126,7 +117,7 @@ public class BoxedBiomeGenerator implements BiomeGenerator {
|
||||
}
|
||||
|
||||
private Biome getBiome(BlockFace dir, double d) {
|
||||
Entry<Double, Biome> en = ((TreeMap<Double, Biome>) QUADRANTS.get(dir)).ceilingEntry(d);
|
||||
Entry<Double, Biome> en = ((TreeMap<Double, Biome>) quadrants.get(dir)).ceilingEntry(d);
|
||||
return en == null ? Biome.OCEAN : en.getValue();
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,54 @@
|
||||
# Change these mid-game will only affect newly generated chunks, so be careful!
|
||||
distribution:
|
||||
overworld:
|
||||
north-east:
|
||||
- 0.05:PLAINS
|
||||
- 0.1:DESERT
|
||||
- 0.2:SAVANNA
|
||||
- 0.4:JUNGLE_EDGE
|
||||
- 0.5:JUNGLE
|
||||
- 0.6:JUNGLE_HILLS
|
||||
- 0.75:BAMBOO_JUNGLE_HILLS
|
||||
- 0.8:BAMBOO_JUNGLE
|
||||
- 0.9:BADLANDS_PLATEAU
|
||||
- 1.0:BADLANDS
|
||||
- 1.1:LUKEWARM_OCEAN
|
||||
- 20.0:WARM_OCEAN
|
||||
south-east:
|
||||
- 0.05:PLAINS
|
||||
- 0.1:SUNFLOWER_PLAINS
|
||||
- 0.2:FLOWER_FOREST
|
||||
- 0.3:SAVANNA
|
||||
- 0.4:DESERT
|
||||
- 0.5:SHATTERED_SAVANNA
|
||||
- 0.65:DESERT_HILLS
|
||||
- 0.7:GRAVELLY_MOUNTAINS
|
||||
- 0.9:BADLANDS_PLATEAU
|
||||
- 1.0:ERODED_BADLANDS
|
||||
- 1.1:MUSHROOM_FIELD_SHORE
|
||||
- 20.0:WARM_OCEAN
|
||||
north-west:
|
||||
- 0.05:PLAINS
|
||||
- 0.25:FOREST
|
||||
- 0.3:FLOWER_FOREST
|
||||
- 0.4:DARK_FOREST
|
||||
- 0.5:SNOWY_TAIGA
|
||||
- 0.65:SNOWY_TAIGA_HILLS
|
||||
- 0.7:SNOWY_MOUNTAINS
|
||||
- 0.9:MOUNTAIN_EDGE
|
||||
- 1.1:BEACH
|
||||
- 20.0:COLD_OCEAN
|
||||
south-west:
|
||||
- 0.05:PLAINS
|
||||
- 0.25:SWAMP
|
||||
- 0.3:FOREST
|
||||
- 0.4:DARK_FOREST
|
||||
- 0.5:SNOWY_TAIGA
|
||||
- 0.65:SNOWY_TAIGA_HILLS
|
||||
- 0.7:SNOWY_MOUNTAINS
|
||||
- 0.9:MOUNTAIN_EDGE
|
||||
- 1.1:ICE_SPIKES
|
||||
- 20.0:COLD_OCEAN
|
||||
nether:
|
||||
biomes:
|
||||
NETHER_WASTES:
|
||||
@ -224,4 +275,4 @@ biomes:
|
||||
scale: 2.5
|
||||
WOODED_MOUNTAINS:
|
||||
height: 10
|
||||
scale: 2.5
|
||||
scale: 2.5
|
||||
|
Loading…
Reference in New Issue
Block a user