mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-14 03:36:03 +00:00
Implement ores, begin work on caves.
This commit is contained in:
@@ -16,7 +16,7 @@ public class BiomeZone {
|
||||
private static final double[] normalMap = new double[] {-0.35662081837654114D, -0.30661869049072266D, -0.27095329761505127D, -0.24149227142333984D, -0.21537694334983826D, -0.19166918098926544D, -0.16956785321235657D, -0.14864568412303925D, -0.12845154106616974D, -0.10894706845283508D, -0.08996972441673279D, -0.0715663805603981D, -0.053535036742687225D, -0.03580872714519501D, -0.01817353256046772D, -7.577221258543432E-4D, 0.016616813838481903D, 0.03416096046566963D, 0.05187138542532921D, 0.06989025324583054D, 0.08827653527259827D, 0.10723070055246353D, 0.12675245106220245D, 0.14694781601428986D, 0.16793397068977356D, 0.18999846279621124D, 0.2138010412454605D, 0.24002985656261444D, 0.2696261405944824D, 0.30540621280670166D, 0.35551881790161133D, 0.653269350528717D};
|
||||
|
||||
|
||||
public BiomeZone(World w, float freq) {
|
||||
private BiomeZone(World w, float freq) {
|
||||
this.w = w;
|
||||
this.noise = new FastNoise((int) w.getSeed()+2);
|
||||
noise.setNoiseType(FastNoise.NoiseType.SimplexFractal);
|
||||
@@ -31,11 +31,11 @@ public class BiomeZone {
|
||||
this.grids = grids;
|
||||
}
|
||||
|
||||
public BiomeGrid getGrid(int x, int z) {
|
||||
protected BiomeGrid getGrid(int x, int z) {
|
||||
return grids[normalize(noise.getSimplexFractal(x, z))];
|
||||
}
|
||||
|
||||
public static BiomeZone fromWorld(World w) {
|
||||
protected static BiomeZone fromWorld(World w) {
|
||||
if(zones.containsKey(w)) return zones.get(w);
|
||||
else return new BiomeZone(w, WorldConfig.fromWorld(w).zoneFreq);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.dfsek.terra.config.BiomeConfig;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.polydev.gaea.biome.Biome;
|
||||
import org.polydev.gaea.biome.BiomeTerrain;
|
||||
@@ -26,7 +27,7 @@ public class UserDefinedBiome implements Biome {
|
||||
private final UserDefinedGenerator gen;
|
||||
private final BiomeConfig config;
|
||||
private final UserDefinedDecorator decorator;
|
||||
public UserDefinedBiome(BiomeConfig config) throws ParseException {
|
||||
public UserDefinedBiome(BiomeConfig config) throws ParseException, InvalidConfigurationException {
|
||||
this.config = config;
|
||||
TreeMap<Integer, BlockPalette> paletteMap = new TreeMap<>();
|
||||
for(Map<?, ?> e : config.getMapList("palette")) {
|
||||
@@ -34,14 +35,20 @@ public class UserDefinedBiome implements Biome {
|
||||
try {
|
||||
if(((String) entry.getKey()).startsWith("BLOCK:")) {
|
||||
try {
|
||||
paletteMap.put((Integer) entry.getValue(), new BlockPalette().addBlockData(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData((String) entry.getKey()), 1), 1));
|
||||
paletteMap.put((Integer) entry.getValue(), new BlockPalette().addBlockData(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1));
|
||||
} catch(IllegalArgumentException ex) {
|
||||
Bukkit.getLogger().severe("SEVERE configuration error for BlockPalettes in biome" + config.getFriendlyName() + ", ID: " + config.getBiomeID() + ". BlockData " + entry.getKey() + " is invalid!");
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalettes in biome " + config.getFriendlyName() + ", ID: " + config.getBiomeID() + ". BlockData " + entry.getKey() + " is invalid!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
paletteMap.put((Integer) entry.getValue(), ConfigUtil.getPalette((String) entry.getKey()).getPalette());
|
||||
} catch(NullPointerException ex) {
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalettes in biome " + config.getFriendlyName() + ", ID: " + config.getBiomeID() + "\n\nPalette " + entry.getKey() + " cannot be found!");
|
||||
}
|
||||
}
|
||||
else paletteMap.put((Integer) entry.getValue(), ConfigUtil.getPalette((String) entry.getKey()).getPalette());
|
||||
} catch(ClassCastException ex) {
|
||||
Bukkit.getLogger().severe("SEVERE configuration error for BlockPalettes in biome" + config.getFriendlyName() + ", ID: " + config.getBiomeID());
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalettes in biome" + config.getFriendlyName() + ", ID: " + config.getBiomeID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.dfsek.terra.biome;
|
||||
|
||||
import com.dfsek.terra.TerraTree;
|
||||
import com.dfsek.terra.config.BiomeConfig;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.polydev.gaea.biome.Decorator;
|
||||
import org.polydev.gaea.math.ProbabilityCollection;
|
||||
import org.polydev.gaea.tree.Tree;
|
||||
import org.polydev.gaea.tree.TreeType;
|
||||
import org.polydev.gaea.world.Fauna;
|
||||
import org.polydev.gaea.world.FaunaType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -20,12 +26,27 @@ public class UserDefinedDecorator extends Decorator {
|
||||
public UserDefinedDecorator(BiomeConfig config) {
|
||||
if(config.contains("fauna")) {
|
||||
for(Map.Entry<String, Object> e : config.getConfigurationSection("fauna").getValues(false).entrySet()) {
|
||||
fauna.add(Fauna.valueOf(e.getKey()), (Integer) e.getValue());
|
||||
try {
|
||||
Bukkit.getLogger().info("[Terra] Adding " + e.getKey() + " to biome's fauna list with weight " + e.getValue());
|
||||
fauna.add(FaunaType.valueOf(e.getKey()), (Integer) e.getValue());
|
||||
} catch(IllegalArgumentException ex) {
|
||||
try {
|
||||
Bukkit.getLogger().info("[Terra] Is custom fauna: true");
|
||||
Fauna faunaCustom = ConfigUtil.getFauna(e.getKey());
|
||||
fauna.add(faunaCustom, (Integer) e.getValue());
|
||||
} catch(NullPointerException ex2) {
|
||||
throw new IllegalArgumentException("SEVERE configuration error for fauna in biome " + config.getFriendlyName() + ", ID " + config.getBiomeID() + "\n\nFauna with ID " + e.getKey() + " cannot be found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(config.contains("trees")) {
|
||||
for(Map.Entry<String, Object> e : config.getConfigurationSection("trees").getValues(false).entrySet()) {
|
||||
trees.add(Tree.valueOf(e.getKey()), (Integer) e.getValue());
|
||||
if(e.getKey().startsWith("TERRA:")) {
|
||||
trees.add(TerraTree.valueOf(e.getKey().substring(6)), (Integer) e.getValue());
|
||||
} else {
|
||||
trees.add(TreeType.valueOf(e.getKey()), (Integer) e.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
faunaChance = config.getInt("fauna-chance", 0);
|
||||
|
||||
Reference in New Issue
Block a user