Clean up configs

This commit is contained in:
dfsek 2020-10-05 22:54:28 -07:00
parent 2659577322
commit 605dd6aadc
10 changed files with 141 additions and 116 deletions

View File

@ -20,22 +20,17 @@ public class AbstractBiomeConfig extends TerraConfig {
private final int snowChance; private final int snowChance;
private double slabThreshold; private double slabThreshold;
private BiomeSlabConfig slabs; private BiomeSlabConfig slabs;
private boolean useStairs;
private final boolean floraSimplex; private final boolean floraSimplex;
private final int floraSeed; private final int floraSeed;
private final float floraFreq; private final float floraFreq;
private final String oceanPalette;
private final int seaLevel; private final int seaLevel;
private Map<String, Object> floraData;
private Map<String, Object> oreData;
private Map<String, Object> treeData;
private List<Map<?, ?>> carvingData;
private List<String> structureConfigs; private List<String> structureConfigs;
private BiomePaletteConfig palette; private BiomePaletteConfig palette;
private BiomeFloraConfig flora; private BiomeFloraConfig flora;
private BiomeCarverConfig carving; private BiomeCarverConfig carving;
private BiomeTreeConfig trees; private BiomeTreeConfig trees;
private BiomeOreConfig ores; private BiomeOreConfig ores;
private BiomeOceanConfig ocean;
public AbstractBiomeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException { public AbstractBiomeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config); super(file, config);
@ -53,8 +48,6 @@ public class AbstractBiomeConfig extends TerraConfig {
floraSeed = getInt("flora-simplex.seed", 0); floraSeed = getInt("flora-simplex.seed", 0);
seaLevel = getInt("ocean.level", 62); seaLevel = getInt("ocean.level", 62);
snowChance = getInt("snow-chance", 0); snowChance = getInt("snow-chance", 0);
oceanPalette = getString("ocean.palette");
useStairs = getBoolean("slabs.use-stairs-if-available", false);
if(contains("carving")) carving = new BiomeCarverConfig(this); if(contains("carving")) carving = new BiomeCarverConfig(this);
@ -66,6 +59,8 @@ public class AbstractBiomeConfig extends TerraConfig {
if(contains("ores")) ores = new BiomeOreConfig(this); if(contains("ores")) ores = new BiomeOreConfig(this);
if(contains("ocean")) ocean = new BiomeOceanConfig(this);
if(contains("slabs") && getBoolean("slabs.enable", false)) slabs = new BiomeSlabConfig(this); if(contains("slabs") && getBoolean("slabs.enable", false)) slabs = new BiomeSlabConfig(this);
if(contains("structures")) structureConfigs = getStringList("structures"); if(contains("structures")) structureConfigs = getStringList("structures");
@ -136,12 +131,12 @@ public class AbstractBiomeConfig extends TerraConfig {
return slabs; return slabs;
} }
public int getSeaLevel() { public BiomeOceanConfig getOcean() {
return seaLevel; return ocean;
} }
public String getOceanPalette() { public int getSeaLevel() {
return oceanPalette; return seaLevel;
} }
public List<String> getStructureConfigs() { public List<String> getStructureConfigs() {

View File

@ -34,21 +34,17 @@ import java.util.Objects;
import java.util.Random; import java.util.Random;
public class BiomeConfig extends TerraConfig { public class BiomeConfig extends TerraConfig {
private static final Palette<BlockData> oceanDefault = new RandomPalette<BlockData>(new Random(0)).add(Material.WATER.createBlockData(), 1);
private final UserDefinedBiome biome; private final UserDefinedBiome biome;
private final String biomeID; private final String biomeID;
private final BiomeOreConfig ore; private final BiomeOreConfig ore;
private final BiomeCarverConfig carver; private final BiomeCarverConfig carver;
private final BiomeFloraConfig flora; private final BiomeFloraConfig flora;
private final BiomeTreeConfig tree; private final BiomeTreeConfig tree;
private String eq; private final BiomeOceanConfig ocean;
private int floraAttempts;
private final BiomeSlabConfig slab; private final BiomeSlabConfig slab;
private double slabThreshold; private String eq;
private boolean floraSimplex;
private FastNoise floraNoise;
private final Palette<BlockData> ocean;
private int seaLevel;
private int snowChance; private int snowChance;
private final List<StructureConfig> structures; private final List<StructureConfig> structures;
private final ConfigPack config; private final ConfigPack config;
@ -76,40 +72,14 @@ public class BiomeConfig extends TerraConfig {
} }
// Get various simple values using getOrDefault config methods. // Get various simple values using getOrDefault config methods.
float floraFreq;
int floraSeed, floraChance, treeChance, treeDensity;
try { try {
slabThreshold = getDouble("slabs.threshold", Objects.requireNonNull(abstractBiome).getSlabThreshold());
floraChance = getInt("flora-chance", Objects.requireNonNull(abstractBiome).getFloraChance());
floraAttempts = getInt("flora-attempts", Objects.requireNonNull(abstractBiome).getFloraAttempts());
treeChance = getInt("tree-chance", Objects.requireNonNull(abstractBiome).getTreeChance());
treeDensity = getInt("tree-density", Objects.requireNonNull(abstractBiome).getTreeDensity());
floraSeed = getInt("flora-simplex.seed", Objects.requireNonNull(abstractBiome).getFloraSeed());
floraSimplex = getBoolean("flora-simplex.enable", Objects.requireNonNull(abstractBiome).isFloraSimplex());
floraFreq = (float) getDouble("flora-simplex.frequency", Objects.requireNonNull(abstractBiome).getFloraFreq());
seaLevel = getInt("ocean.level", Objects.requireNonNull(abstractBiome).getSeaLevel());
snowChance = getInt("snow-chance", Objects.requireNonNull(abstractBiome).getSnowChance()); snowChance = getInt("snow-chance", Objects.requireNonNull(abstractBiome).getSnowChance());
eq = getString("noise-equation", Objects.requireNonNull(abstractBiome).getEquation()); eq = getString("noise-equation", Objects.requireNonNull(abstractBiome).getEquation());
} catch(NullPointerException e) { } catch(NullPointerException e) {
slabThreshold = getDouble("slabs.threshold", 0.1D);
floraChance = getInt("flora-chance", 0);
floraAttempts = getInt("flora-attempts", 1);
treeChance = getInt("tree-chance", 0);
treeDensity = getInt("tree-density", 0);
floraSeed = getInt("flora-simplex.seed", 0);
floraSimplex = getBoolean("flora-simplex.enable", false);
floraFreq = (float) getDouble("flora-simplex.frequency", 0.1);
seaLevel = getInt("ocean.level", 62);
snowChance = getInt("snow-chance", 0); snowChance = getInt("snow-chance", 0);
eq = getString("noise-equation", null); eq = getString("noise-equation", null);
} }
if(floraSimplex) {
floraNoise = new FastNoise(floraSeed);
floraNoise.setNoiseType(FastNoise.NoiseType.Simplex);
floraNoise.setFrequency(floraFreq);
}
BiomePaletteConfig palette; BiomePaletteConfig palette;
// Check if biome is extending abstract biome, only use abstract biome's palette if palette is NOT defined for current biome. // Check if biome is extending abstract biome, only use abstract biome's palette if palette is NOT defined for current biome.
if(extending && abstractBiome.getPaletteData() != null && ! contains("palette")) { if(extending && abstractBiome.getPaletteData() != null && ! contains("palette")) {
@ -129,7 +99,7 @@ public class BiomeConfig extends TerraConfig {
// Check if flora should be handled by super biome. // Check if flora should be handled by super biome.
if(extending && abstractBiome.getFlora() != null && ! contains("flora")) { if(extending && abstractBiome.getFlora() != null && ! contains("flora")) {
flora = abstractBiome.getFlora(); flora = abstractBiome.getFlora();
Debug.info("Using super flora (" + flora.getFlora().size() + " entries, " + floraChance + " % chance)"); Debug.info("Using super flora (" + flora.getFlora().size() + " entries, " + flora.getFloraChance() + " % chance)");
} else flora = new BiomeFloraConfig(this); } else flora = new BiomeFloraConfig(this);
// Check if trees should be handled by super biome. // Check if trees should be handled by super biome.
@ -150,11 +120,17 @@ public class BiomeConfig extends TerraConfig {
Debug.info("Using super slabs"); Debug.info("Using super slabs");
} else slab = new BiomeSlabConfig(this); } else slab = new BiomeSlabConfig(this);
// Get ocean stuff
if(extending && abstractBiome.getOcean() != null) {
ocean = abstractBiome.getOcean();
Debug.info("Using super ocean");
} else ocean = new BiomeOceanConfig(this);
//Make sure equation is non-null //Make sure equation is non-null
if(eq == null || eq.equals("")) throw new ConfigException("Could not find noise equation! Biomes must include a noise equation, or extend an abstract biome with one.", getID()); if(eq == null || eq.equals("")) throw new ConfigException("Could not find noise equation! Biomes must include a noise equation, or extend an abstract biome with one.", getID());
// Create decorator for this config. // Create decorator for this config.
UserDefinedDecorator dec = new UserDefinedDecorator(flora.getFlora(), tree.getTrees(), floraChance, treeChance, treeDensity); UserDefinedDecorator dec = new UserDefinedDecorator(flora.getFlora(), tree.getTrees(), flora.getFloraChance(), tree.getTreeChance(), tree.getTreeDensity());
// Get Vanilla biome, throw exception if it is invalid/unspecified. // Get Vanilla biome, throw exception if it is invalid/unspecified.
org.bukkit.block.Biome vanillaBiome; org.bukkit.block.Biome vanillaBiome;
@ -165,32 +141,6 @@ public class BiomeConfig extends TerraConfig {
throw new ConfigException("Invalid Vanilla biome: \"" + getString("vanilla") + "\"", getID()); throw new ConfigException("Invalid Vanilla biome: \"" + getString("vanilla") + "\"", getID());
} }
// Ocean stuff
String oceanPalette;
try {
oceanPalette = getString("ocean.palette", Objects.requireNonNull(abstractBiome).getOceanPalette());
} catch(NullPointerException e) {
oceanPalette = null;
}
if(contains("ocean") && oceanPalette != null) {
if(oceanPalette.startsWith("BLOCK:")) {
try {
ocean = new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(oceanPalette.substring(6)), 1), 1);
} catch(IllegalArgumentException ex) {
throw new ConfigException("BlockData \"" + oceanPalette + "\" is invalid! (Ocean Palette)", getID());
}
} else {
try {
ocean = config.getPalette(oceanPalette).getPalette();
} catch(NullPointerException ex) {
throw new NotFoundException("Palette", oceanPalette, getID());
}
}
} else ocean = oceanDefault;
// Structure stuff // Structure stuff
structures = new ArrayList<>(); structures = new ArrayList<>();
List<String> st = new ArrayList<>(); List<String> st = new ArrayList<>();
@ -213,24 +163,16 @@ public class BiomeConfig extends TerraConfig {
} }
} }
public Range getOreHeight(OreConfig c) {
return ore.getOreHeights().get(c);
}
public UserDefinedBiome getBiome() { public UserDefinedBiome getBiome() {
return biome; return biome;
} }
public int getFloraAttempts() {
return floraAttempts;
}
public String getID() { public String getID() {
return biomeID; return biomeID;
} }
public Map<OreConfig, Range> getOres() { public BiomeOreConfig getOres() {
return ore.getOres(); return ore;
} }
public Range getFloraHeights(Flora f) { public Range getFloraHeights(Flora f) {
@ -246,32 +188,16 @@ public class BiomeConfig extends TerraConfig {
return carver.getCarvers().getOrDefault(config.getCarver(c), 0); return carver.getCarvers().getOrDefault(config.getCarver(c), 0);
} }
public double getSlabThreshold() { public BiomeSlabConfig getSlabs() {
return slabThreshold; return slab;
} }
public Map<Material, Palette<BlockData>> getStairs() { public BiomeOceanConfig getOcean() {
return slab.getStairs();
}
public Map<Material, Palette<BlockData>> getSlabs() {
return slab.getSlabs();
}
public boolean isFloraSimplex() {
return floraSimplex;
}
public FastNoise getFloraNoise() {
return floraNoise;
}
public Palette<BlockData> getOceanPalette() {
return ocean; return ocean;
} }
public int getSeaLevel() { public BiomeFloraConfig getFlora() {
return seaLevel; return flora;
} }
public List<StructureConfig> getStructures() { public List<StructureConfig> getStructures() {

View File

@ -8,6 +8,7 @@ import com.dfsek.terra.config.exception.ConfigException;
import com.dfsek.terra.config.exception.NotFoundException; import com.dfsek.terra.config.exception.NotFoundException;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.polydev.gaea.math.FastNoise;
import org.polydev.gaea.math.ProbabilityCollection; import org.polydev.gaea.math.ProbabilityCollection;
import org.polydev.gaea.math.Range; import org.polydev.gaea.math.Range;
import org.polydev.gaea.world.Flora; import org.polydev.gaea.world.Flora;
@ -19,10 +20,25 @@ import java.util.Map;
public class BiomeFloraConfig extends TerraConfigSection { public class BiomeFloraConfig extends TerraConfigSection {
private final ProbabilityCollection<Flora> flora = new ProbabilityCollection<>(); private final ProbabilityCollection<Flora> flora = new ProbabilityCollection<>();
private final Map<Flora, Range> floraHeights = new HashMap<>(); private final Map<Flora, Range> floraHeights = new HashMap<>();
private int floraAttempts;
private int floraChance;
private boolean floraSimplex;
private FastNoise floraNoise;
public BiomeFloraConfig(TerraConfig parent) throws InvalidConfigurationException { public BiomeFloraConfig(TerraConfig parent) throws InvalidConfigurationException {
super(parent); super(parent);
ConfigurationSection cfg = parent.getConfigurationSection("flora"); ConfigurationSection cfg = parent.getConfigurationSection("flora.items");
if(cfg == null) return; if(cfg == null) return;
floraSimplex = parent.getBoolean("flora.simplex.enable", false);
floraAttempts = parent.getInt("flora.attempts", 1);
floraChance = parent.getInt("flora.chance", 0);
float floraFreq = (float) parent.getDouble("flora.simplex.frequency", 0.1);
int floraSeed = parent.getInt("flora.simplex.seed", 0);
if(floraSimplex) {
floraNoise = new FastNoise(floraSeed);
floraNoise.setNoiseType(FastNoise.NoiseType.Simplex);
floraNoise.setFrequency(floraFreq);
}
try { try {
for(Map.Entry<String, Object> e : cfg.getValues(false).entrySet()) { for(Map.Entry<String, Object> e : cfg.getValues(false).entrySet()) {
Map<?, ?> val = ((ConfigurationSection) e.getValue()).getValues(false); Map<?, ?> val = ((ConfigurationSection) e.getValue()).getValues(false);
@ -57,4 +73,20 @@ public class BiomeFloraConfig extends TerraConfigSection {
public Map<Flora, Range> getFloraHeights() { public Map<Flora, Range> getFloraHeights() {
return floraHeights; return floraHeights;
} }
public FastNoise getFloraNoise() {
return floraNoise;
}
public int getFloraAttempts() {
return floraAttempts;
}
public boolean isFloraSimplex() {
return floraSimplex;
}
public int getFloraChance() {
return floraChance;
}
} }

View File

@ -0,0 +1,50 @@
package com.dfsek.terra.config.genconfig.biome;
import com.dfsek.terra.config.TerraConfig;
import com.dfsek.terra.config.TerraConfigSection;
import com.dfsek.terra.config.exception.ConfigException;
import com.dfsek.terra.config.exception.NotFoundException;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.InvalidConfigurationException;
import org.jetbrains.annotations.NotNull;
import org.polydev.gaea.math.ProbabilityCollection;
import org.polydev.gaea.world.palette.Palette;
import org.polydev.gaea.world.palette.RandomPalette;
import java.util.Random;
public class BiomeOceanConfig extends TerraConfigSection {
private final Palette<BlockData> ocean;
private final int seaLevel;
private static final Palette<BlockData> oceanDefault = new RandomPalette<BlockData>(new Random(0)).add(Material.WATER.createBlockData(), 1);
public BiomeOceanConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException {
super(parent);
seaLevel = parent.getInt("ocean.level", 62);
String oceanN = parent.getString("ocean.palette");
if(oceanN != null) {
if(oceanN.startsWith("BLOCK:")) {
try {
ocean = new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(oceanN.substring(6)), 1), 1);
} catch(IllegalArgumentException ex) {
throw new ConfigException("BlockData \"" + oceanN + "\" is invalid! (Ocean Palette)", parent.getID());
}
} else {
try {
ocean = parent.getConfig().getPalette(oceanN).getPalette();
} catch(NullPointerException ex) {
throw new NotFoundException("Palette", oceanN, parent.getID());
}
}
} else ocean = oceanDefault;
}
public Palette<BlockData> getOcean() {
return ocean;
}
public int getSeaLevel() {
return seaLevel;
}
}

View File

@ -22,8 +22,10 @@ import java.util.Random;
public class BiomeSlabConfig extends TerraConfigSection { public class BiomeSlabConfig extends TerraConfigSection {
private final Map<Material, Palette<BlockData>> slabs; private final Map<Material, Palette<BlockData>> slabs;
private final Map<Material, Palette<BlockData>> stairs; private final Map<Material, Palette<BlockData>> stairs;
private double slabThreshold;
public BiomeSlabConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException { public BiomeSlabConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException {
super(parent); super(parent);
slabThreshold = parent.getDouble("slabs.threshold", 0.1D);
slabs = getSlabPalettes(parent.getMapList("slabs.palettes")); slabs = getSlabPalettes(parent.getMapList("slabs.palettes"));
if(parent.contains("slabs.stair-palettes") && parent.getBoolean("slabs.use-stairs-if-available", false)) { if(parent.contains("slabs.stair-palettes") && parent.getBoolean("slabs.use-stairs-if-available", false)) {
stairs = getSlabPalettes(parent.getMapList("slabs.stair-palettes")); stairs = getSlabPalettes(parent.getMapList("slabs.stair-palettes"));
@ -67,4 +69,8 @@ public class BiomeSlabConfig extends TerraConfigSection {
public Map<Material, Palette<BlockData>> getSlabs() { public Map<Material, Palette<BlockData>> getSlabs() {
return slabs; return slabs;
} }
public double getSlabThreshold() {
return slabThreshold;
}
} }

View File

@ -17,12 +17,16 @@ import java.util.Map;
public class BiomeTreeConfig extends TerraConfigSection { public class BiomeTreeConfig extends TerraConfigSection {
private final ProbabilityCollection<Tree> trees = new ProbabilityCollection<>(); private final ProbabilityCollection<Tree> trees = new ProbabilityCollection<>();
private final Map<Tree, Range> treeHeights = new HashMap<>(); private final Map<Tree, Range> treeHeights = new HashMap<>();
private int treeChance;
private int treeDensity;
public BiomeTreeConfig(TerraConfig parent) throws InvalidConfigurationException { public BiomeTreeConfig(TerraConfig parent) throws InvalidConfigurationException {
super(parent); super(parent);
ConfigurationSection c = parent.getConfigurationSection("trees"); ConfigurationSection c = parent.getConfigurationSection("trees.items");
if(c == null) return; if(c == null) return;
Map<String, Object> cfg = c.getValues(false); Map<String, Object> cfg = c.getValues(false);
if(cfg.size() == 0) return; if(cfg.size() == 0) return;
treeChance = parent.getInt("trees.chance", 0);
treeDensity = parent.getInt("trees.density", 0);
for(Map.Entry<String, Object> e : cfg.entrySet()) { for(Map.Entry<String, Object> e : cfg.entrySet()) {
try { try {
Map<?, ?> val = ((ConfigurationSection) e.getValue()).getValues(false); Map<?, ?> val = ((ConfigurationSection) e.getValue()).getValues(false);
@ -45,4 +49,12 @@ public class BiomeTreeConfig extends TerraConfigSection {
public Map<Tree, Range> getTreeHeights() { public Map<Tree, Range> getTreeHeights() {
return treeHeights; return treeHeights;
} }
public int getTreeDensity() {
return treeDensity;
}
public int getTreeChance() {
return treeChance;
}
} }

View File

@ -6,6 +6,7 @@ import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.biome.UserDefinedBiome; import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.config.base.ConfigPack; import com.dfsek.terra.config.base.ConfigPack;
import com.dfsek.terra.config.genconfig.biome.BiomeConfig; import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
import com.dfsek.terra.config.genconfig.biome.BiomeSlabConfig;
import com.dfsek.terra.population.CavePopulator; import com.dfsek.terra.population.CavePopulator;
import com.dfsek.terra.population.FloraPopulator; import com.dfsek.terra.population.FloraPopulator;
import com.dfsek.terra.population.OrePopulator; import com.dfsek.terra.population.OrePopulator;
@ -71,14 +72,15 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
int cz = zOrig + z; int cz = zOrig + z;
Biome b = getBiomeGrid(world).getBiome(xOrig+x, zOrig+z, GenerationPhase.PALETTE_APPLY); Biome b = getBiomeGrid(world).getBiome(xOrig+x, zOrig+z, GenerationPhase.PALETTE_APPLY);
BiomeConfig c = config.getBiome((UserDefinedBiome) b); BiomeConfig c = config.getBiome((UserDefinedBiome) b);
int sea = c.getSeaLevel(); BiomeSlabConfig slab = c.getSlabs();
Palette<BlockData> seaPalette = c.getOceanPalette(); int sea = c.getOcean().getSeaLevel();
Palette<BlockData> seaPalette = c.getOcean().getOcean();
for(int y = world.getMaxHeight()-1; y >= 0; y--) { for(int y = world.getMaxHeight()-1; y >= 0; y--) {
if(super.getInterpolatedNoise(x, y, z) > 0) { if(super.getInterpolatedNoise(x, y, z) > 0) {
BlockData data = b.getGenerator().getPalette(y).get(paletteLevel, cx, cz); BlockData data = b.getGenerator().getPalette(y).get(paletteLevel, cx, cz);
chunk.setBlock(x, y, z, data); chunk.setBlock(x, y, z, data);
if(paletteLevel == 0 && c.getSlabs() != null && y < 255) { if(paletteLevel == 0 && c.getSlabs() != null && y < 255) {
prepareBlockPart(data, chunk.getBlockData(x, y+1, z), chunk, new Vector(x, y+1, z), c.getSlabs(), c.getStairs(), c.getSlabThreshold()); prepareBlockPart(data, chunk.getBlockData(x, y+1, z), chunk, new Vector(x, y+1, z), slab.getSlabs(), slab.getStairs(), slab.getSlabThreshold());
} }
paletteLevel++; paletteLevel++;
} else if(y <= sea) { } else if(y <= sea) {

View File

@ -6,6 +6,7 @@ import com.dfsek.terra.biome.TerraBiomeGrid;
import com.dfsek.terra.biome.UserDefinedBiome; import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.config.base.ConfigPack; import com.dfsek.terra.config.base.ConfigPack;
import com.dfsek.terra.config.genconfig.biome.BiomeConfig; import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
import com.dfsek.terra.config.genconfig.biome.BiomeFloraConfig;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -30,9 +31,10 @@ public class FloraPopulator extends GaeaBlockPopulator {
if(biome.getDecorator().getFloraChance() <= 0) continue; if(biome.getDecorator().getFloraChance() <= 0) continue;
try { try {
BiomeConfig c = config.getBiome(biome); BiomeConfig c = config.getBiome(biome);
for(int i = 0; i < c.getFloraAttempts(); i++) { BiomeFloraConfig f = c.getFlora();
for(int i = 0; i < f.getFloraAttempts(); i++) {
Flora item; Flora item;
if(c.isFloraSimplex()) item = biome.getDecorator().getFlora().get(c.getFloraNoise(), (chunk.getX() << 4) + x, (chunk.getZ() << 4) + z); if(f.isFloraSimplex()) item = biome.getDecorator().getFlora().get(f.getFloraNoise(), (chunk.getX() << 4) + x, (chunk.getZ() << 4) + z);
else item = biome.getDecorator().getFlora().get(random); else item = biome.getDecorator().getFlora().get(random);
for(Block highest : item.getValidSpawnsAt(chunk, x, z, c.getFloraHeights(item))) { for(Block highest : item.getValidSpawnsAt(chunk, x, z, c.getFloraHeights(item))) {
if(random.nextInt(100) < biome.getDecorator().getFloraChance()) if(random.nextInt(100) < biome.getDecorator().getFloraChance())

View File

@ -23,12 +23,12 @@ public class OrePopulator extends GaeaBlockPopulator {
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("OreTime")) { try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("OreTime")) {
ConfigPack config = TerraWorld.getWorld(world).getConfig(); ConfigPack config = TerraWorld.getWorld(world).getConfig();
Biome b = TerraWorld.getWorld(world).getGrid().getBiome((chunk.getX() << 4)+8, (chunk.getZ() << 4) + 8, GenerationPhase.POPULATE); Biome b = TerraWorld.getWorld(world).getGrid().getBiome((chunk.getX() << 4)+8, (chunk.getZ() << 4) + 8, GenerationPhase.POPULATE);
for(Map.Entry<OreConfig, Range> e : config.getBiome((UserDefinedBiome) b).getOres().entrySet()) { for(Map.Entry<OreConfig, Range> e : config.getBiome((UserDefinedBiome) b).getOres().getOres().entrySet()) {
int num = e.getValue().get(random); int num = e.getValue().get(random);
for(int i = 0; i < num; i++) { for(int i = 0; i < num; i++) {
int x = random.nextInt(16); int x = random.nextInt(16);
int z = random.nextInt(16); int z = random.nextInt(16);
int y = config.getBiome((UserDefinedBiome) b).getOreHeight(e.getKey()).get(random); int y = config.getBiome((UserDefinedBiome) b).getOres().getOreHeights().get(e.getKey()).get(random);
e.getKey().doVein(chunk.getBlock(x, y, z).getLocation(), random); e.getKey().doVein(chunk.getBlock(x, y, z).getLocation(), random);
} }
} }

View File

@ -51,7 +51,7 @@ public class StructureSpawnRequirement implements Serializable {
public boolean matches(World w, int x, int y, int z) { public boolean matches(World w, int x, int y, int z) {
UserDefinedBiome b = (UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(x, z, GenerationPhase.POPULATE); UserDefinedBiome b = (UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(x, z, GenerationPhase.POPULATE);
BiomeConfig c = TerraWorld.getWorld(w).getConfig().getBiome(b); BiomeConfig c = TerraWorld.getWorld(w).getConfig().getBiome(b);
if(y <= c.getSeaLevel()) return false; if(y <= c.getOcean().getSeaLevel()) return false;
return b.getGenerator().getNoise(getNoise(w), w, x, y, z) <= 0; return b.getGenerator().getNoise(getNoise(w), w, x, y, z) <= 0;
} }
}, OCEAN { }, OCEAN {
@ -59,7 +59,7 @@ public class StructureSpawnRequirement implements Serializable {
public boolean matches(World w, int x, int y, int z) { public boolean matches(World w, int x, int y, int z) {
UserDefinedBiome b = (UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(x, z, GenerationPhase.POPULATE); UserDefinedBiome b = (UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(x, z, GenerationPhase.POPULATE);
BiomeConfig c = TerraWorld.getWorld(w).getConfig().getBiome(b); BiomeConfig c = TerraWorld.getWorld(w).getConfig().getBiome(b);
if(y > c.getSeaLevel()) return false; if(y > c.getOcean().getSeaLevel()) return false;
return b.getGenerator().getNoise(getNoise(w), w, x, y, z) <= 0; return b.getGenerator().getNoise(getNoise(w), w, x, y, z) <= 0;
} }
}, LAND { }, LAND {