diff --git a/pom.xml b/pom.xml index 5d075155d..adf80f72f 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.polydev gaea - 1.9.6 + 1.10.0 javax.vecmath diff --git a/src/main/java/com/dfsek/terra/TerraChunkGenerator.java b/src/main/java/com/dfsek/terra/TerraChunkGenerator.java index 9464d0d3a..21a785898 100644 --- a/src/main/java/com/dfsek/terra/TerraChunkGenerator.java +++ b/src/main/java/com/dfsek/terra/TerraChunkGenerator.java @@ -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); } } } diff --git a/src/main/java/com/dfsek/terra/TerraProfiler.java b/src/main/java/com/dfsek/terra/TerraProfiler.java index 416033578..242fd0fe8 100644 --- a/src/main/java/com/dfsek/terra/TerraProfiler.java +++ b/src/main/java/com/dfsek/terra/TerraProfiler.java @@ -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); diff --git a/src/main/java/com/dfsek/terra/biome/TerraBiomeGrid.java b/src/main/java/com/dfsek/terra/biome/TerraBiomeGrid.java index 3894dddee..3bd120459 100644 --- a/src/main/java/com/dfsek/terra/biome/TerraBiomeGrid.java +++ b/src/main/java/com/dfsek/terra/biome/TerraBiomeGrid.java @@ -16,12 +16,14 @@ public class TerraBiomeGrid extends BiomeGrid { private static final Map 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."); diff --git a/src/main/java/com/dfsek/terra/biome/UserDefinedBiome.java b/src/main/java/com/dfsek/terra/biome/UserDefinedBiome.java index d4cd4f32f..391b332f6 100644 --- a/src/main/java/com/dfsek/terra/biome/UserDefinedBiome.java +++ b/src/main/java/com/dfsek/terra/biome/UserDefinedBiome.java @@ -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; } diff --git a/src/main/java/com/dfsek/terra/biome/UserDefinedDecorator.java b/src/main/java/com/dfsek/terra/biome/UserDefinedDecorator.java index 0c56261c6..17457a061 100644 --- a/src/main/java/com/dfsek/terra/biome/UserDefinedDecorator.java +++ b/src/main/java/com/dfsek/terra/biome/UserDefinedDecorator.java @@ -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; + private final ProbabilityCollection flora; private final ProbabilityCollection trees; - private final int faunaChance; + private final int floraChance; private final int treeChance; private final int treeDensity; - public UserDefinedDecorator(ProbabilityCollection fauna, ProbabilityCollection trees, int faunaChance, int treeChance, int treeDensity) { - this.fauna = fauna; + public UserDefinedDecorator(ProbabilityCollection flora, ProbabilityCollection 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 getFauna() { - return fauna; + public ProbabilityCollection getFlora() { + return flora; } @Override - public int getFaunaChance() { - return faunaChance; + public int getFloraChance() { + return floraChance; } } diff --git a/src/main/java/com/dfsek/terra/biome/UserDefinedGenerator.java b/src/main/java/com/dfsek/terra/biome/UserDefinedGenerator.java index b8f6cbc2e..0003c6e43 100644 --- a/src/main/java/com/dfsek/terra/biome/UserDefinedGenerator.java +++ b/src/main/java/com/dfsek/terra/biome/UserDefinedGenerator.java @@ -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 paletteMap; + private final TreeMap> 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 v, TreeMap pa) throws ParseException { + public UserDefinedGenerator(String e, List v, TreeMap> 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 e : paletteMap.entrySet()) { + public Palette getPalette(int y) { + for(Map.Entry> e : paletteMap.entrySet()) { if(e.getKey() >= y ) return e.getValue(); } return null; diff --git a/src/main/java/com/dfsek/terra/config/ConfigUtil.java b/src/main/java/com/dfsek/terra/config/ConfigUtil.java index 924e4898a..a8957e66f 100644 --- a/src/main/java/com/dfsek/terra/config/ConfigUtil.java +++ b/src/main/java/com/dfsek/terra/config/ConfigUtil.java @@ -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); diff --git a/src/main/java/com/dfsek/terra/config/genconfig/AbstractBiomeConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/AbstractBiomeConfig.java index 6231a702c..0d657e8fe 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/AbstractBiomeConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/AbstractBiomeConfig.java @@ -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 ores; private Map oreHeights; private Map carvers; - private ProbabilityCollection fauna; + private ProbabilityCollection flora; private ProbabilityCollection trees; - private int faunaChance; + private int floraChance; private int treeChance; private int treeDensity; private String equation; - private TreeMap paletteMap; + private TreeMap> 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().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1)); + paletteMap.put((Integer) entry.getValue(), new RandomPalette(new Random(0)).add(new ProbabilityCollection().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 e : Objects.requireNonNull(getConfigurationSection("fauna")).getValues(false).entrySet()) { + if(contains("flora")) { + flora = new ProbabilityCollection<>(); + for(Map.Entry 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 getFauna() { - return fauna; + public ProbabilityCollection getFlora() { + return flora; } public ProbabilityCollection getTrees() { @@ -178,7 +179,7 @@ public class AbstractBiomeConfig extends TerraConfigObject { return equation; } - public TreeMap getPaletteMap() { + public TreeMap> getPaletteMap() { return paletteMap; } diff --git a/src/main/java/com/dfsek/terra/config/genconfig/BiomeConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/BiomeConfig.java index 3489ba401..c7882b8e6 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/BiomeConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/BiomeConfig.java @@ -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 ores; private Map oreHeights; private Map carvers; @@ -51,7 +49,7 @@ public class BiomeConfig extends TerraConfigObject { public void init() throws InvalidConfigurationException { oreHeights = new HashMap<>(); ores = new HashMap<>(); - ProbabilityCollection fauna = new ProbabilityCollection<>(); + ProbabilityCollection flora = new ProbabilityCollection<>(); ProbabilityCollection 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 paletteMap; + TreeMap> 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().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1)); + paletteMap.put((Integer) entry.getValue(), new RandomPalette(new Random(0)).add(new ProbabilityCollection().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 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 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 getOres() { return ores; } diff --git a/src/main/java/com/dfsek/terra/config/genconfig/FaunaConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java similarity index 70% rename from src/main/java/com/dfsek/terra/config/genconfig/FaunaConfig.java rename to src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java index 5bee7456c..0ac2e3486 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/FaunaConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java @@ -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 faunaConfig = new HashMap<>(); - private BlockPalette faunaPalette; +public class FloraConfig extends TerraConfigObject implements Flora { + private static final Map floraConfig = new HashMap<>(); + private Palette floraPalette; private String id; private String friendlyName; List 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 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); } } diff --git a/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java index d22fcfd0e..e764ffad5 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java @@ -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 palettes = new HashMap<>(); - private BlockPalette palette; + private Palette 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 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 getPalette() { return palette; } @@ -67,7 +66,7 @@ public class PaletteConfig extends TerraConfigObject { return paletteID; } - protected static BlockPalette getPalette(List> maps, BlockPalette p) throws InvalidConfigurationException { + protected static Palette getPalette(List> maps, Palette p) throws InvalidConfigurationException { for(Map m : maps) { try { ProbabilityCollection 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) { diff --git a/src/main/java/com/dfsek/terra/population/FaunaPopulator.java b/src/main/java/com/dfsek/terra/population/FloraPopulator.java similarity index 71% rename from src/main/java/com/dfsek/terra/population/FaunaPopulator.java rename to src/main/java/com/dfsek/terra/population/FloraPopulator.java index 53bc71ac7..d16d235a0 100644 --- a/src/main/java/com/dfsek/terra/population/FaunaPopulator.java +++ b/src/main/java/com/dfsek/terra/population/FloraPopulator.java @@ -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(); } } diff --git a/test.sh b/test.sh index df721e315..343b0b01f 100755 --- a/test.sh +++ b/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 \