mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 02:20:57 +00:00
Refactor & update to Gaea 1.10
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -95,7 +95,7 @@
|
||||
<dependency>
|
||||
<groupId>org.polydev</groupId>
|
||||
<artifactId>gaea</artifactId>
|
||||
<version>1.9.6</version>
|
||||
<version>1.10.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.vecmath</groupId>
|
||||
|
||||
@@ -3,11 +3,12 @@ package com.dfsek.terra;
|
||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||
import com.dfsek.terra.config.WorldConfig;
|
||||
import com.dfsek.terra.population.CavePopulator;
|
||||
import com.dfsek.terra.population.FaunaPopulator;
|
||||
import com.dfsek.terra.population.FloraPopulator;
|
||||
import com.dfsek.terra.population.OrePopulator;
|
||||
import com.dfsek.terra.population.TreePopulator;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.generation.GaeaChunkGenerator;
|
||||
@@ -22,11 +23,13 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class TerraChunkGenerator extends GaeaChunkGenerator {
|
||||
private static final BlockData STONE = Material.STONE.createBlockData();
|
||||
private static final BlockData WATER = Material.WATER.createBlockData();
|
||||
private final PopulationManager popMan = new PopulationManager();
|
||||
public TerraChunkGenerator() {
|
||||
super(ChunkInterpolator.InterpolationType.TRILINEAR);
|
||||
popMan.attach(new TreePopulator());
|
||||
popMan.attach(new FaunaPopulator());
|
||||
popMan.attach(new FloraPopulator());
|
||||
popMan.attach(new OrePopulator());
|
||||
}
|
||||
|
||||
@@ -37,8 +40,8 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
||||
for(byte x = 0; x < 16; x++) {
|
||||
for(int y = 0; y < 256; y++) {
|
||||
for(byte z = 0; z < 16; z++) {
|
||||
if(super.getInterpolatedNoise(x, y, z) > 0) chunk.setBlock(x, y, z, Material.STONE);
|
||||
else if(y < sea) chunk.setBlock(x, y, z, Material.WATER);
|
||||
if(super.getInterpolatedNoise(x, y, z) > 0) chunk.setBlock(x, y, z, STONE);
|
||||
else if(y < sea) chunk.setBlock(x, y, z, WATER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TerraProfiler extends WorldProfiler {
|
||||
.addMeasurement(new Measurement(2500000, DataType.PERIOD_MILLISECONDS), "ChunkBaseGenTime")
|
||||
.addMeasurement(new Measurement(2000000, DataType.PERIOD_MILLISECONDS), "BiomeSetTime")
|
||||
.addMeasurement(new Measurement(25000000, DataType.PERIOD_NANOSECONDS), "TreeGenTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "FaunaTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "FloraTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveBlockUpdate");
|
||||
profilerMap.put(w, this);
|
||||
|
||||
@@ -16,12 +16,14 @@ public class TerraBiomeGrid extends BiomeGrid {
|
||||
|
||||
private static final Map<World, TerraBiomeGrid> grids = new HashMap<>();
|
||||
private final World w;
|
||||
private final BiomeZone zone;
|
||||
|
||||
|
||||
|
||||
private TerraBiomeGrid(World w, float freq1, float freq2, boolean blank) {
|
||||
super(w, freq1, freq2);
|
||||
this.w = w;
|
||||
this.zone = BiomeZone.fromWorld(w);
|
||||
if(!blank) grids.put(w, this);
|
||||
}
|
||||
|
||||
@@ -41,7 +43,7 @@ public class TerraBiomeGrid extends BiomeGrid {
|
||||
@Override
|
||||
public Biome getBiome(int x, int z) {
|
||||
try {
|
||||
return BiomeZone.fromWorld(w).getGrid(x, z).getBiome(x, z);
|
||||
return zone.getGrid(x, z).getBiome(x, z);
|
||||
} catch(NullPointerException e) {
|
||||
if(ConfigUtil.debug) e.printStackTrace();
|
||||
if(failNum % 256 == 0) Bukkit.getLogger().severe("[Terra] A severe configuration error has prevented Terra from properly generating terrain at coordinates: " + x + ", " + z + ". Please check your configuration for errors. Any config errors will have been reported above.");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.biome;
|
||||
|
||||
import org.polydev.gaea.biome.Biome;
|
||||
import org.polydev.gaea.biome.BiomeTerrain;
|
||||
import org.polydev.gaea.biome.Generator;
|
||||
import org.polydev.gaea.biome.Decorator;
|
||||
import org.polydev.gaea.structures.features.Feature;
|
||||
|
||||
@@ -32,12 +32,12 @@ public class UserDefinedBiome implements Biome {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the BiomeTerrain instance used to generate the biome.
|
||||
* Gets the Generator instance used to generate the biome.
|
||||
*
|
||||
* @return BiomeTerrain - The terrain generation instance.
|
||||
* @return Generator - The terrain generation instance.
|
||||
*/
|
||||
@Override
|
||||
public BiomeTerrain getGenerator() {
|
||||
public Generator getGenerator() {
|
||||
return gen;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,21 +4,21 @@ import org.bukkit.block.Biome;
|
||||
import org.polydev.gaea.biome.Decorator;
|
||||
import org.polydev.gaea.math.ProbabilityCollection;
|
||||
import org.polydev.gaea.tree.Tree;
|
||||
import org.polydev.gaea.world.Fauna;
|
||||
import org.polydev.gaea.world.Flora;
|
||||
|
||||
public class UserDefinedDecorator extends Decorator {
|
||||
|
||||
private final ProbabilityCollection<Fauna> fauna;
|
||||
private final ProbabilityCollection<Flora> flora;
|
||||
private final ProbabilityCollection<Tree> trees;
|
||||
private final int faunaChance;
|
||||
private final int floraChance;
|
||||
private final int treeChance;
|
||||
private final int treeDensity;
|
||||
|
||||
public UserDefinedDecorator(ProbabilityCollection<Fauna> fauna, ProbabilityCollection<Tree> trees, int faunaChance, int treeChance, int treeDensity) {
|
||||
this.fauna = fauna;
|
||||
public UserDefinedDecorator(ProbabilityCollection<Flora> flora, ProbabilityCollection<Tree> trees, int floraChance, int treeChance, int treeDensity) {
|
||||
this.flora = flora;
|
||||
this.trees = trees;
|
||||
|
||||
this.faunaChance = faunaChance;
|
||||
this.floraChance = floraChance;
|
||||
this.treeChance = treeChance;
|
||||
this.treeDensity = treeDensity;
|
||||
}
|
||||
@@ -42,23 +42,18 @@ public class UserDefinedDecorator extends Decorator {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateSnow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getVanillaBiome() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProbabilityCollection<Fauna> getFauna() {
|
||||
return fauna;
|
||||
public ProbabilityCollection<Flora> getFlora() {
|
||||
return flora;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFaunaChance() {
|
||||
return faunaChance;
|
||||
public int getFloraChance() {
|
||||
return floraChance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +1,36 @@
|
||||
package com.dfsek.terra.biome;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.config.WorldConfig;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
import com.dfsek.terra.math.NoiseFunction2;
|
||||
import com.dfsek.terra.math.NoiseFunction3;
|
||||
import org.bukkit.World;
|
||||
import org.polydev.gaea.biome.BiomeTerrain;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.polydev.gaea.biome.Generator;
|
||||
import org.polydev.gaea.math.FastNoise;
|
||||
import org.polydev.gaea.math.parsii.eval.Expression;
|
||||
import org.polydev.gaea.math.parsii.eval.Parser;
|
||||
import org.polydev.gaea.math.parsii.eval.Scope;
|
||||
import org.polydev.gaea.math.parsii.eval.Variable;
|
||||
import org.polydev.gaea.math.parsii.tokenizer.ParseException;
|
||||
import org.polydev.gaea.world.palette.BlockPalette;
|
||||
import org.polydev.gaea.world.palette.Palette;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class UserDefinedGenerator extends BiomeTerrain {
|
||||
public class UserDefinedGenerator extends Generator {
|
||||
private final Expression noiseExp;
|
||||
private final Scope s = new Scope();
|
||||
private final Variable xVar = s.getVariable("x");;
|
||||
private final Variable yVar = s.getVariable("y");
|
||||
private final Variable zVar = s.getVariable("z");;
|
||||
private final TreeMap<Integer, BlockPalette> paletteMap;
|
||||
private final TreeMap<Integer, Palette<BlockData>> paletteMap;
|
||||
private final NoiseFunction2 n2 = new NoiseFunction2();
|
||||
private final NoiseFunction3 n3 = new NoiseFunction3();
|
||||
|
||||
private static final Object noiseLock = new Object();
|
||||
|
||||
|
||||
public UserDefinedGenerator(String e, List<Variable> v, TreeMap<Integer, BlockPalette> pa) throws ParseException {
|
||||
public UserDefinedGenerator(String e, List<Variable> v, TreeMap<Integer, Palette<BlockData>> pa) throws ParseException {
|
||||
Parser p = new Parser();
|
||||
p.registerFunction("noise2", n2);
|
||||
p.registerFunction("noise3", n3);
|
||||
@@ -86,8 +84,8 @@ public class UserDefinedGenerator extends BiomeTerrain {
|
||||
* @return BlocPalette - The biome's palette.
|
||||
*/
|
||||
@Override
|
||||
public BlockPalette getPalette(int y) {
|
||||
for(Map.Entry<Integer, BlockPalette> e : paletteMap.entrySet()) {
|
||||
public Palette<BlockData> getPalette(int y) {
|
||||
for(Map.Entry<Integer, Palette<BlockData>> e : paletteMap.entrySet()) {
|
||||
if(e.getKey() >= y ) return e.getValue();
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.dfsek.terra.config.genconfig.AbstractBiomeConfig;
|
||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
||||
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||
import com.dfsek.terra.config.genconfig.FaunaConfig;
|
||||
import com.dfsek.terra.config.genconfig.FloraConfig;
|
||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||
import com.dfsek.terra.config.genconfig.PaletteConfig;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -34,7 +34,7 @@ public class ConfigUtil {
|
||||
|
||||
new ConfigLoader("carving").load(main, CarverConfig.class);
|
||||
|
||||
new ConfigLoader("fauna").load(main, FaunaConfig.class);
|
||||
new ConfigLoader("flora").load(main, FloraConfig.class);
|
||||
|
||||
new ConfigLoader("abstract" + File.separator + "biomes").load(main, AbstractBiomeConfig.class);
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@ import org.bukkit.configuration.InvalidConfigurationException;
|
||||
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 org.polydev.gaea.world.palette.BlockPalette;
|
||||
import org.polydev.gaea.world.Flora;
|
||||
import org.polydev.gaea.world.FloraType;
|
||||
import org.polydev.gaea.world.palette.Palette;
|
||||
import org.polydev.gaea.world.palette.Palette;
|
||||
import org.polydev.gaea.world.palette.RandomPalette;
|
||||
|
||||
import java.io.File;
|
||||
@@ -29,13 +30,13 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
||||
private Map<OreConfig, MaxMin> ores;
|
||||
private Map<OreConfig, MaxMin> oreHeights;
|
||||
private Map<CarverConfig, Integer> carvers;
|
||||
private ProbabilityCollection<Fauna> fauna;
|
||||
private ProbabilityCollection<Flora> flora;
|
||||
private ProbabilityCollection<Tree> trees;
|
||||
private int faunaChance;
|
||||
private int floraChance;
|
||||
private int treeChance;
|
||||
private int treeDensity;
|
||||
private String equation;
|
||||
private TreeMap<Integer, BlockPalette> paletteMap;
|
||||
private TreeMap<Integer, Palette<BlockData>> paletteMap;
|
||||
|
||||
public AbstractBiomeConfig(File file) throws IOException, InvalidConfigurationException {
|
||||
super(file);
|
||||
@@ -53,19 +54,19 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
||||
try {
|
||||
if(((String) entry.getKey()).startsWith("BLOCK:")) {
|
||||
try {
|
||||
paletteMap.put((Integer) entry.getValue(), new RandomPalette(new Random(0)).addBlockData(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1));
|
||||
paletteMap.put((Integer) entry.getValue(), new RandomPalette(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1));
|
||||
} catch(IllegalArgumentException ex) {
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalettes in abstract biome, ID: " + biomeID + ". BlockData " + entry.getKey() + " is invalid!");
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for Palettes in abstract biome, ID: " + biomeID + ". BlockData " + entry.getKey() + " is invalid!");
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
paletteMap.put((Integer) entry.getValue(), PaletteConfig.fromID((String) entry.getKey()).getPalette());
|
||||
} catch(NullPointerException ex) {
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalettes in abstract biome, ID: " + biomeID + "\n\nPalette " + entry.getKey() + " cannot be found!");
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for Palettes in abstract biome, ID: " + biomeID + "\n\nPalette " + entry.getKey() + " cannot be found!");
|
||||
}
|
||||
}
|
||||
} catch(ClassCastException ex) {
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalettes in abstract biome, ID: " + biomeID);
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for Palettes in abstract biome, ID: " + biomeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,19 +90,19 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
||||
}
|
||||
}
|
||||
|
||||
if(contains("fauna")) {
|
||||
fauna = new ProbabilityCollection<>();
|
||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("fauna")).getValues(false).entrySet()) {
|
||||
if(contains("flora")) {
|
||||
flora = new ProbabilityCollection<>();
|
||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("flora")).getValues(false).entrySet()) {
|
||||
try {
|
||||
Bukkit.getLogger().info("[Terra] Adding " + e.getKey() + " to abstract biome's fauna list with weight " + e.getValue());
|
||||
fauna.add(FaunaType.valueOf(e.getKey()), (Integer) e.getValue());
|
||||
Bukkit.getLogger().info("[Terra] Adding " + e.getKey() + " to abstract biome's flora list with weight " + e.getValue());
|
||||
flora.add(FloraType.valueOf(e.getKey()), (Integer) e.getValue());
|
||||
} catch(IllegalArgumentException ex) {
|
||||
try {
|
||||
Bukkit.getLogger().info("[Terra] Is custom fauna: true");
|
||||
Fauna faunaCustom = FaunaConfig.fromID(e.getKey());
|
||||
fauna.add(faunaCustom, (Integer) e.getValue());
|
||||
Bukkit.getLogger().info("[Terra] Is custom flora: true");
|
||||
Flora floraCustom = FloraConfig.fromID(e.getKey());
|
||||
flora.add(floraCustom, (Integer) e.getValue());
|
||||
} catch(NullPointerException ex2) {
|
||||
throw new IllegalArgumentException("SEVERE configuration error for fauna in abstract biome, ID " + getID() + "\n\nFauna with ID " + e.getKey() + " cannot be found!");
|
||||
throw new IllegalArgumentException("SEVERE configuration error for flora in abstract biome, ID " + getID() + "\n\nFlora with ID " + e.getKey() + " cannot be found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,7 +117,7 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
faunaChance = getInt("fauna-chance", 0);
|
||||
floraChance = getInt("flora-chance", 0);
|
||||
treeChance = getInt("tree-chance", 0);
|
||||
treeDensity = getInt("tree-density", 0);
|
||||
equation = getString("noise-equation");
|
||||
@@ -138,8 +139,8 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
||||
return biomeID;
|
||||
}
|
||||
|
||||
public int getFaunaChance() {
|
||||
return faunaChance;
|
||||
public int getFloraChance() {
|
||||
return floraChance;
|
||||
}
|
||||
|
||||
public int getTreeChance() {
|
||||
@@ -166,8 +167,8 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
public ProbabilityCollection<Fauna> getFauna() {
|
||||
return fauna;
|
||||
public ProbabilityCollection<Flora> getFlora() {
|
||||
return flora;
|
||||
}
|
||||
|
||||
public ProbabilityCollection<Tree> getTrees() {
|
||||
@@ -178,7 +179,7 @@ public class AbstractBiomeConfig extends TerraConfigObject {
|
||||
return equation;
|
||||
}
|
||||
|
||||
public TreeMap<Integer, BlockPalette> getPaletteMap() {
|
||||
public TreeMap<Integer, Palette<BlockData>> getPaletteMap() {
|
||||
return paletteMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,10 @@ import org.polydev.gaea.math.ProbabilityCollection;
|
||||
import org.polydev.gaea.math.parsii.tokenizer.ParseException;
|
||||
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 org.polydev.gaea.world.palette.BlockPalette;
|
||||
import org.polydev.gaea.world.Flora;
|
||||
import org.polydev.gaea.world.FloraType;
|
||||
import org.polydev.gaea.world.palette.Palette;
|
||||
import org.polydev.gaea.world.palette.RandomPalette;
|
||||
import scala.concurrent.impl.FutureConvertersImpl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -37,7 +36,6 @@ public class BiomeConfig extends TerraConfigObject {
|
||||
private UserDefinedBiome biome;
|
||||
private String biomeID;
|
||||
private String friendlyName;
|
||||
private org.bukkit.block.Biome vanillaBiome;
|
||||
private Map<OreConfig, MaxMin> ores;
|
||||
private Map<OreConfig, MaxMin> oreHeights;
|
||||
private Map<CarverConfig, Integer> carvers;
|
||||
@@ -51,7 +49,7 @@ public class BiomeConfig extends TerraConfigObject {
|
||||
public void init() throws InvalidConfigurationException {
|
||||
oreHeights = new HashMap<>();
|
||||
ores = new HashMap<>();
|
||||
ProbabilityCollection<Fauna> fauna = new ProbabilityCollection<>();
|
||||
ProbabilityCollection<Flora> flora = new ProbabilityCollection<>();
|
||||
ProbabilityCollection<Tree> trees = new ProbabilityCollection<>();
|
||||
if(!contains("id")) throw new InvalidConfigurationException("Biome ID unspecified!");
|
||||
this.biomeID = getString("id");
|
||||
@@ -73,7 +71,7 @@ public class BiomeConfig extends TerraConfigObject {
|
||||
}
|
||||
}
|
||||
|
||||
TreeMap<Integer, BlockPalette> paletteMap;
|
||||
TreeMap<Integer, Palette<BlockData>> paletteMap;
|
||||
// Check if biome is extending abstract biome, only use abstract biome's palette if palette is NOT defined for current biome.
|
||||
if(extending && abstractBiome.getPaletteMap() != null && !contains("palette")) {
|
||||
paletteMap = abstractBiome.getPaletteMap();
|
||||
@@ -85,20 +83,20 @@ public class BiomeConfig extends TerraConfigObject {
|
||||
try {
|
||||
if(((String) entry.getKey()).startsWith("BLOCK:")) {
|
||||
try {
|
||||
paletteMap.put((Integer) entry.getValue(), new RandomPalette(new Random(0)).addBlockData(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1));
|
||||
paletteMap.put((Integer) entry.getValue(), new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1));
|
||||
} catch(IllegalArgumentException ex) {
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalettes in biome " + getFriendlyName() + ", ID: " + biomeID + ". BlockData " + entry.getKey() + " is invalid!");
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for Palettes in biome " + getFriendlyName() + ", ID: " + biomeID + ". BlockData " + entry.getKey() + " is invalid!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
try {
|
||||
paletteMap.put((Integer) entry.getValue(), PaletteConfig.fromID((String) entry.getKey()).getPalette());
|
||||
} catch(NullPointerException ex) {
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalettes in biome " + getFriendlyName() + ", ID: " + biomeID + "\n\nPalette " + entry.getKey() + " cannot be found!");
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for Palettes in biome " + getFriendlyName() + ", ID: " + biomeID + "\n\nPalette " + entry.getKey() + " cannot be found!");
|
||||
}
|
||||
}
|
||||
} catch(ClassCastException ex) {
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalettes in biome " + getFriendlyName() + ", ID: " + biomeID);
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for Palettes in biome " + getFriendlyName() + ", ID: " + biomeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,41 +123,41 @@ public class BiomeConfig extends TerraConfigObject {
|
||||
}
|
||||
} else carvers = new HashMap<>();
|
||||
|
||||
int faunaChance, treeChance, treeDensity;
|
||||
int floraChance, treeChance, treeDensity;
|
||||
|
||||
// Get various simple values using getOrDefault config methods.
|
||||
try {
|
||||
faunaChance = getInt("fauna-chance", Objects.requireNonNull(abstractBiome).getFaunaChance());
|
||||
floraChance = getInt("flora-chance", Objects.requireNonNull(abstractBiome).getFloraChance());
|
||||
treeChance = getInt("tree-chance", Objects.requireNonNull(abstractBiome).getTreeChance());
|
||||
treeDensity = getInt("tree-density", Objects.requireNonNull(abstractBiome).getTreeDensity());
|
||||
eq = getString("noise-equation", Objects.requireNonNull(abstractBiome).getEquation());
|
||||
} catch(NullPointerException e) {
|
||||
faunaChance = getInt("fauna-chance", 0);
|
||||
floraChance = getInt("flora-chance", 0);
|
||||
treeChance = getInt("tree-chance", 0);
|
||||
treeDensity = getInt("tree-density", 0);
|
||||
eq = getString("noise-equation", null);
|
||||
}
|
||||
|
||||
// Check if fauna should be handled by super biome.
|
||||
if(extending && abstractBiome.getFauna() != null && !contains("fauna")) {
|
||||
fauna = abstractBiome.getFauna();
|
||||
Bukkit.getLogger().info("Using super fauna (" + fauna.size() + " entries, " + faunaChance + " % chance)");
|
||||
} else if(contains("fauna")) {
|
||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("fauna")).getValues(false).entrySet()) {
|
||||
// Check if flora should be handled by super biome.
|
||||
if(extending && abstractBiome.getFlora() != null && !contains("flora")) {
|
||||
flora = abstractBiome.getFlora();
|
||||
Bukkit.getLogger().info("Using super flora (" + flora.size() + " entries, " + floraChance + " % chance)");
|
||||
} else if(contains("flora")) {
|
||||
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("flora")).getValues(false).entrySet()) {
|
||||
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());
|
||||
Bukkit.getLogger().info("[Terra] Adding " + e.getKey() + " to biome's flora list with weight " + e.getValue());
|
||||
flora.add(FloraType.valueOf(e.getKey()), (Integer) e.getValue());
|
||||
} catch(IllegalArgumentException ex) {
|
||||
try {
|
||||
Bukkit.getLogger().info("[Terra] Is custom fauna: true");
|
||||
Fauna faunaCustom = FaunaConfig.fromID(e.getKey());
|
||||
fauna.add(faunaCustom, (Integer) e.getValue());
|
||||
Bukkit.getLogger().info("[Terra] Is custom flora: true");
|
||||
Flora floraCustom = FloraConfig.fromID(e.getKey());
|
||||
flora.add(floraCustom, (Integer) e.getValue());
|
||||
} catch(NullPointerException ex2) {
|
||||
throw new IllegalArgumentException("SEVERE configuration error for fauna in biome " + getFriendlyName() + ", ID " + getID() + "\n\nFauna with ID " + e.getKey() + " cannot be found!");
|
||||
throw new IllegalArgumentException("SEVERE configuration error for flora in biome " + getFriendlyName() + ", ID " + getID() + "\n\nFlora with ID " + e.getKey() + " cannot be found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else fauna = new ProbabilityCollection<>();
|
||||
} else flora = new ProbabilityCollection<>();
|
||||
|
||||
if(extending && abstractBiome.getTrees() != null && !contains("trees")) { // Check if trees should be handled by super biome.
|
||||
trees = abstractBiome.getTrees();
|
||||
@@ -178,12 +176,13 @@ public class BiomeConfig extends TerraConfigObject {
|
||||
if(eq == null) throw new InvalidConfigurationException("Noise equation must be specified in biome or super biome.");
|
||||
|
||||
// Create decorator for this config.
|
||||
UserDefinedDecorator dec = new UserDefinedDecorator(fauna, trees, faunaChance, treeChance, treeDensity);
|
||||
UserDefinedDecorator dec = new UserDefinedDecorator(flora, trees, floraChance, treeChance, treeDensity);
|
||||
|
||||
// Get Vanilla biome, throw exception if it is invalid/unspecified.
|
||||
org.bukkit.block.Biome vanillaBiome;
|
||||
try {
|
||||
if(!contains("vanilla")) throw new InvalidConfigurationException("Vanilla Biome unspecified!");
|
||||
this.vanillaBiome = org.bukkit.block.Biome.valueOf(getString("vanilla"));
|
||||
vanillaBiome = org.bukkit.block.Biome.valueOf(getString("vanilla"));
|
||||
} catch(IllegalArgumentException e) {
|
||||
throw new InvalidConfigurationException("Invalid Vanilla biome: " + getString("vanilla"));
|
||||
}
|
||||
@@ -230,10 +229,6 @@ public class BiomeConfig extends TerraConfigObject {
|
||||
return friendlyName;
|
||||
}
|
||||
|
||||
public org.bukkit.block.Biome getVanillaBiome() {
|
||||
return vanillaBiome;
|
||||
}
|
||||
|
||||
public Map<OreConfig, MaxMin> getOres() {
|
||||
return ores;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.dfsek.terra.config.genconfig;
|
||||
|
||||
import com.dfsek.terra.config.ConfigLoader;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import com.dfsek.terra.config.TerraConfigObject;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -8,9 +7,10 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.polydev.gaea.world.Fauna;
|
||||
import org.polydev.gaea.world.palette.BlockPalette;
|
||||
import org.polydev.gaea.world.Flora;
|
||||
import org.polydev.gaea.world.palette.Palette;
|
||||
import org.polydev.gaea.world.palette.RandomPalette;
|
||||
|
||||
import java.io.File;
|
||||
@@ -20,23 +20,23 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class FaunaConfig extends TerraConfigObject implements Fauna {
|
||||
private static final Map<String, FaunaConfig> faunaConfig = new HashMap<>();
|
||||
private BlockPalette faunaPalette;
|
||||
public class FloraConfig extends TerraConfigObject implements Flora {
|
||||
private static final Map<String, FloraConfig> floraConfig = new HashMap<>();
|
||||
private Palette<BlockData> floraPalette;
|
||||
private String id;
|
||||
private String friendlyName;
|
||||
|
||||
List<Material> spawnable;
|
||||
public FaunaConfig(File file) throws IOException, InvalidConfigurationException {
|
||||
public FloraConfig(File file) throws IOException, InvalidConfigurationException {
|
||||
super(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws InvalidConfigurationException {
|
||||
if(!contains("blocks")) throw new InvalidConfigurationException("No blocks defined in custom fauna!");
|
||||
if(!contains("id")) throw new InvalidConfigurationException("Fauna ID unspecified!");
|
||||
if(!contains("name")) throw new InvalidConfigurationException("Fauna name unspecified!");
|
||||
if(!contains("spawnable")) throw new InvalidConfigurationException("Fauna spawnable blocks unspecified!");
|
||||
if(!contains("blocks")) throw new InvalidConfigurationException("No blocks defined in custom flora!");
|
||||
if(!contains("id")) throw new InvalidConfigurationException("Flora ID unspecified!");
|
||||
if(!contains("name")) throw new InvalidConfigurationException("Flora name unspecified!");
|
||||
if(!contains("spawnable")) throw new InvalidConfigurationException("Flora spawnable blocks unspecified!");
|
||||
|
||||
try {
|
||||
spawnable = ConfigUtil.getElements(getStringList("spawnable"), Material.class);
|
||||
@@ -45,14 +45,14 @@ public class FaunaConfig extends TerraConfigObject implements Fauna {
|
||||
throw new InvalidConfigurationException("Invalid material ID in spawnable list: " + e.getMessage());
|
||||
}
|
||||
|
||||
BlockPalette p = new RandomPalette(new Random(getInt("seed", 4)));
|
||||
Palette<BlockData> p = new RandomPalette<>(new Random(getInt("seed", 4)));
|
||||
|
||||
faunaPalette = PaletteConfig.getPalette(getMapList("blocks"), p);
|
||||
if(!contains("id")) throw new InvalidConfigurationException("Fauna ID unspecified!");
|
||||
floraPalette = PaletteConfig.getPalette(getMapList("blocks"), p);
|
||||
if(!contains("id")) throw new InvalidConfigurationException("Flora ID unspecified!");
|
||||
this.id = getString("id");
|
||||
if(!contains("name")) throw new InvalidConfigurationException("Fauna Name unspecified!");
|
||||
if(!contains("name")) throw new InvalidConfigurationException("Flora Name unspecified!");
|
||||
this.friendlyName = getString("name");
|
||||
faunaConfig.put(id, this);
|
||||
floraConfig.put(id, this);
|
||||
}
|
||||
|
||||
public String getFriendlyName() {
|
||||
@@ -73,22 +73,22 @@ public class FaunaConfig extends TerraConfigObject implements Fauna {
|
||||
|
||||
@Override
|
||||
public boolean plant(Location location) {
|
||||
int size = faunaPalette.getSize();
|
||||
int size = floraPalette.getSize();
|
||||
for(int i = 0; i < size; i++) {
|
||||
if(!location.clone().add(0, i+1, 0).getBlock().isEmpty()) return false;
|
||||
}
|
||||
for(int i = 0; i < size; i++) {
|
||||
location.clone().add(0, i+1, 0).getBlock().setBlockData(faunaPalette.getBlockData(size-(i+1), location.getBlockX(), location.getBlockZ()), false);
|
||||
location.clone().add(0, i+1, 0).getBlock().setBlockData(floraPalette.get(size-(i+1), location.getBlockX(), location.getBlockZ()), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Fauna with name " + getFriendlyName() + ", ID " + getID();
|
||||
return "Flora with name " + getFriendlyName() + ", ID " + getID();
|
||||
}
|
||||
|
||||
public static FaunaConfig fromID(String id) {
|
||||
return faunaConfig.get(id);
|
||||
public static FloraConfig fromID(String id) {
|
||||
return floraConfig.get(id);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.polydev.gaea.math.FastNoise;
|
||||
import org.polydev.gaea.math.ProbabilityCollection;
|
||||
import org.polydev.gaea.world.palette.BlockPalette;
|
||||
import org.polydev.gaea.world.palette.Palette;
|
||||
import org.polydev.gaea.world.palette.RandomPalette;
|
||||
import org.polydev.gaea.world.palette.SimplexPalette;
|
||||
|
||||
@@ -21,27 +21,26 @@ import java.util.Random;
|
||||
|
||||
public class PaletteConfig extends TerraConfigObject {
|
||||
private static final Map<String, PaletteConfig> palettes = new HashMap<>();
|
||||
private BlockPalette palette;
|
||||
private Palette<BlockData> palette;
|
||||
private String paletteID;
|
||||
private boolean isEnabled = false;
|
||||
private String friendlyName;
|
||||
private boolean useNoise = false;
|
||||
private float nFreq;
|
||||
public PaletteConfig(File file) throws IOException, InvalidConfigurationException {
|
||||
super(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws InvalidConfigurationException {
|
||||
BlockPalette pal;
|
||||
Palette<BlockData> pal;
|
||||
if(getBoolean("simplex", false)) {
|
||||
useNoise = true;
|
||||
FastNoise pNoise = new FastNoise(getInt("seed", 3));
|
||||
pNoise.setNoiseType(FastNoise.NoiseType.SimplexFractal);
|
||||
pNoise.setFractalOctaves(4);
|
||||
pNoise.setFrequency((float) getDouble("frequency", 0.02));
|
||||
pal = new SimplexPalette(pNoise);
|
||||
} else pal = new RandomPalette(new Random(getInt("seed", 3)));
|
||||
pal = new SimplexPalette<>(pNoise);
|
||||
} else pal = new RandomPalette<>(new Random(getInt("seed", 3)));
|
||||
palette = getPalette(getMapList("blocks"), pal);
|
||||
if(!contains("id")) throw new InvalidConfigurationException("Grid ID unspecified!");
|
||||
this.paletteID = getString("id");
|
||||
@@ -51,7 +50,7 @@ public class PaletteConfig extends TerraConfigObject {
|
||||
palettes.put(paletteID, this);
|
||||
}
|
||||
|
||||
public BlockPalette getPalette() {
|
||||
public Palette<BlockData> getPalette() {
|
||||
return palette;
|
||||
}
|
||||
|
||||
@@ -67,7 +66,7 @@ public class PaletteConfig extends TerraConfigObject {
|
||||
return paletteID;
|
||||
}
|
||||
|
||||
protected static BlockPalette getPalette(List<Map<?, ?>> maps, BlockPalette p) throws InvalidConfigurationException {
|
||||
protected static Palette<BlockData> getPalette(List<Map<?, ?>> maps, Palette<BlockData> p) throws InvalidConfigurationException {
|
||||
for(Map<?, ?> m : maps) {
|
||||
try {
|
||||
ProbabilityCollection<BlockData> layer = new ProbabilityCollection<>();
|
||||
@@ -76,9 +75,9 @@ public class PaletteConfig extends TerraConfigObject {
|
||||
layer.add(Bukkit.createBlockData((String) type.getKey()), (Integer) type.getValue());
|
||||
}
|
||||
}
|
||||
p.addBlockData(layer, (Integer) m.get("layers"));
|
||||
p.add(layer, (Integer) m.get("layers"));
|
||||
} catch(ClassCastException e) {
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for BlockPalette: \n\n" + e.getMessage());
|
||||
throw new InvalidConfigurationException("SEVERE configuration error for Palette: \n\n" + e.getMessage());
|
||||
}
|
||||
}
|
||||
return p;
|
||||
@@ -86,7 +85,7 @@ public class PaletteConfig extends TerraConfigObject {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BlockPalette with name: " + getFriendlyName() + ", ID " + getID() + " with " + getPalette().getSize() + " layers, using Simplex: " + useNoise;
|
||||
return "Palette with name: " + getFriendlyName() + ", ID " + getID() + " with " + getPalette().getSize() + " layers, using Simplex: " + useNoise;
|
||||
}
|
||||
|
||||
public static PaletteConfig fromID(String id) {
|
||||
|
||||
@@ -9,26 +9,26 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.biome.Biome;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
import org.polydev.gaea.profiler.ProfileFuture;
|
||||
import org.polydev.gaea.world.Fauna;
|
||||
import org.polydev.gaea.world.Flora;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class FaunaPopulator extends GaeaBlockPopulator {
|
||||
public class FloraPopulator extends GaeaBlockPopulator {
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
ProfileFuture fauna = TerraProfiler.fromWorld(world).measure("FaunaTime");
|
||||
ProfileFuture flora = TerraProfiler.fromWorld(world).measure("FloraTime");
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
Biome biome = TerraBiomeGrid.fromWorld(world).getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z);
|
||||
if(biome.getDecorator().getFaunaChance() <= 0 || random.nextInt(100) > biome.getDecorator().getFaunaChance())
|
||||
if(biome.getDecorator().getFloraChance() <= 0 || random.nextInt(100) > biome.getDecorator().getFloraChance())
|
||||
continue;
|
||||
try {
|
||||
Fauna item = biome.getDecorator().getFauna().get(random);
|
||||
Flora item = biome.getDecorator().getFlora().get(random);
|
||||
Block highest = item.getHighestValidSpawnAt(chunk, x, z);
|
||||
if(highest != null) item.plant(highest.getLocation());
|
||||
} catch(NullPointerException ignored) {}
|
||||
}
|
||||
}
|
||||
if(fauna!=null) fauna.complete();
|
||||
if(flora!=null) flora.complete();
|
||||
}
|
||||
}
|
||||
6
test.sh
6
test.sh
@@ -19,9 +19,9 @@ colorend() {
|
||||
if [ ! -d "$DIRECTORY/server" ]; then
|
||||
echo "$DIRECTORY/server not found. Cloning now."
|
||||
git clone $REPO $DIRECTORY/server
|
||||
sed -i "s/\${gen}/$NAME/g" $DIRECTORY/server/bukkit.yml
|
||||
sed -i "s/\${world}/$WORLD/g" $DIRECTORY/server/bukkit.yml
|
||||
fi
|
||||
sed -i "s/\${gen}/$NAME/g" $DIRECTORY/server/bukkit.yml
|
||||
sed -i "s/\${world}/$WORLD/g" $DIRECTORY/server/bukkit.yml
|
||||
cp $DIRECTORY/prod/$PROJECT.jar $DIRECTORY/server/plugins/$PROJECT.jar
|
||||
cd $DIRECTORY/server || exit
|
||||
if ! test -f "paperclip.jar"; then
|
||||
@@ -40,8 +40,6 @@ if [ -z "$(grep true eula.txt 2>/dev/null)" ]; then
|
||||
echo "eula=true" > eula.txt
|
||||
fi
|
||||
|
||||
|
||||
|
||||
java -Xms5G -Xmx5G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC \
|
||||
-XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 \
|
||||
-XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 \
|
||||
|
||||
Reference in New Issue
Block a user