mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-27 22:40:23 +00:00
Clean up imports
This commit is contained in:
1 parent
f198b371e0
commit
224dfbe638
86 files changed
+407
-211
No files matched your search
@@ -13,6 +13,7 @@ public class Debug {
|
|||||||
public static void info(String message) {
|
public static void info(String message) {
|
||||||
if(ConfigUtil.debug) main.getLogger().info(message);
|
if(ConfigUtil.debug) main.getLogger().info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warn(String message) {
|
public static void warn(String message) {
|
||||||
if(ConfigUtil.debug) main.getLogger().warning(message);
|
if(ConfigUtil.debug) main.getLogger().warning(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public class EventListener implements Listener {
|
|||||||
public EventListener(GaeaPlugin main) {
|
public EventListener(GaeaPlugin main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEnderEye(EntitySpawnEvent e) {
|
public void onEnderEye(EntitySpawnEvent e) {
|
||||||
Entity entity = e.getEntity();
|
Entity entity = e.getEntity();
|
||||||
@@ -36,14 +37,18 @@ public class EventListener implements Listener {
|
|||||||
Debug.info("Location: " + location);
|
Debug.info("Location: " + location);
|
||||||
});
|
});
|
||||||
finder.run(); // Do this synchronously so eye doesn't change direction several ticks after spawning.
|
finder.run(); // Do this synchronously so eye doesn't change direction several ticks after spawning.
|
||||||
} else main.getLogger().warning("No overrides are defined for Strongholds. Ender Signals will not work correctly.");
|
} else
|
||||||
|
main.getLogger().warning("No overrides are defined for Strongholds. Ender Signals will not work correctly.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCartographerChange(VillagerAcquireTradeEvent e) {
|
public void onCartographerChange(VillagerAcquireTradeEvent e) {
|
||||||
if(! (e.getEntity() instanceof Villager)) return;
|
if(! (e.getEntity() instanceof Villager)) return;
|
||||||
if(((Villager) e.getEntity()).getProfession().equals(Villager.Profession.CARTOGRAPHER)) e.setCancelled(true); // Cancel leveling if the villager is a Cartographer, to prevent crashing server.
|
if(((Villager) e.getEntity()).getProfession().equals(Villager.Profession.CARTOGRAPHER))
|
||||||
|
e.setCancelled(true); // Cancel leveling if the villager is a Cartographer, to prevent crashing server.
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCartographerLevel(VillagerCareerChangeEvent e) {
|
public void onCartographerLevel(VillagerCareerChangeEvent e) {
|
||||||
if(e.getProfession().equals(Villager.Profession.CARTOGRAPHER)) {
|
if(e.getProfession().equals(Villager.Profession.CARTOGRAPHER)) {
|
||||||
|
|||||||
@@ -8,10 +8,8 @@ import com.dfsek.terra.generation.TerraChunkGenerator;
|
|||||||
import com.dfsek.terra.util.PaperUtil;
|
import com.dfsek.terra.util.PaperUtil;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.polydev.gaea.GaeaPlugin;
|
import org.polydev.gaea.GaeaPlugin;
|
||||||
@@ -19,10 +17,8 @@ import org.polydev.gaea.generation.GaeaChunkGenerator;
|
|||||||
import org.polydev.gaea.lang.Language;
|
import org.polydev.gaea.lang.Language;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class Terra extends GaeaPlugin {
|
public class Terra extends GaeaPlugin {
|
||||||
private static Terra instance;
|
private static Terra instance;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class TerraProfiler extends WorldProfiler {
|
public class TerraProfiler extends WorldProfiler {
|
||||||
private static final Map<World, TerraProfiler> profilerMap = new HashMap<>();
|
private static final Map<World, TerraProfiler> profilerMap = new HashMap<>();
|
||||||
|
|
||||||
public TerraProfiler(World w) {
|
public TerraProfiler(World w) {
|
||||||
super(w);
|
super(w);
|
||||||
this
|
this
|
||||||
@@ -23,6 +24,7 @@ public class TerraProfiler extends WorldProfiler {
|
|||||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveBlockUpdate");
|
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveBlockUpdate");
|
||||||
profilerMap.put(w, this);
|
profilerMap.put(w, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TerraProfiler fromWorld(World w) {
|
public static TerraProfiler fromWorld(World w) {
|
||||||
if(w.getGenerator() instanceof TerraChunkGenerator) {
|
if(w.getGenerator() instanceof TerraChunkGenerator) {
|
||||||
if(profilerMap.containsKey(w)) return profilerMap.get(w);
|
if(profilerMap.containsKey(w)) return profilerMap.get(w);
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import com.dfsek.terra.biome.TerraBiomeGrid;
|
|||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.biome.UserDefinedGrid;
|
import com.dfsek.terra.biome.UserDefinedGrid;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
import com.dfsek.terra.config.base.WorldConfig;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ public class AsyncBiomeFinder implements Runnable {
|
|||||||
int z = centerZ;
|
int z = centerZ;
|
||||||
int run = 1;
|
int run = 1;
|
||||||
boolean toggle = true;
|
boolean toggle = true;
|
||||||
main: for(int i = startRadius; i < maxRadius; i++) {
|
main:
|
||||||
|
for(int i = startRadius; i < maxRadius; i++) {
|
||||||
for(int j = 0; j < run; j++) {
|
for(int j = 0; j < run; j++) {
|
||||||
if(checkBiome(x, z).equals(target)) break main;
|
if(checkBiome(x, z).equals(target)) break main;
|
||||||
if(toggle) x++;
|
if(toggle) x++;
|
||||||
@@ -67,6 +68,7 @@ public class AsyncBiomeFinder implements Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to get biome at location
|
* Helper method to get biome at location
|
||||||
|
*
|
||||||
* @param x X coordinate
|
* @param x X coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
* @return Biome at coordinates
|
* @return Biome at coordinates
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.dfsek.terra.structure.Structure;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@@ -54,7 +53,8 @@ public class AsyncStructureFinder implements Runnable {
|
|||||||
boolean toggle = true;
|
boolean toggle = true;
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
Vector spawn = null;
|
Vector spawn = null;
|
||||||
main: for(int i = startRadius; i < maxRadius; i++) {
|
main:
|
||||||
|
for(int i = startRadius; i < maxRadius; i++) {
|
||||||
for(int j = 0; j < run; j++) {
|
for(int j = 0; j < run; j++) {
|
||||||
spawn = target.getSpawn().getChunkSpawn(x, z, seed);
|
spawn = target.getSpawn().getChunkSpawn(x, z, seed);
|
||||||
if(isValidSpawn(spawn.getBlockX(), spawn.getBlockZ())) {
|
if(isValidSpawn(spawn.getBlockX(), spawn.getBlockZ())) {
|
||||||
@@ -82,13 +82,15 @@ public class AsyncStructureFinder implements Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if coordinate pair is a valid structure spawn
|
* Check if coordinate pair is a valid structure spawn
|
||||||
|
*
|
||||||
* @param x X coordinate
|
* @param x X coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
* @return Whether location is a valid spawn for StructureConfig
|
* @return Whether location is a valid spawn for StructureConfig
|
||||||
*/
|
*/
|
||||||
private boolean isValidSpawn(int x, int z) {
|
private boolean isValidSpawn(int x, int z) {
|
||||||
Location spawn = target.getSpawn().getNearestSpawn(x, z, world.getSeed()).toLocation(world);
|
Location spawn = target.getSpawn().getNearestSpawn(x, z, world.getSeed()).toLocation(world);
|
||||||
if(! TerraWorld.getWorld(world).getConfig().getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(target)) return false;
|
if(! TerraWorld.getWorld(world).getConfig().getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(target))
|
||||||
|
return false;
|
||||||
Random r2 = new Random(spawn.hashCode());
|
Random r2 = new Random(spawn.hashCode());
|
||||||
Structure struc = target.getStructure(r2);
|
Structure struc = target.getStructure(r2);
|
||||||
Structure.Rotation rotation = Structure.Rotation.fromDegrees(r2.nextInt(4) * 90);
|
Structure.Rotation rotation = Structure.Rotation.fromDegrees(r2.nextInt(4) * 90);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public class BiomeZone {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get BiomeGrid at location
|
* Get BiomeGrid at location
|
||||||
|
*
|
||||||
* @param x X coordinate
|
* @param x X coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
* @return BiomeGrid at coordinates.
|
* @return BiomeGrid at coordinates.
|
||||||
@@ -45,6 +46,7 @@ public class BiomeZone {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of BiomeGrids this BiomeZone holds.
|
* Get the number of BiomeGrids this BiomeZone holds.
|
||||||
|
*
|
||||||
* @return Number of grids
|
* @return Number of grids
|
||||||
*/
|
*/
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
@@ -53,6 +55,7 @@ public class BiomeZone {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the normalized grid noise at location
|
* Get the normalized grid noise at location
|
||||||
|
*
|
||||||
* @param x X coordinate
|
* @param x X coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
* @return Normalized noise at coordinates
|
* @return Normalized noise at coordinates
|
||||||
@@ -63,6 +66,7 @@ public class BiomeZone {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get raw grid noise at location
|
* Get raw grid noise at location
|
||||||
|
*
|
||||||
* @param x X coordinate
|
* @param x X coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
* @return Raw noise at coordinates
|
* @return Raw noise at coordinates
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class CoordinatePerturb {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a CoordinatePerturb object with a given frequency, amplitude, and seed.
|
* Create a CoordinatePerturb object with a given frequency, amplitude, and seed.
|
||||||
|
*
|
||||||
* @param frequency Noise frequency
|
* @param frequency Noise frequency
|
||||||
* @param amplitude Offset amplitude
|
* @param amplitude Offset amplitude
|
||||||
* @param seed Noise seed
|
* @param seed Noise seed
|
||||||
@@ -29,6 +30,7 @@ public class CoordinatePerturb {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset a coordinate pair
|
* Offset a coordinate pair
|
||||||
|
*
|
||||||
* @param x X coordinate
|
* @param x X coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
* @return Vector2 containing offset coordinates
|
* @return Vector2 containing offset coordinates
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.polydev.gaea.math.FastNoiseLite;
|
|||||||
public class ErosionNoise {
|
public class ErosionNoise {
|
||||||
private final double thresh;
|
private final double thresh;
|
||||||
private final FastNoiseLite noise;
|
private final FastNoiseLite noise;
|
||||||
|
|
||||||
public ErosionNoise(float freq1, double thresh, int octaves, long seed) {
|
public ErosionNoise(float freq1, double thresh, int octaves, long seed) {
|
||||||
FastNoiseLite main = new FastNoiseLite((int) (seed + 1));
|
FastNoiseLite main = new FastNoiseLite((int) (seed + 1));
|
||||||
main.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
main.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
||||||
@@ -20,6 +21,7 @@ public class ErosionNoise {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether a location is eroded
|
* Get whether a location is eroded
|
||||||
|
*
|
||||||
* @param x X coordinate
|
* @param x X coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
* @return Whether location is eroded
|
* @return Whether location is eroded
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ public class TerraBiomeGrid extends BiomeGrid {
|
|||||||
b = (UserDefinedBiome) zone.getGrid(xp, zp).getBiome(xp, zp, phase);
|
b = (UserDefinedBiome) zone.getGrid(xp, zp).getBiome(xp, zp, phase);
|
||||||
} catch(NullPointerException e) {
|
} catch(NullPointerException e) {
|
||||||
if(ConfigUtil.debug) e.printStackTrace();
|
if(ConfigUtil.debug) e.printStackTrace();
|
||||||
if(failNum % 256 == 0) LangUtil.log("error.severe-config", Level.SEVERE, String.valueOf(x), String.valueOf(z));
|
if(failNum % 256 == 0)
|
||||||
|
LangUtil.log("error.severe-config", Level.SEVERE, String.valueOf(x), String.valueOf(z));
|
||||||
failNum++;
|
failNum++;
|
||||||
return ConfigUtil.failType.fail();
|
return ConfigUtil.failType.fail();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.dfsek.terra.biome;
|
|||||||
import com.dfsek.terra.generation.UserDefinedDecorator;
|
import com.dfsek.terra.generation.UserDefinedDecorator;
|
||||||
import com.dfsek.terra.generation.UserDefinedGenerator;
|
import com.dfsek.terra.generation.UserDefinedGenerator;
|
||||||
import org.polydev.gaea.biome.Biome;
|
import org.polydev.gaea.biome.Biome;
|
||||||
import org.polydev.gaea.biome.Generator;
|
|
||||||
import org.polydev.gaea.biome.Decorator;
|
import org.polydev.gaea.biome.Decorator;
|
||||||
|
import org.polydev.gaea.biome.Generator;
|
||||||
import org.polydev.gaea.structures.features.Feature;
|
import org.polydev.gaea.structures.features.Feature;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class UserDefinedGrid extends BiomeGrid {
|
|||||||
private final boolean fromImage;
|
private final boolean fromImage;
|
||||||
private final ImageLoader.Channel channelX;
|
private final ImageLoader.Channel channelX;
|
||||||
private final ImageLoader.Channel channelZ;
|
private final ImageLoader.Channel channelZ;
|
||||||
|
|
||||||
public UserDefinedGrid(World w, float freq1, float freq2, UserDefinedBiome[][] b, WorldConfig c) {
|
public UserDefinedGrid(World w, float freq1, float freq2, UserDefinedBiome[][] b, WorldConfig c) {
|
||||||
super(w, freq1, freq2, b.length, b[0].length);
|
super(w, freq1, freq2, b.length, b[0].length);
|
||||||
super.setGrid(b);
|
super.setGrid(b);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public enum FailType {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the action specified by the enum type to occur on failure of terrain generation.
|
* Performs the action specified by the enum type to occur on failure of terrain generation.
|
||||||
|
*
|
||||||
* @return Failover biome, if specified, null if not.
|
* @return Failover biome, if specified, null if not.
|
||||||
*/
|
*/
|
||||||
public abstract Biome fail();
|
public abstract Biome fail();
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package com.dfsek.terra.biome.failsafe;
|
|||||||
|
|
||||||
import com.dfsek.terra.generation.UserDefinedDecorator;
|
import com.dfsek.terra.generation.UserDefinedDecorator;
|
||||||
import org.polydev.gaea.math.ProbabilityCollection;
|
import org.polydev.gaea.math.ProbabilityCollection;
|
||||||
import org.polydev.gaea.tree.Tree;
|
|
||||||
import org.polydev.gaea.world.Flora;
|
|
||||||
|
|
||||||
public final class FailoverDecorator extends UserDefinedDecorator {
|
public final class FailoverDecorator extends UserDefinedDecorator {
|
||||||
public FailoverDecorator() {
|
public FailoverDecorator() {
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
public final class FailoverGenerator extends UserDefinedGenerator {
|
public final class FailoverGenerator extends UserDefinedGenerator {
|
||||||
private static final TreeMap<Integer, Palette<BlockData>> palette = new TreeMap<>();
|
private static final TreeMap<Integer, Palette<BlockData>> palette = new TreeMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
palette.put(255, new RandomPalette<BlockData>(new Random(2403)).add(Material.STONE.createBlockData(), 1));
|
palette.put(255, new RandomPalette<BlockData>(new Random(2403)).add(Material.STONE.createBlockData(), 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FailoverGenerator() throws ParseException {
|
public FailoverGenerator() throws ParseException {
|
||||||
super("0", Collections.emptyList(), palette, false);
|
super("0", Collections.emptyList(), palette, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,17 +9,18 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.polydev.gaea.math.FastNoiseLite;
|
import org.polydev.gaea.math.FastNoiseLite;
|
||||||
import org.polydev.gaea.math.MathUtil;
|
import org.polydev.gaea.math.MathUtil;
|
||||||
import org.polydev.gaea.world.carving.CarvingData;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class Cavern {
|
public class Cavern {
|
||||||
private final Node node;
|
private final Node node;
|
||||||
private final long seed;
|
private final long seed;
|
||||||
|
|
||||||
public Cavern(World w) {
|
public Cavern(World w) {
|
||||||
this.node = new Node(w);
|
this.node = new Node(w);
|
||||||
this.seed = w.getSeed();
|
this.seed = w.getSeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public VoxelGeometry carveChunk(int chunkX, int chunkZ) {
|
public VoxelGeometry carveChunk(int chunkX, int chunkZ) {
|
||||||
long seedC = MathUtil.getCarverChunkSeed(chunkX, chunkZ, seed);
|
long seedC = MathUtil.getCarverChunkSeed(chunkX, chunkZ, seed);
|
||||||
Random chunk = new Random(seedC);
|
Random chunk = new Random(seedC);
|
||||||
@@ -37,12 +38,15 @@ public class Cavern {
|
|||||||
carve.merge(new Tube(org, _00, 4));
|
carve.merge(new Tube(org, _00, 4));
|
||||||
return carve;
|
return carve;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Node {
|
public static class Node {
|
||||||
private final long seed;
|
private final long seed;
|
||||||
private final GridSpawn spawn = new GridSpawn(16, 0);
|
private final GridSpawn spawn = new GridSpawn(16, 0);
|
||||||
|
|
||||||
public Node(World w) {
|
public Node(World w) {
|
||||||
this.seed = w.getSeed();
|
this.seed = w.getSeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getNodeLocation(int x, int z) {
|
public Vector getNodeLocation(int x, int z) {
|
||||||
return spawn.getNearestSpawn(x, z, seed);
|
return spawn.getNearestSpawn(x, z, seed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class SimplexCarver extends Carver {
|
|||||||
private final FastNoiseLite column;
|
private final FastNoiseLite column;
|
||||||
private final FastNoiseLite hasCaves;
|
private final FastNoiseLite hasCaves;
|
||||||
private final double root2inverse = 1D / Math.sqrt(2);
|
private final double root2inverse = 1D / Math.sqrt(2);
|
||||||
|
|
||||||
public SimplexCarver(int minY, int maxY) {
|
public SimplexCarver(int minY, int maxY) {
|
||||||
super(minY, maxY);
|
super(minY, maxY);
|
||||||
noise = new FastNoiseLite(2403);
|
noise = new FastNoiseLite(2403);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.dfsek.terra.carving;
|
package com.dfsek.terra.carving;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
|
||||||
import org.polydev.gaea.math.Range;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
|
import org.polydev.gaea.math.Range;
|
||||||
import org.polydev.gaea.world.carving.Carver;
|
import org.polydev.gaea.world.carving.Carver;
|
||||||
import org.polydev.gaea.world.carving.Worm;
|
import org.polydev.gaea.world.carving.Worm;
|
||||||
|
|
||||||
@@ -50,6 +50,7 @@ public class UserDefinedCarver extends Carver {
|
|||||||
private final Vector direction;
|
private final Vector direction;
|
||||||
private final int maxRad;
|
private final int maxRad;
|
||||||
private double runningRadius;
|
private double runningRadius;
|
||||||
|
|
||||||
public UserDefinedWorm(int length, Random r, Vector origin, int maxRad, int topCut, int bottomCut) {
|
public UserDefinedWorm(int length, Random r, Vector origin, int maxRad, int topCut, int bottomCut) {
|
||||||
super(length, r, origin);
|
super(length, r, origin);
|
||||||
super.setTopCut(topCut);
|
super.setTopCut(topCut);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.dfsek.terra.command;
|
|||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
|||||||
@@ -104,9 +104,11 @@ public class BiomeInfoCommand extends WorldCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
||||||
if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator)) return Collections.emptyList();
|
if(! (sender instanceof Player) || ! (((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
|
||||||
|
return Collections.emptyList();
|
||||||
List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
|
List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
|
||||||
if(args.length == 1) return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
|
if(args.length == 1)
|
||||||
|
return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,10 +20,12 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class BiomeLocateCommand extends WorldCommand {
|
public class BiomeLocateCommand extends WorldCommand {
|
||||||
private final boolean tp;
|
private final boolean tp;
|
||||||
|
|
||||||
public BiomeLocateCommand(org.polydev.gaea.command.Command parent, boolean teleport) {
|
public BiomeLocateCommand(org.polydev.gaea.command.Command parent, boolean teleport) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.tp = teleport;
|
this.tp = teleport;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||||
String id = args[0];
|
String id = args[0];
|
||||||
@@ -62,9 +64,11 @@ public class BiomeLocateCommand extends WorldCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
||||||
if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator)) return Collections.emptyList();
|
if(! (sender instanceof Player) || ! (((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
|
||||||
|
return Collections.emptyList();
|
||||||
List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
|
List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
|
||||||
if(args.length == 1) return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
|
if(args.length == 1)
|
||||||
|
return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,9 @@ package com.dfsek.terra.command.structure;
|
|||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import com.dfsek.terra.util.structure.WorldEditUtil;
|
|
||||||
import com.dfsek.terra.structure.Structure;
|
|
||||||
import com.dfsek.terra.structure.InitializationException;
|
import com.dfsek.terra.structure.InitializationException;
|
||||||
|
import com.dfsek.terra.structure.Structure;
|
||||||
|
import com.dfsek.terra.util.structure.WorldEditUtil;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|||||||
@@ -22,10 +22,12 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class LocateCommand extends WorldCommand {
|
public class LocateCommand extends WorldCommand {
|
||||||
private final boolean tp;
|
private final boolean tp;
|
||||||
|
|
||||||
public LocateCommand(org.polydev.gaea.command.Command parent, boolean tp) {
|
public LocateCommand(org.polydev.gaea.command.Command parent, boolean tp) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.tp = tp;
|
this.tp = tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||||
String id = args[0];
|
String id = args[0];
|
||||||
@@ -52,8 +54,7 @@ public class LocateCommand extends WorldCommand {
|
|||||||
int finalZ = location.getBlockZ();
|
int finalZ = location.getBlockZ();
|
||||||
Bukkit.getScheduler().runTask(Terra.getInstance(), () -> sender.teleport(new Location(sender.getWorld(), finalX, sender.getLocation().getY(), finalZ)));
|
Bukkit.getScheduler().runTask(Terra.getInstance(), () -> sender.teleport(new Location(sender.getWorld(), finalX, sender.getLocation().getY(), finalZ)));
|
||||||
}
|
}
|
||||||
}
|
} else sender.sendMessage("Unable to locate structure. ");
|
||||||
else sender.sendMessage("Unable to locate structure. ");
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
return true;
|
return true;
|
||||||
@@ -76,9 +77,11 @@ public class LocateCommand extends WorldCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
||||||
if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator)) return Collections.emptyList();
|
if(! (sender instanceof Player) || ! (((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
|
||||||
|
return Collections.emptyList();
|
||||||
List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getStructureIDs();
|
List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getStructureIDs();
|
||||||
if(args.length == 1) return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
|
if(args.length == 1)
|
||||||
|
return ids.stream().filter(string -> string.toUpperCase().startsWith(args[0].toUpperCase())).collect(Collectors.toList());
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,8 @@ public class ConfigLoader {
|
|||||||
try {
|
try {
|
||||||
Constructor<T> c = clazz.getConstructor(File.class, ConfigPack.class);
|
Constructor<T> c = clazz.getConstructor(File.class, ConfigPack.class);
|
||||||
T o = c.newInstance(path.toFile(), config);
|
T o = c.newInstance(path.toFile(), config);
|
||||||
if(ids.contains(o.getID())) LangUtil.log("config.error.duplicate", Level.SEVERE, path.toString());
|
if(ids.contains(o.getID()))
|
||||||
|
LangUtil.log("config.error.duplicate", Level.SEVERE, path.toString());
|
||||||
ids.add(o.getID());
|
ids.add(o.getID());
|
||||||
configs.put(o.getID(), o);
|
configs.put(o.getID(), o);
|
||||||
LangUtil.log("config.loaded", Level.INFO, o.toString(), path.toString());
|
LangUtil.log("config.loaded", Level.INFO, o.toString(), path.toString());
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public abstract class TerraConfig extends YamlConfiguration {
|
public abstract class TerraConfig extends YamlConfiguration {
|
||||||
private final ConfigPack config;
|
private final ConfigPack config;
|
||||||
|
|
||||||
public TerraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public TerraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
load(file);
|
load(file);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public abstract class TerraConfigSection {
|
public abstract class TerraConfigSection {
|
||||||
private final TerraConfig parent;
|
private final TerraConfig parent;
|
||||||
|
|
||||||
public TerraConfigSection(@NotNull TerraConfig parent) {
|
public TerraConfigSection(@NotNull TerraConfig parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public TerraConfig getParent() {
|
public TerraConfig getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
|
|||||||
@@ -5,19 +5,17 @@ import com.dfsek.terra.carving.UserDefinedCarver;
|
|||||||
import com.dfsek.terra.config.ConfigLoader;
|
import com.dfsek.terra.config.ConfigLoader;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.exception.NotFoundException;
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
import com.dfsek.terra.config.genconfig.TreeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.biome.AbstractBiomeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
|
||||||
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
import com.dfsek.terra.config.genconfig.BiomeGridConfig;
|
||||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||||
import com.dfsek.terra.config.genconfig.FloraConfig;
|
import com.dfsek.terra.config.genconfig.FloraConfig;
|
||||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||||
import com.dfsek.terra.config.genconfig.PaletteConfig;
|
import com.dfsek.terra.config.genconfig.PaletteConfig;
|
||||||
import com.dfsek.terra.config.genconfig.StructureConfig;
|
import com.dfsek.terra.config.genconfig.StructureConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.TreeConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.biome.AbstractBiomeConfig;
|
||||||
|
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import com.dfsek.terra.util.StructureTypeEnum;
|
import com.dfsek.terra.util.StructureTypeEnum;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.StructureType;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public final class ConfigUtil {
|
|||||||
public static long dataSave; // Period of population data saving, in ticks.
|
public static long dataSave; // Period of population data saving, in ticks.
|
||||||
public static boolean masterDisableCaves;
|
public static boolean masterDisableCaves;
|
||||||
public static FailType failType;
|
public static FailType failType;
|
||||||
|
|
||||||
public static void loadConfig(JavaPlugin main) {
|
public static void loadConfig(JavaPlugin main) {
|
||||||
main.saveDefaultConfig();
|
main.saveDefaultConfig();
|
||||||
main.reloadConfig();
|
main.reloadConfig();
|
||||||
@@ -70,7 +71,8 @@ public final class ConfigUtil {
|
|||||||
Set<Material> bl = new HashSet<>();
|
Set<Material> bl = new HashSet<>();
|
||||||
for(String s : list) {
|
for(String s : list) {
|
||||||
try {
|
try {
|
||||||
if(bl.contains(Bukkit.createBlockData(s).getMaterial())) Bukkit.getLogger().warning("Duplicate material in " + phase + " list: " + s);
|
if(bl.contains(Bukkit.createBlockData(s).getMaterial()))
|
||||||
|
Bukkit.getLogger().warning("Duplicate material in " + phase + " list: " + s);
|
||||||
bl.add(Bukkit.createBlockData(s).getMaterial());
|
bl.add(Bukkit.createBlockData(s).getMaterial());
|
||||||
} catch(NullPointerException | IllegalArgumentException e) {
|
} catch(NullPointerException | IllegalArgumentException e) {
|
||||||
throw new ConfigException("Could not load BlockData data for \"" + s + "\"", id);
|
throw new ConfigException("Could not load BlockData data for \"" + s + "\"", id);
|
||||||
|
|||||||
@@ -3,15 +3,12 @@ package com.dfsek.terra.config.base;
|
|||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import com.dfsek.terra.debug.gui.DebugGUI;
|
|
||||||
import com.dfsek.terra.image.ImageLoader;
|
import com.dfsek.terra.image.ImageLoader;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.polydev.gaea.GaeaPlugin;
|
import org.polydev.gaea.GaeaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -51,7 +48,8 @@ public class WorldConfig {
|
|||||||
FileConfiguration config = new YamlConfiguration();
|
FileConfiguration config = new YamlConfiguration();
|
||||||
Debug.info("Loading config " + configID + " for world " + worldID);
|
Debug.info("Loading config " + configID + " for world " + worldID);
|
||||||
try { // Load/create world config file
|
try { // Load/create world config file
|
||||||
if(configID == null || configID.equals("")) throw new ConfigException("Config pack unspecified in bukkit.yml!", worldID);
|
if(configID == null || configID.equals(""))
|
||||||
|
throw new ConfigException("Config pack unspecified in bukkit.yml!", worldID);
|
||||||
File configFile = new File(main.getDataFolder() + File.separator + "worlds", worldID + ".yml");
|
File configFile = new File(main.getDataFolder() + File.separator + "worlds", worldID + ".yml");
|
||||||
if(! configFile.exists()) {
|
if(! configFile.exists()) {
|
||||||
configFile.getParentFile().mkdirs();
|
configFile.getParentFile().mkdirs();
|
||||||
@@ -65,7 +63,8 @@ public class WorldConfig {
|
|||||||
|
|
||||||
tConfig = ConfigPack.fromID(configID);
|
tConfig = ConfigPack.fromID(configID);
|
||||||
|
|
||||||
if(tConfig == null) throw new ConfigException("No such config pack: \"" + configID + "\". This pack either does not exist, or failed to load due to configuration errors.", worldID);
|
if(tConfig == null)
|
||||||
|
throw new ConfigException("No such config pack: \"" + configID + "\". This pack either does not exist, or failed to load due to configuration errors.", worldID);
|
||||||
|
|
||||||
// Load image stuff
|
// Load image stuff
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.bukkit.configuration.InvalidConfigurationException;
|
|||||||
public class ConfigException extends InvalidConfigurationException {
|
public class ConfigException extends InvalidConfigurationException {
|
||||||
private final String message;
|
private final String message;
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
public ConfigException(String message, String id) {
|
public ConfigException(String message, String id) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.dfsek.terra.config.genconfig;
|
|||||||
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.biome.UserDefinedGrid;
|
import com.dfsek.terra.biome.UserDefinedGrid;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
import com.dfsek.terra.config.base.WorldConfig;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.exception.NotFoundException;
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.dfsek.terra.config.genconfig;
|
|||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig;
|
||||||
|
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@@ -63,7 +63,8 @@ public class FloraConfig extends TerraConfig implements Flora {
|
|||||||
if(spawnable.contains(check.getType()) && replaceable.contains(other.getType())) {
|
if(spawnable.contains(check.getType()) && replaceable.contains(other.getType())) {
|
||||||
blocks.add(check);
|
blocks.add(check);
|
||||||
}
|
}
|
||||||
} else for(int y : range) {
|
}
|
||||||
|
else for(int y : range) {
|
||||||
if(y > 254 || y < 0) continue;
|
if(y > 254 || y < 0) continue;
|
||||||
Block check = chunk.getBlock(x, y, z);
|
Block check = chunk.getBlock(x, y, z);
|
||||||
Block other = chunk.getBlock(x, y + 1, z);
|
Block other = chunk.getBlock(x, y + 1, z);
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig;
|
||||||
|
|
||||||
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@@ -34,6 +33,7 @@ public class OreConfig extends TerraConfig {
|
|||||||
private final boolean crossChunks;
|
private final boolean crossChunks;
|
||||||
private final int chunkEdgeOffset;
|
private final int chunkEdgeOffset;
|
||||||
Set<Material> replaceable;
|
Set<Material> replaceable;
|
||||||
|
|
||||||
public OreConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public OreConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
if(! contains("id")) throw new ConfigException("Ore ID not found!", "null");
|
if(! contains("id")) throw new ConfigException("Ore ID not found!", "null");
|
||||||
@@ -49,7 +49,8 @@ public class OreConfig extends TerraConfig {
|
|||||||
crossChunks = getBoolean("cross-chunks", true);
|
crossChunks = getBoolean("cross-chunks", true);
|
||||||
chunkEdgeOffset = getInt("edge-offset", 1);
|
chunkEdgeOffset = getInt("edge-offset", 1);
|
||||||
|
|
||||||
if(chunkEdgeOffset > 7 || chunkEdgeOffset < 0) throw new ConfigException("Edge offset is too high/low!", getID());
|
if(chunkEdgeOffset > 7 || chunkEdgeOffset < 0)
|
||||||
|
throw new ConfigException("Edge offset is too high/low!", getID());
|
||||||
|
|
||||||
replaceable = ConfigUtil.toBlockData(getStringList("replace"), "replaceable", getID());
|
replaceable = ConfigUtil.toBlockData(getStringList("replace"), "replaceable", getID());
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ public class OreConfig extends TerraConfig {
|
|||||||
private int randomInRange(Random r) {
|
private int randomInRange(Random r) {
|
||||||
return r.nextInt(max - min + 1) + min;
|
return r.nextInt(max - min + 1) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doVein(Vector l, Chunk chunk, Random r) {
|
public void doVein(Vector l, Chunk chunk, Random r) {
|
||||||
FastNoiseLite ore = new FastNoiseLite(r.nextInt());
|
FastNoiseLite ore = new FastNoiseLite(r.nextInt());
|
||||||
ore.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
ore.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
||||||
@@ -81,12 +83,14 @@ public class OreConfig extends TerraConfig {
|
|||||||
ChunkCoordinate coord = new ChunkCoordinate(Math.floorDiv(oreLoc.getBlockX(), 16), Math.floorDiv(oreLoc.getBlockZ(), 16), chunk.getWorld().getUID());
|
ChunkCoordinate coord = new ChunkCoordinate(Math.floorDiv(oreLoc.getBlockX(), 16), Math.floorDiv(oreLoc.getBlockZ(), 16), chunk.getWorld().getUID());
|
||||||
Block b = chunks.computeIfAbsent(coord, k -> chunk.getWorld().getChunkAt(oreLoc.toLocation(chunk.getWorld())))
|
Block b = chunks.computeIfAbsent(coord, k -> chunk.getWorld().getChunkAt(oreLoc.toLocation(chunk.getWorld())))
|
||||||
.getBlock(Math.floorMod(source.getBlockX(), 16), source.getBlockY(), Math.floorMod(source.getBlockZ(), 16)); // Chunk caching conditional computation
|
.getBlock(Math.floorMod(source.getBlockX(), 16), source.getBlockY(), Math.floorMod(source.getBlockZ(), 16)); // Chunk caching conditional computation
|
||||||
if(replaceable.contains(b.getType()) && b.getLocation().getY() >= 0) b.setBlockData(oreData, update);
|
if(replaceable.contains(b.getType()) && b.getLocation().getY() >= 0)
|
||||||
|
b.setBlockData(oreData, update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doVeinSingle(Vector l, Chunk chunk, Random r) {
|
public void doVeinSingle(Vector l, Chunk chunk, Random r) {
|
||||||
FastNoiseLite ore = new FastNoiseLite(r.nextInt());
|
FastNoiseLite ore = new FastNoiseLite(r.nextInt());
|
||||||
ore.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
ore.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
||||||
@@ -96,10 +100,12 @@ public class OreConfig extends TerraConfig {
|
|||||||
for(int y = - rad; y <= rad; y++) {
|
for(int y = - rad; y <= rad; y++) {
|
||||||
for(int z = - rad; z <= rad; z++) {
|
for(int z = - rad; z <= rad; z++) {
|
||||||
Vector oreLoc = l.clone().add(new Vector(x, y, z));
|
Vector oreLoc = l.clone().add(new Vector(x, y, z));
|
||||||
if(oreLoc.getBlockX() > 15 || oreLoc.getBlockZ() > 15 || oreLoc.getBlockY() > 255 || oreLoc.getBlockX() < 0 || oreLoc.getBlockZ() < 0 || oreLoc.getBlockY() < 0) continue;
|
if(oreLoc.getBlockX() > 15 || oreLoc.getBlockZ() > 15 || oreLoc.getBlockY() > 255 || oreLoc.getBlockX() < 0 || oreLoc.getBlockZ() < 0 || oreLoc.getBlockY() < 0)
|
||||||
|
continue;
|
||||||
if(oreLoc.distance(l) < (rad + 0.5) * ((ore.getNoise(x, y, z) + 1) * deform)) {
|
if(oreLoc.distance(l) < (rad + 0.5) * ((ore.getNoise(x, y, z) + 1) * deform)) {
|
||||||
Block b = chunk.getBlock(oreLoc.getBlockX(), oreLoc.getBlockY(), oreLoc.getBlockZ());
|
Block b = chunk.getBlock(oreLoc.getBlockX(), oreLoc.getBlockY(), oreLoc.getBlockZ());
|
||||||
if(replaceable.contains(b.getType()) && b.getLocation().getY() >= 0) b.setBlockData(oreData, update);
|
if(replaceable.contains(b.getType()) && b.getLocation().getY() >= 0)
|
||||||
|
b.setBlockData(oreData, update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
@@ -23,6 +23,7 @@ public class PaletteConfig extends TerraConfig {
|
|||||||
private final Palette<BlockData> palette;
|
private final Palette<BlockData> palette;
|
||||||
private final String paletteID;
|
private final String paletteID;
|
||||||
private boolean useNoise = false;
|
private boolean useNoise = false;
|
||||||
|
|
||||||
public PaletteConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public PaletteConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
if(! contains("id")) throw new ConfigException("Palette ID unspecified!", "null");
|
if(! contains("id")) throw new ConfigException("Palette ID unspecified!", "null");
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.dfsek.terra.config.genconfig;
|
package com.dfsek.terra.config.genconfig;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.exception.NotFoundException;
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
@@ -32,6 +32,7 @@ public class StructureConfig extends TerraConfig {
|
|||||||
private final Range bound;
|
private final Range bound;
|
||||||
private final Map<Integer, LootTable> loot = new HashMap<>();
|
private final Map<Integer, LootTable> loot = new HashMap<>();
|
||||||
StructurePopulator.SearchType type;
|
StructurePopulator.SearchType type;
|
||||||
|
|
||||||
public StructureConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public StructureConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
if(! contains("id")) throw new ConfigException("No ID specified!", "null");
|
if(! contains("id")) throw new ConfigException("No ID specified!", "null");
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class TreeConfig extends TerraConfig implements Tree {
|
|||||||
private final String id;
|
private final String id;
|
||||||
private final int yOffset;
|
private final int yOffset;
|
||||||
private final ProbabilityCollection<Structure> structure = new ProbabilityCollection<>();
|
private final ProbabilityCollection<Structure> structure = new ProbabilityCollection<>();
|
||||||
|
|
||||||
public TreeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
public TreeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
|
||||||
super(file, config);
|
super(file, config);
|
||||||
spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID());
|
spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID());
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package com.dfsek.terra.config.genconfig.biome;
|
package com.dfsek.terra.config.genconfig.biome;
|
||||||
|
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class AbstractBiomeConfig extends TerraConfig {
|
public class AbstractBiomeConfig extends TerraConfig {
|
||||||
private final String biomeID;
|
private final String biomeID;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class BiomeCarverConfig extends TerraConfigSection {
|
public class BiomeCarverConfig extends TerraConfigSection {
|
||||||
private final Map<CarverConfig, Integer> carvers = new HashMap<>();
|
private final Map<CarverConfig, Integer> carvers = new HashMap<>();
|
||||||
|
|
||||||
public BiomeCarverConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeCarverConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
ConfigurationSection configurationSection = parent.getConfigurationSection("carving");
|
ConfigurationSection configurationSection = parent.getConfigurationSection("carving");
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ public class BiomeConfig extends TerraConfig {
|
|||||||
} else palette = new BiomePaletteConfig(this);
|
} else palette = new BiomePaletteConfig(this);
|
||||||
|
|
||||||
// Palette must not be null
|
// Palette must not be null
|
||||||
if(palette.getPaletteMap() == null) throw new ConfigException("No Palette specified in biome or super biome.", getID());
|
if(palette.getPaletteMap() == null)
|
||||||
|
throw new ConfigException("No Palette specified in biome or super biome.", getID());
|
||||||
|
|
||||||
// Check if carving should be handled by super biome.
|
// Check if carving should be handled by super biome.
|
||||||
if(extending && abstractBiome.getCarving() != null && ! contains("carving")) {
|
if(extending && abstractBiome.getCarving() != null && ! contains("carving")) {
|
||||||
@@ -121,7 +122,8 @@ public class BiomeConfig extends TerraConfig {
|
|||||||
} else snow = new BiomeSnowConfig(this);
|
} else snow = new BiomeSnowConfig(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(), flora.getFloraChance(), tree.getTreeDensity());
|
UserDefinedDecorator dec = new UserDefinedDecorator(flora.getFlora(), tree.getTrees(), flora.getFloraChance(), tree.getTreeDensity());
|
||||||
@@ -138,7 +140,8 @@ public class BiomeConfig extends TerraConfig {
|
|||||||
// Structure stuff
|
// Structure stuff
|
||||||
structures = new ArrayList<>();
|
structures = new ArrayList<>();
|
||||||
List<String> st = new ArrayList<>();
|
List<String> st = new ArrayList<>();
|
||||||
if(abstractBiome != null && abstractBiome.getStructureConfigs() != null) st = abstractBiome.getStructureConfigs();
|
if(abstractBiome != null && abstractBiome.getStructureConfigs() != null)
|
||||||
|
st = abstractBiome.getStructureConfigs();
|
||||||
if(contains("structures")) st = getStringList("structures");
|
if(contains("structures")) st = getStringList("structures");
|
||||||
for(String s : st) {
|
for(String s : st) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public class BiomeFloraConfig extends TerraConfigSection {
|
|||||||
private int floraChance;
|
private int floraChance;
|
||||||
private boolean floraSimplex;
|
private boolean floraSimplex;
|
||||||
private FastNoiseLite floraNoise;
|
private FastNoiseLite floraNoise;
|
||||||
|
|
||||||
public BiomeFloraConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeFloraConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
ConfigurationSection cfg = parent.getConfigurationSection("flora.items");
|
ConfigurationSection cfg = parent.getConfigurationSection("flora.items");
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class BiomeOceanConfig extends TerraConfigSection {
|
|||||||
private final Palette<BlockData> ocean;
|
private final Palette<BlockData> ocean;
|
||||||
private final int seaLevel;
|
private final int seaLevel;
|
||||||
private static final Palette<BlockData> oceanDefault = new RandomPalette<BlockData>(new Random(0)).add(Material.WATER.createBlockData(), 1);
|
private static final Palette<BlockData> oceanDefault = new RandomPalette<BlockData>(new Random(0)).add(Material.WATER.createBlockData(), 1);
|
||||||
|
|
||||||
public BiomeOceanConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeOceanConfig(@NotNull TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
seaLevel = parent.getInt("ocean.level", 62);
|
seaLevel = parent.getInt("ocean.level", 62);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.util.Map;
|
|||||||
public class BiomeOreConfig extends TerraConfigSection {
|
public class BiomeOreConfig extends TerraConfigSection {
|
||||||
private final Map<OreConfig, Range> ores = new HashMap<>();
|
private final Map<OreConfig, Range> ores = new HashMap<>();
|
||||||
private final Map<OreConfig, Range> oreHeights = new HashMap<>();
|
private final Map<OreConfig, Range> oreHeights = new HashMap<>();
|
||||||
|
|
||||||
public BiomeOreConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeOreConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
ConfigurationSection c = parent.getConfigurationSection("ores");
|
ConfigurationSection c = parent.getConfigurationSection("ores");
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.dfsek.terra.config.exception.ConfigException;
|
|||||||
import com.dfsek.terra.config.exception.NotFoundException;
|
import com.dfsek.terra.config.exception.NotFoundException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.polydev.gaea.math.ProbabilityCollection;
|
import org.polydev.gaea.math.ProbabilityCollection;
|
||||||
import org.polydev.gaea.world.palette.Palette;
|
import org.polydev.gaea.world.palette.Palette;
|
||||||
@@ -19,6 +18,7 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
public class BiomePaletteConfig extends TerraConfigSection {
|
public class BiomePaletteConfig extends TerraConfigSection {
|
||||||
private TreeMap<Integer, Palette<BlockData>> paletteMap;
|
private TreeMap<Integer, Palette<BlockData>> paletteMap;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BiomePaletteConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomePaletteConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
@@ -34,8 +34,7 @@ public class BiomePaletteConfig extends TerraConfigSection {
|
|||||||
} catch(IllegalArgumentException ex) {
|
} catch(IllegalArgumentException ex) {
|
||||||
throw new ConfigException("BlockData " + entry.getKey() + " is invalid! (Palettes)", parent.getID());
|
throw new ConfigException("BlockData " + entry.getKey() + " is invalid! (Palettes)", parent.getID());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
try {
|
try {
|
||||||
paletteMap.put((Integer) entry.getValue(), parent.getConfig().getPalette((String) entry.getKey()).getPalette());
|
paletteMap.put((Integer) entry.getValue(), parent.getConfig().getPalette((String) entry.getKey()).getPalette());
|
||||||
} catch(NullPointerException ex) {
|
} catch(NullPointerException ex) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ 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;
|
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);
|
slabThreshold = parent.getDouble("slabs.threshold", 0.1D);
|
||||||
@@ -31,6 +32,7 @@ public class BiomeSlabConfig extends TerraConfigSection {
|
|||||||
stairs = getSlabPalettes(parent.getMapList("slabs.stair-palettes"));
|
stairs = getSlabPalettes(parent.getMapList("slabs.stair-palettes"));
|
||||||
} else stairs = new HashMap<>();
|
} else stairs = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<Material, Palette<BlockData>> getSlabPalettes(List<Map<?, ?>> paletteConfigSection) throws InvalidConfigurationException {
|
protected Map<Material, Palette<BlockData>> getSlabPalettes(List<Map<?, ?>> paletteConfigSection) throws InvalidConfigurationException {
|
||||||
Map<Material, Palette<BlockData>> paletteMap = new HashMap<>();
|
Map<Material, Palette<BlockData>> paletteMap = new HashMap<>();
|
||||||
|
|
||||||
@@ -47,7 +49,8 @@ public class BiomeSlabConfig extends TerraConfigSection {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Palette<BlockData> p = getParent().getConfig().getPalette((String) entry.getValue()).getPalette();
|
Palette<BlockData> p = getParent().getConfig().getPalette((String) entry.getValue()).getPalette();
|
||||||
if(p.getSize() != 1) throw new InvalidConfigurationException("Slab palette must hold only one layer. Palette " + entry.getValue() + " is too large/small");
|
if(p.getSize() != 1)
|
||||||
|
throw new InvalidConfigurationException("Slab palette must hold only one layer. Palette " + entry.getValue() + " is too large/small");
|
||||||
paletteMap.put(Bukkit.createBlockData((String) entry.getKey()).getMaterial(), p);
|
paletteMap.put(Bukkit.createBlockData((String) entry.getKey()).getMaterial(), p);
|
||||||
} catch(NullPointerException ex) {
|
} catch(NullPointerException ex) {
|
||||||
throw new NotFoundException("Slab Palette", (String) entry.getValue(), getParent().getConfig().getID());
|
throw new NotFoundException("Slab Palette", (String) entry.getValue(), getParent().getConfig().getID());
|
||||||
|
|||||||
@@ -1,27 +1,19 @@
|
|||||||
package com.dfsek.terra.config.genconfig.biome;
|
package com.dfsek.terra.config.genconfig.biome;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
|
||||||
import com.dfsek.terra.config.TerraConfig;
|
import com.dfsek.terra.config.TerraConfig;
|
||||||
import com.dfsek.terra.config.TerraConfigSection;
|
import com.dfsek.terra.config.TerraConfigSection;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.exception.ConfigException;
|
import com.dfsek.terra.config.exception.ConfigException;
|
||||||
import com.dfsek.terra.config.exception.NotFoundException;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.polydev.gaea.math.FastNoiseLite;
|
|
||||||
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.FloraType;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BiomeSnowConfig extends TerraConfigSection {
|
public class BiomeSnowConfig extends TerraConfigSection {
|
||||||
private final int[] snowHeights;
|
private final int[] snowHeights;
|
||||||
private boolean doSnow = false;
|
private boolean doSnow = false;
|
||||||
|
|
||||||
public BiomeSnowConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeSnowConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
snowHeights = new int[256];
|
snowHeights = new int[256];
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import org.polydev.gaea.math.ProbabilityCollection;
|
|||||||
import org.polydev.gaea.math.Range;
|
import org.polydev.gaea.math.Range;
|
||||||
import org.polydev.gaea.tree.Tree;
|
import org.polydev.gaea.tree.Tree;
|
||||||
import org.polydev.gaea.tree.TreeType;
|
import org.polydev.gaea.tree.TreeType;
|
||||||
import org.polydev.gaea.world.Flora;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -19,6 +18,7 @@ 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 treeDensity;
|
private int treeDensity;
|
||||||
|
|
||||||
public BiomeTreeConfig(TerraConfig parent) throws InvalidConfigurationException {
|
public BiomeTreeConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||||
super(parent);
|
super(parent);
|
||||||
ConfigurationSection c = parent.getConfigurationSection("trees.items");
|
ConfigurationSection c = parent.getConfigurationSection("trees.items");
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import static org.polydev.gaea.util.JarUtil.copyResourcesToDirectory;
|
|||||||
public final class LangUtil {
|
public final class LangUtil {
|
||||||
private static Language language;
|
private static Language language;
|
||||||
private static Logger logger;
|
private static Logger logger;
|
||||||
|
|
||||||
public static void load(String langID, JavaPlugin main) {
|
public static void load(String langID, JavaPlugin main) {
|
||||||
logger = main.getLogger();
|
logger = main.getLogger();
|
||||||
File file = new File(main.getDataFolder(), "lang");
|
File file = new File(main.getDataFolder(), "lang");
|
||||||
@@ -45,6 +46,7 @@ public final class LangUtil {
|
|||||||
public static void log(String messageID, Level level, String... args) {
|
public static void log(String messageID, Level level, String... args) {
|
||||||
language.getMessage(messageID).log(logger, level, args);
|
language.getMessage(messageID).log(logger, level, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send(String messageID, CommandSender sender, String... args) {
|
public static void send(String messageID, CommandSender sender, String... args) {
|
||||||
language.getMessage(messageID).send(sender, args);
|
language.getMessage(messageID).send(sender, args);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.dfsek.terra.debug.gui;
|
package com.dfsek.terra.debug.gui;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
|
import com.dfsek.terra.generation.TerraChunkGenerator;
|
||||||
import com.dfsek.terra.image.ImageLoader;
|
import com.dfsek.terra.image.ImageLoader;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -18,6 +18,7 @@ public class DebugFrame extends JFrame implements ActionListener {
|
|||||||
private final int x;
|
private final int x;
|
||||||
private final int z;
|
private final int z;
|
||||||
private final BufferedImage img;
|
private final BufferedImage img;
|
||||||
|
|
||||||
public DebugFrame(BufferedImage image, String s) {
|
public DebugFrame(BufferedImage image, String s) {
|
||||||
super(s);
|
super(s);
|
||||||
this.x = image.getWidth();
|
this.x = image.getWidth();
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ import java.awt.image.BufferedImage;
|
|||||||
public class DebugGUI extends Thread {
|
public class DebugGUI extends Thread {
|
||||||
|
|
||||||
private final BufferedImage img;
|
private final BufferedImage img;
|
||||||
|
|
||||||
public DebugGUI(BufferedImage img) {
|
public DebugGUI(BufferedImage img) {
|
||||||
this.img = img;
|
this.img = img;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DebugFrame frame = new DebugFrame(img, "Image2Map Debug GUI");
|
DebugFrame frame = new DebugFrame(img, "Image2Map Debug GUI");
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.event;
|
package com.dfsek.terra.event;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.config.genconfig.TreeConfig;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.polydev.gaea.tree.Tree;
|
import org.polydev.gaea.tree.Tree;
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
|
|||||||
public int getNoiseOctaves(World world) {
|
public int getNoiseOctaves(World world) {
|
||||||
return octaves;
|
return octaves;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getNoiseFrequency(World world) {
|
public float getNoiseFrequency(World world) {
|
||||||
return frequency;
|
return frequency;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class UserDefinedGenerator extends Generator {
|
|||||||
this.noiseExp = p.parse(equation, s);
|
this.noiseExp = p.parse(equation, s);
|
||||||
this.preventSmooth = preventSmooth;
|
this.preventSmooth = preventSmooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the 2D noise at a pair of coordinates using the provided FastNoiseLite instance.
|
* Gets the 2D noise at a pair of coordinates using the provided FastNoiseLite instance.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,18 +8,17 @@ import com.dfsek.terra.debug.gui.DebugGUI;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.polydev.gaea.biome.NormalizationUtil;
|
import org.polydev.gaea.biome.NormalizationUtil;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
|
|
||||||
public class ImageLoader {
|
public class ImageLoader {
|
||||||
private final BufferedImage image;
|
private final BufferedImage image;
|
||||||
private final Align align;
|
private final Align align;
|
||||||
double inverseRoot2 = 0.7071067811865475;
|
double inverseRoot2 = 0.7071067811865475;
|
||||||
|
|
||||||
public ImageLoader(File file, Align align) throws IOException {
|
public ImageLoader(File file, Align align) throws IOException {
|
||||||
image = ImageIO.read(file);
|
image = ImageIO.read(file);
|
||||||
this.align = align;
|
this.align = align;
|
||||||
@@ -30,11 +29,16 @@ public class ImageLoader {
|
|||||||
int rgb;
|
int rgb;
|
||||||
rgb = align.getRGB(image, x, y);
|
rgb = align.getRGB(image, x, y);
|
||||||
switch(channel) {
|
switch(channel) {
|
||||||
case RED: return rgb >> 16 & 0xff;
|
case RED:
|
||||||
case GREEN: return rgb >> 8 & 0xff;
|
return rgb >> 16 & 0xff;
|
||||||
case BLUE: return rgb & 0xff;
|
case GREEN:
|
||||||
case ALPHA: return rgb >> 32 & 0xff;
|
return rgb >> 8 & 0xff;
|
||||||
default: throw new IllegalArgumentException();
|
case BLUE:
|
||||||
|
return rgb & 0xff;
|
||||||
|
case ALPHA:
|
||||||
|
return rgb >> 32 & 0xff;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +49,7 @@ public class ImageLoader {
|
|||||||
DebugGUI debugGUI = new DebugGUI(newImg);
|
DebugGUI debugGUI = new DebugGUI(newImg);
|
||||||
debugGUI.start();
|
debugGUI.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BufferedImage redrawStepped(BufferedImage original, World w, Align align) {
|
private static BufferedImage redrawStepped(BufferedImage original, World w, Align align) {
|
||||||
BufferedImage newImg = copyImage(original);
|
BufferedImage newImg = copyImage(original);
|
||||||
TerraBiomeGrid tb = TerraWorld.getWorld(w).getGrid();
|
TerraBiomeGrid tb = TerraWorld.getWorld(w).getGrid();
|
||||||
@@ -52,7 +57,8 @@ public class ImageLoader {
|
|||||||
for(int x = 0; x < newImg.getWidth(); x++) {
|
for(int x = 0; x < newImg.getWidth(); x++) {
|
||||||
for(int y = 0; y < newImg.getHeight(); y++) {
|
for(int y = 0; y < newImg.getHeight(); y++) {
|
||||||
float[] noise;
|
float[] noise;
|
||||||
if(align.equals(Align.CENTER)) noise = tb.getGrid(x - original.getWidth()/2, y - original.getHeight()/2).getRawNoise(x - original.getWidth()/2, y - original.getHeight()/2);
|
if(align.equals(Align.CENTER))
|
||||||
|
noise = tb.getGrid(x - original.getWidth() / 2, y - original.getHeight() / 2).getRawNoise(x - original.getWidth() / 2, y - original.getHeight() / 2);
|
||||||
else noise = tb.getGrid(x, y).getRawNoise(x, y);
|
else noise = tb.getGrid(x, y).getRawNoise(x, y);
|
||||||
newImg.setRGB(x, y, new Color((int) (NormalizationUtil.normalize(noise[0], tb.getGrid(x, y).getSizeX(), 4) * ((double) 255 / tb.getGrid(x, y).getSizeX())),
|
newImg.setRGB(x, y, new Color((int) (NormalizationUtil.normalize(noise[0], tb.getGrid(x, y).getSizeX(), 4) * ((double) 255 / tb.getGrid(x, y).getSizeX())),
|
||||||
(int) (NormalizationUtil.normalize(noise[1], tb.getGrid(x, y).getSizeZ(), 4) * ((double) 255 / tb.getGrid(x, y).getSizeZ())),
|
(int) (NormalizationUtil.normalize(noise[1], tb.getGrid(x, y).getSizeZ(), 4) * ((double) 255 / tb.getGrid(x, y).getSizeZ())),
|
||||||
@@ -76,6 +82,7 @@ public class ImageLoader {
|
|||||||
public double getNoiseVal(int x, int y, Channel channel) {
|
public double getNoiseVal(int x, int y, Channel channel) {
|
||||||
return ((double) (getChannel(x, y, channel) - 128) / 128) * inverseRoot2;
|
return ((double) (getChannel(x, y, channel) - 128) / 128) * inverseRoot2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BufferedImage copyImage(BufferedImage source) {
|
private static BufferedImage copyImage(BufferedImage source) {
|
||||||
BufferedImage b = new BufferedImage(source.getWidth(), source.getHeight(), source.getType());
|
BufferedImage b = new BufferedImage(source.getWidth(), source.getHeight(), source.getType());
|
||||||
Graphics g = b.getGraphics();
|
Graphics g = b.getGraphics();
|
||||||
@@ -91,6 +98,7 @@ public class ImageLoader {
|
|||||||
public enum Channel {
|
public enum Channel {
|
||||||
RED, GREEN, BLUE, ALPHA
|
RED, GREEN, BLUE, ALPHA
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Align {
|
public enum Align {
|
||||||
CENTER {
|
CENTER {
|
||||||
@Override
|
@Override
|
||||||
@@ -104,7 +112,9 @@ public class ImageLoader {
|
|||||||
return image.getRGB(Math.floorMod(x, image.getWidth()), Math.floorMod(y, image.getHeight()));
|
return image.getRGB(Math.floorMod(x, image.getWidth()), Math.floorMod(y, image.getHeight()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public abstract int getRGB(BufferedImage image, int x, int y);
|
public abstract int getRGB(BufferedImage image, int x, int y);
|
||||||
|
|
||||||
private static int getRGBNoAlign(BufferedImage image, int x, int y) {
|
private static int getRGBNoAlign(BufferedImage image, int x, int y) {
|
||||||
return image.getRGB(Math.floorMod(x, image.getWidth()), Math.floorMod(y, image.getHeight()));
|
return image.getRGB(Math.floorMod(x, image.getWidth()), Math.floorMod(y, image.getHeight()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.dfsek.terra.image;
|
package com.dfsek.terra.image;
|
||||||
|
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.BiomeZone;
|
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||||
import com.dfsek.terra.config.base.WorldConfig;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.polydev.gaea.biome.NormalizationUtil;
|
import org.polydev.gaea.biome.NormalizationUtil;
|
||||||
|
|
||||||
@@ -16,10 +14,12 @@ import java.io.IOException;
|
|||||||
public class WorldImageGenerator {
|
public class WorldImageGenerator {
|
||||||
private final World w;
|
private final World w;
|
||||||
private final BufferedImage draw;
|
private final BufferedImage draw;
|
||||||
|
|
||||||
public WorldImageGenerator(World w, int width, int height) {
|
public WorldImageGenerator(World w, int width, int height) {
|
||||||
draw = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
draw = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
this.w = w;
|
this.w = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldImageGenerator drawWorld(int centerX, int centerZ) {
|
public WorldImageGenerator drawWorld(int centerX, int centerZ) {
|
||||||
TerraWorld tw = TerraWorld.getWorld(w);
|
TerraWorld tw = TerraWorld.getWorld(w);
|
||||||
TerraBiomeGrid tb = tw.getGrid();
|
TerraBiomeGrid tb = tw.getGrid();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class NoiseFunction3 implements Function {
|
public class NoiseFunction3 implements Function {
|
||||||
private FastNoiseLite gen;
|
private FastNoiseLite gen;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNumberOfArguments() {
|
public int getNumberOfArguments() {
|
||||||
return 3;
|
return 3;
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package com.dfsek.terra.population;
|
|||||||
|
|
||||||
import com.dfsek.terra.TerraProfiler;
|
import com.dfsek.terra.TerraProfiler;
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.carving.SimplexCarver;
|
|
||||||
import com.dfsek.terra.config.base.ConfigPack;
|
import com.dfsek.terra.config.base.ConfigPack;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||||
import com.dfsek.terra.structure.StructureSpawnRequirement;
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -29,6 +27,7 @@ import java.util.Set;
|
|||||||
public class CavePopulator extends BlockPopulator {
|
public class CavePopulator extends BlockPopulator {
|
||||||
private static final Map<Material, BlockData> shiftStorage = new HashMap<>(); // Persist BlockData created for shifts, to avoid re-calculating each time.
|
private static final Map<Material, BlockData> shiftStorage = new HashMap<>(); // Persist BlockData created for shifts, to avoid re-calculating each time.
|
||||||
private static final BlockData AIR = Material.AIR.createBlockData();
|
private static final BlockData AIR = Material.AIR.createBlockData();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||||
if(ConfigUtil.masterDisableCaves) return;
|
if(ConfigUtil.masterDisableCaves) return;
|
||||||
@@ -75,7 +74,8 @@ public class CavePopulator extends BlockPopulator {
|
|||||||
if(c.getShiftedBlocks().get(shiftCandidate.get(l)).contains(mut.getBlock().getType())) {
|
if(c.getShiftedBlocks().get(shiftCandidate.get(l)).contains(mut.getBlock().getType())) {
|
||||||
mut.getBlock().setBlockData(shiftStorage.computeIfAbsent(shiftCandidate.get(l), Material::createBlockData), false);
|
mut.getBlock().setBlockData(shiftStorage.computeIfAbsent(shiftCandidate.get(l), Material::createBlockData), false);
|
||||||
}
|
}
|
||||||
} catch(NullPointerException ignore) {}
|
} catch(NullPointerException ignore) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("CaveBlockUpdate")) {
|
try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("CaveBlockUpdate")) {
|
||||||
for(Block b : updateNeeded) {
|
for(Block b : updateNeeded) {
|
||||||
@@ -100,6 +100,7 @@ public class CavePopulator extends BlockPopulator {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean borderingOcean(Block b) {
|
private boolean borderingOcean(Block b) {
|
||||||
return b.getRelative(BlockFace.UP).getType().equals(Material.WATER) || b.getType().equals(Material.LAVA);
|
return b.getRelative(BlockFace.UP).getType().equals(Material.WATER) || b.getType().equals(Material.LAVA);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ 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 com.dfsek.terra.config.genconfig.biome.BiomeFloraConfig;
|
||||||
import com.dfsek.terra.event.TreeGenerateEvent;
|
import com.dfsek.terra.event.TreeGenerateEvent;
|
||||||
import com.dfsek.terra.generation.UserDefinedDecorator;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.polydev.gaea.biome.Biome;
|
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
import org.polydev.gaea.math.Range;
|
import org.polydev.gaea.math.Range;
|
||||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||||
@@ -58,18 +56,21 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
|||||||
BiomeFloraConfig f = c.getFlora();
|
BiomeFloraConfig f = c.getFlora();
|
||||||
for(int i = 0; i < f.getFloraAttempts(); i++) {
|
for(int i = 0; i < f.getFloraAttempts(); i++) {
|
||||||
Flora item;
|
Flora item;
|
||||||
if(f.isFloraSimplex()) item = biome.getDecorator().getFlora().get(f.getFloraNoise(), originX + x, originZ + z);
|
if(f.isFloraSimplex())
|
||||||
|
item = biome.getDecorator().getFlora().get(f.getFloraNoise(), originX + x, originZ + 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())
|
||||||
item.plant(highest.getLocation());
|
item.plant(highest.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(NullPointerException ignore) {}
|
} catch(NullPointerException ignore) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean doTrees(@NotNull UserDefinedBiome biome, TerraWorld world, @NotNull Random random, @NotNull Chunk chunk, int x, int z) {
|
private static boolean doTrees(@NotNull UserDefinedBiome biome, TerraWorld world, @NotNull Random random, @NotNull Chunk chunk, int x, int z) {
|
||||||
for(Block block : getValidTreeSpawnsAt(chunk, x, z, new Range(0, 254))) {
|
for(Block block : getValidTreeSpawnsAt(chunk, x, z, new Range(0, 254))) {
|
||||||
Tree tree = biome.getDecorator().getTrees().get(random);
|
Tree tree = biome.getDecorator().getTrees().get(random);
|
||||||
@@ -80,13 +81,16 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
|||||||
TreeGenerateEvent event = new TreeGenerateEvent(world, l, tree);
|
TreeGenerateEvent event = new TreeGenerateEvent(world, l, tree);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if(! event.isCancelled()) tree.plant(l, random, Terra.getInstance());
|
if(! event.isCancelled()) tree.plant(l, random, Terra.getInstance());
|
||||||
} catch(NullPointerException ignore) {}
|
} catch(NullPointerException ignore) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int offset(Random r, int i) {
|
private static int offset(Random r, int i) {
|
||||||
return Math.min(Math.max(i + r.nextInt(3) - 1, 0), 15);
|
return Math.min(Math.max(i + r.nextInt(3) - 1, 0), 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Block> getValidTreeSpawnsAt(Chunk chunk, int x, int z, Range check) {
|
public static List<Block> getValidTreeSpawnsAt(Chunk chunk, int x, int z, Range check) {
|
||||||
List<Block> blocks = new ArrayList<>();
|
List<Block> blocks = new ArrayList<>();
|
||||||
for(int y : check) {
|
for(int y : check) {
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
package com.dfsek.terra.population;
|
package com.dfsek.terra.population;
|
||||||
|
|
||||||
|
import com.dfsek.terra.TerraProfiler;
|
||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
|
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.OreConfig;
|
||||||
import com.dfsek.terra.config.genconfig.biome.BiomeOreConfig;
|
import com.dfsek.terra.config.genconfig.biome.BiomeOreConfig;
|
||||||
import com.dfsek.terra.event.OreVeinGenerateEvent;
|
import com.dfsek.terra.event.OreVeinGenerateEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
import org.polydev.gaea.math.Range;
|
|
||||||
import com.dfsek.terra.TerraProfiler;
|
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
|
||||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.polydev.gaea.biome.Biome;
|
import org.polydev.gaea.biome.Biome;
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
|
import org.polydev.gaea.math.Range;
|
||||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||||
import org.polydev.gaea.profiler.ProfileFuture;
|
import org.polydev.gaea.profiler.ProfileFuture;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.dfsek.terra.TerraProfiler;
|
|||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
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.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||||
import com.dfsek.terra.util.DataUtil;
|
import com.dfsek.terra.util.DataUtil;
|
||||||
@@ -13,7 +12,6 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||||
@@ -25,6 +23,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class SnowPopulator extends GaeaBlockPopulator {
|
public class SnowPopulator extends GaeaBlockPopulator {
|
||||||
private static final Set<Material> blacklistSpawn = new HashSet<>();
|
private static final Set<Material> blacklistSpawn = new HashSet<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for(Material m : Material.values()) {
|
for(Material m : Material.values()) {
|
||||||
String name = m.toString().toLowerCase();
|
String name = m.toString().toLowerCase();
|
||||||
@@ -44,6 +43,7 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
|||||||
if(ConfigUtil.debug)
|
if(ConfigUtil.debug)
|
||||||
Bukkit.getLogger().info("Added " + blacklistSpawn.size() + " materials to snow blacklist");
|
Bukkit.getLogger().info("Added " + blacklistSpawn.size() + " materials to snow blacklist");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("SnowTime")) {
|
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("SnowTime")) {
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ public class StructurePopulator extends BlockPopulator {
|
|||||||
if(! tw.isSafe()) return;
|
if(! tw.isSafe()) return;
|
||||||
TerraBiomeGrid grid = tw.getGrid();
|
TerraBiomeGrid grid = tw.getGrid();
|
||||||
ConfigPack config = tw.getConfig();
|
ConfigPack config = tw.getConfig();
|
||||||
structure: for(StructureConfig conf : config.getAllStructures()) {
|
structure:
|
||||||
|
for(StructureConfig conf : config.getAllStructures()) {
|
||||||
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
|
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
|
||||||
if(! config.getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(conf)) continue;
|
if(! config.getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(conf)) continue;
|
||||||
Random r2 = new Random(spawn.hashCode());
|
Random r2 = new Random(spawn.hashCode());
|
||||||
@@ -73,6 +74,7 @@ public class StructurePopulator extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SearchType {
|
public enum SearchType {
|
||||||
UP, DOWN
|
UP, DOWN
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.Random;
|
|||||||
public class GridSpawn {
|
public class GridSpawn {
|
||||||
private final int separation;
|
private final int separation;
|
||||||
private final int width;
|
private final int width;
|
||||||
|
|
||||||
public GridSpawn(int width, int separation) {
|
public GridSpawn(int width, int separation) {
|
||||||
this.separation = separation;
|
this.separation = separation;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
@@ -20,6 +21,7 @@ public class GridSpawn {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get nearest spawn point
|
* Get nearest spawn point
|
||||||
|
*
|
||||||
* @param x X coordinate
|
* @param x X coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
* @param seed Seed for RNG
|
* @param seed Seed for RNG
|
||||||
@@ -44,6 +46,7 @@ public class GridSpawn {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the X/Z coordinates of the spawn point in the nearest Chunk (not Minecraft chunk)
|
* Get the X/Z coordinates of the spawn point in the nearest Chunk (not Minecraft chunk)
|
||||||
|
*
|
||||||
* @param structureChunkX Chunk X coordinate
|
* @param structureChunkX Chunk X coordinate
|
||||||
* @param structureChunkZ Chunk Z coordinate
|
* @param structureChunkZ Chunk Z coordinate
|
||||||
* @param seed Seed for RNG
|
* @param seed Seed for RNG
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.dfsek.terra.procgen.math;
|
package com.dfsek.terra.procgen.math;
|
||||||
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* oh yeah
|
* oh yeah
|
||||||
*/
|
*/
|
||||||
@@ -11,6 +9,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a vector with a given X and Z component
|
* Create a vector with a given X and Z component
|
||||||
|
*
|
||||||
* @param x X component
|
* @param x X component
|
||||||
* @param z Z component
|
* @param z Z component
|
||||||
*/
|
*/
|
||||||
@@ -21,6 +20,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get X component
|
* Get X component
|
||||||
|
*
|
||||||
* @return X component
|
* @return X component
|
||||||
*/
|
*/
|
||||||
public double getX() {
|
public double getX() {
|
||||||
@@ -29,6 +29,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Z component
|
* Get Z component
|
||||||
|
*
|
||||||
* @return Z component
|
* @return Z component
|
||||||
*/
|
*/
|
||||||
public double getZ() {
|
public double getZ() {
|
||||||
@@ -37,6 +38,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiply X and Z components by a value.
|
* Multiply X and Z components by a value.
|
||||||
|
*
|
||||||
* @param m Value to multiply
|
* @param m Value to multiply
|
||||||
* @return Mutated vector, for chaining.
|
* @return Mutated vector, for chaining.
|
||||||
*/
|
*/
|
||||||
@@ -48,6 +50,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Divide X and Z components by a value.
|
* Divide X and Z components by a value.
|
||||||
|
*
|
||||||
* @param d Divisor
|
* @param d Divisor
|
||||||
* @return Mutated vector, for chaining.
|
* @return Mutated vector, for chaining.
|
||||||
*/
|
*/
|
||||||
@@ -59,6 +62,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the squared length of this Vector
|
* Get the squared length of this Vector
|
||||||
|
*
|
||||||
* @return squared length
|
* @return squared length
|
||||||
*/
|
*/
|
||||||
public double lengthSquared() {
|
public double lengthSquared() {
|
||||||
@@ -67,6 +71,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the length of this Vector
|
* Get the length of this Vector
|
||||||
|
*
|
||||||
* @return length
|
* @return length
|
||||||
*/
|
*/
|
||||||
public double length() {
|
public double length() {
|
||||||
@@ -75,6 +80,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add this vector to another.
|
* Add this vector to another.
|
||||||
|
*
|
||||||
* @param other Vector to add
|
* @param other Vector to add
|
||||||
* @return Mutated vector, for chaining.
|
* @return Mutated vector, for chaining.
|
||||||
*/
|
*/
|
||||||
@@ -86,6 +92,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Subtract a vector from this vector,
|
* Subtract a vector from this vector,
|
||||||
|
*
|
||||||
* @param other Vector to subtract
|
* @param other Vector to subtract
|
||||||
* @return Mutated vector, for chaining.
|
* @return Mutated vector, for chaining.
|
||||||
*/
|
*/
|
||||||
@@ -97,6 +104,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize this vector to length 1
|
* Normalize this vector to length 1
|
||||||
|
*
|
||||||
* @return Mutated vector, for chaining.
|
* @return Mutated vector, for chaining.
|
||||||
*/
|
*/
|
||||||
public Vector2 normalize() {
|
public Vector2 normalize() {
|
||||||
@@ -106,6 +114,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the distance from this vector to another.
|
* Get the distance from this vector to another.
|
||||||
|
*
|
||||||
* @param other Another vector
|
* @param other Another vector
|
||||||
* @return Distance between vectors
|
* @return Distance between vectors
|
||||||
*/
|
*/
|
||||||
@@ -115,6 +124,7 @@ public class Vector2 implements Cloneable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the squared distance between 2 vectors.
|
* Get the squared distance between 2 vectors.
|
||||||
|
*
|
||||||
* @param other Another vector
|
* @param other Another vector
|
||||||
* @return Squared distance
|
* @return Squared distance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ import java.util.Set;
|
|||||||
public class Rectangle extends Polygon {
|
public class Rectangle extends Polygon {
|
||||||
private Vector2 min;
|
private Vector2 min;
|
||||||
private Vector2 max;
|
private Vector2 max;
|
||||||
|
|
||||||
public Rectangle(Vector2 min, Vector2 max) {
|
public Rectangle(Vector2 min, Vector2 max) {
|
||||||
this.max = new Vector2(Math.min(min.getX(), max.getX()), Math.min(min.getZ(), max.getZ()));
|
this.max = new Vector2(Math.min(min.getX(), max.getX()), Math.min(min.getZ(), max.getZ()));
|
||||||
this.min = new Vector2(Math.max(min.getX(), max.getX()), Math.max(min.getZ(), max.getZ()));;
|
this.min = new Vector2(Math.max(min.getX(), max.getX()), Math.max(min.getZ(), max.getZ()));
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle(Vector2 center, double xRadius, double zRadius) {
|
public Rectangle(Vector2 center, double xRadius, double zRadius) {
|
||||||
Vector2 rad = new Vector2(xRadius, zRadius);
|
Vector2 rad = new Vector2(xRadius, zRadius);
|
||||||
this.min = center.clone().subtract(rad);
|
this.min = center.clone().subtract(rad);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.dfsek.terra.procgen.voxel;
|
package com.dfsek.terra.procgen.voxel;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.polydev.gaea.math.FastNoiseLite;
|
import org.polydev.gaea.math.FastNoiseLite;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.procgen.voxel;
|
package com.dfsek.terra.procgen.voxel;
|
||||||
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.polydev.gaea.math.FastNoiseLite;
|
|
||||||
|
|
||||||
public class Sphere extends VoxelGeometry {
|
public class Sphere extends VoxelGeometry {
|
||||||
public Sphere(Vector start, int rad) {
|
public Sphere(Vector start, int rad) {
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ public abstract class VoxelGeometry {
|
|||||||
public void merge(VoxelGeometry other) {
|
public void merge(VoxelGeometry other) {
|
||||||
geometry.addAll(other.geometry);
|
geometry.addAll(other.geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VoxelGeometry getBlank() {
|
public static VoxelGeometry getBlank() {
|
||||||
return new VoxelGeometry() {};
|
return new VoxelGeometry() {
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
public class InitializationException extends Exception {
|
public class InitializationException extends Exception {
|
||||||
private final Location worldLoc;
|
private final Location worldLoc;
|
||||||
|
|
||||||
public InitializationException(String message, @Nullable Location worldLoc) {
|
public InitializationException(String message, @Nullable Location worldLoc) {
|
||||||
super(message);
|
super(message);
|
||||||
this.worldLoc = worldLoc == null ? null : worldLoc.clone();
|
this.worldLoc = worldLoc == null ? null : worldLoc.clone();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.dfsek.terra.structure;
|
|||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
import com.dfsek.terra.procgen.math.Vector2;
|
import com.dfsek.terra.procgen.math.Vector2;
|
||||||
import com.dfsek.terra.util.structure.RotationUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -10,7 +9,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Container;
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.Directional;
|
import org.bukkit.block.data.Directional;
|
||||||
@@ -21,7 +19,6 @@ import org.bukkit.block.data.Rotatable;
|
|||||||
import org.bukkit.block.data.type.RedstoneWire;
|
import org.bukkit.block.data.type.RedstoneWire;
|
||||||
import org.bukkit.inventory.BlockInventoryHolder;
|
import org.bukkit.inventory.BlockInventoryHolder;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.polydev.gaea.math.Range;
|
import org.polydev.gaea.math.Range;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -32,10 +29,8 @@ import java.io.InputStream;
|
|||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -67,7 +62,8 @@ public class Structure implements Serializable {
|
|||||||
this.uuid = UUID.randomUUID();
|
this.uuid = UUID.randomUUID();
|
||||||
this.spawns = new HashSet<>();
|
this.spawns = new HashSet<>();
|
||||||
this.inventories = new HashSet<>();
|
this.inventories = new HashSet<>();
|
||||||
if(l1.getX() > l2.getX() || l1.getY() > l2.getY() || l1.getZ() > l2.getZ()) throw new IllegalArgumentException("Invalid locations provided!");
|
if(l1.getX() > l2.getX() || l1.getY() > l2.getY() || l1.getZ() > l2.getZ())
|
||||||
|
throw new IllegalArgumentException("Invalid locations provided!");
|
||||||
structure = new StructureContainedBlock[l2.getBlockX() - l1.getBlockX() + 1][l2.getBlockZ() - l1.getBlockZ() + 1][l2.getBlockY() - l1.getBlockY() + 1];
|
structure = new StructureContainedBlock[l2.getBlockX() - l1.getBlockX() + 1][l2.getBlockZ() - l1.getBlockZ() + 1][l2.getBlockY() - l1.getBlockY() + 1];
|
||||||
for(int x = 0; x <= l2.getBlockX() - l1.getBlockX(); x++) {
|
for(int x = 0; x <= l2.getBlockX() - l1.getBlockX(); x++) {
|
||||||
for(int z = 0; z <= l2.getBlockZ() - l1.getBlockZ(); z++) {
|
for(int z = 0; z <= l2.getBlockZ() - l1.getBlockZ(); z++) {
|
||||||
@@ -132,6 +128,7 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get GaeaStructureInfo object
|
* Get GaeaStructureInfo object
|
||||||
|
*
|
||||||
* @return Structure Info
|
* @return Structure Info
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -141,6 +138,7 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Paste the structure at a Location, ignoring chunk boundaries.
|
* Paste the structure at a Location, ignoring chunk boundaries.
|
||||||
|
*
|
||||||
* @param origin Origin location
|
* @param origin Origin location
|
||||||
* @param r Rotation
|
* @param r Rotation
|
||||||
*/
|
*/
|
||||||
@@ -153,7 +151,8 @@ public class Structure implements Serializable {
|
|||||||
public boolean checkSpawns(Location origin, Rotation r) {
|
public boolean checkSpawns(Location origin, Rotation r) {
|
||||||
for(StructureContainedBlock b : spawns) {
|
for(StructureContainedBlock b : spawns) {
|
||||||
Vector2 rot = getRotatedCoords(new Vector2(b.getX() - structureInfo.getCenterX(), b.getZ() - structureInfo.getCenterZ()), r);
|
Vector2 rot = getRotatedCoords(new Vector2(b.getX() - structureInfo.getCenterX(), b.getZ() - structureInfo.getCenterZ()), r);
|
||||||
if(!b.getRequirement().matches(origin.getWorld(), (int) rot.getX()+origin.getBlockX(), origin.getBlockY()+b.getY(), (int) rot.getZ()+origin.getBlockZ())) return false;
|
if(! b.getRequirement().matches(origin.getWorld(), (int) rot.getX() + origin.getBlockX(), origin.getBlockY() + b.getY(), (int) rot.getZ() + origin.getBlockZ()))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -164,6 +163,7 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Paste structure at an origin location, confined to a single chunk.
|
* Paste structure at an origin location, confined to a single chunk.
|
||||||
|
*
|
||||||
* @param origin Origin location
|
* @param origin Origin location
|
||||||
* @param chunk Chunk to confine pasting to
|
* @param chunk Chunk to confine pasting to
|
||||||
* @param r Rotation
|
* @param r Rotation
|
||||||
@@ -180,6 +180,7 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Paste a single StructureDefinedBlock at an origin location, offset by its coordinates.
|
* Paste a single StructureDefinedBlock at an origin location, offset by its coordinates.
|
||||||
|
*
|
||||||
* @param block The block to paste
|
* @param block The block to paste
|
||||||
* @param origin The origin location
|
* @param origin The origin location
|
||||||
* @param r The rotation of the structure
|
* @param r The rotation of the structure
|
||||||
@@ -190,7 +191,8 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
Location loc = origin.clone().add(block.getX(), block.getY(), block.getZ());
|
Location loc = origin.clone().add(block.getX(), block.getY(), block.getZ());
|
||||||
Block worldBlock = loc.getBlock();
|
Block worldBlock = loc.getBlock();
|
||||||
main: while(worldBlock.isEmpty()) {
|
main:
|
||||||
|
while(worldBlock.isEmpty()) {
|
||||||
if(loc.getBlockY() > 255 || loc.getBlockY() < 0) return;
|
if(loc.getBlockY() > 255 || loc.getBlockY() < 0) return;
|
||||||
if(block.getPull() == null) break;
|
if(block.getPull() == null) break;
|
||||||
switch(block.getPull()) {
|
switch(block.getPull()) {
|
||||||
@@ -200,12 +202,14 @@ public class Structure implements Serializable {
|
|||||||
case DOWN:
|
case DOWN:
|
||||||
worldBlock = worldBlock.getRelative(BlockFace.DOWN);
|
worldBlock = worldBlock.getRelative(BlockFace.DOWN);
|
||||||
break;
|
break;
|
||||||
default: break main;
|
default:
|
||||||
|
break main;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
int offset = block.getPullOffset();
|
int offset = block.getPullOffset();
|
||||||
if(offset != 0) worldBlock = worldBlock.getRelative((offset > 0) ? BlockFace.UP : BlockFace.DOWN, Math.abs(offset));
|
if(offset != 0)
|
||||||
|
worldBlock = worldBlock.getRelative((offset > 0) ? BlockFace.UP : BlockFace.DOWN, Math.abs(offset));
|
||||||
|
|
||||||
if(data instanceof Rotatable) {
|
if(data instanceof Rotatable) {
|
||||||
BlockFace rt = getRotatedFace(((Rotatable) data).getRotation(), r);
|
BlockFace rt = getRotatedFace(((Rotatable) data).getRotation(), r);
|
||||||
@@ -247,6 +251,7 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a Consumer for all blocks in a cuboid region defined by 3 Ranges, accounting for rotation.
|
* Execute a Consumer for all blocks in a cuboid region defined by 3 Ranges, accounting for rotation.
|
||||||
|
*
|
||||||
* @param xM X Range
|
* @param xM X Range
|
||||||
* @param yM Y Range
|
* @param yM Y Range
|
||||||
* @param zM Z Range
|
* @param zM Z Range
|
||||||
@@ -270,6 +275,7 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether a set of coordinates is within the current structure
|
* Test whether a set of coordinates is within the current structure
|
||||||
|
*
|
||||||
* @param x X coordinate
|
* @param x X coordinate
|
||||||
* @param y Y coordinate
|
* @param y Y coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
@@ -281,6 +287,7 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* From an origin location (First bound) fetch the second bound.
|
* From an origin location (First bound) fetch the second bound.
|
||||||
|
*
|
||||||
* @param origin Origin location
|
* @param origin Origin location
|
||||||
* @return Other bound location
|
* @return Other bound location
|
||||||
*/
|
*/
|
||||||
@@ -290,6 +297,7 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the structure to a file
|
* Save the structure to a file
|
||||||
|
*
|
||||||
* @param f File to save to
|
* @param f File to save to
|
||||||
* @throws IOException If file access error occurs
|
* @throws IOException If file access error occurs
|
||||||
*/
|
*/
|
||||||
@@ -299,6 +307,7 @@ public class Structure implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a structure from a file.
|
* Load a structure from a file.
|
||||||
|
*
|
||||||
* @param f File to load from
|
* @param f File to load from
|
||||||
* @return The structure loaded
|
* @return The structure loaded
|
||||||
* @throws IOException If file access error occurs
|
* @throws IOException If file access error occurs
|
||||||
@@ -345,8 +354,10 @@ public class Structure implements Serializable {
|
|||||||
Vector2 min = getRotatedCoords(new Vector2(x.getMin(), z.getMin()).subtract(center), r.inverse()).add(center);
|
Vector2 min = getRotatedCoords(new Vector2(x.getMin(), z.getMin()).subtract(center), r.inverse()).add(center);
|
||||||
Vector2 max = getRotatedCoords(new Vector2(x.getMax(), z.getMax()).subtract(center), r.inverse()).add(center);
|
Vector2 max = getRotatedCoords(new Vector2(x.getMax(), z.getMax()).subtract(center), r.inverse()).add(center);
|
||||||
|
|
||||||
if(a.equals(Axis.X)) return new Range((int) Math.floor(Math.min(min.getX(), max.getX())), (int) Math.ceil(Math.max(min.getX(), max.getX())) + 1);
|
if(a.equals(Axis.X))
|
||||||
else return new Range((int) Math.floor(Math.min(min.getZ(), max.getZ())), (int) Math.ceil(Math.max(min.getZ(), max.getZ())) + 1);
|
return new Range((int) Math.floor(Math.min(min.getX(), max.getX())), (int) Math.ceil(Math.max(min.getX(), max.getX())) + 1);
|
||||||
|
else
|
||||||
|
return new Range((int) Math.floor(Math.min(min.getZ(), max.getZ())), (int) Math.ceil(Math.max(min.getZ(), max.getZ())) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -358,16 +369,19 @@ public class Structure implements Serializable {
|
|||||||
return new Range(0, structureInfo.getSizeY());
|
return new Range(0, structureInfo.getSizeY());
|
||||||
case Z:
|
case Z:
|
||||||
return new Range(0, structureInfo.getSizeZ());
|
return new Range(0, structureInfo.getSizeZ());
|
||||||
default: throw new IllegalArgumentException();
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Axis {
|
public enum Axis {
|
||||||
X, Y, Z
|
X, Y, Z
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Rotation {
|
public enum Rotation {
|
||||||
CW_90(90), CW_180(180), CCW_90(270), NONE(0);
|
CW_90(90), CW_180(180), CCW_90(270), NONE(0);
|
||||||
private final int degrees;
|
private final int degrees;
|
||||||
|
|
||||||
Rotation(int degrees) {
|
Rotation(int degrees) {
|
||||||
this.degrees = degrees;
|
this.degrees = degrees;
|
||||||
}
|
}
|
||||||
@@ -375,22 +389,34 @@ public class Structure implements Serializable {
|
|||||||
public int getDegrees() {
|
public int getDegrees() {
|
||||||
return degrees;
|
return degrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Rotation fromDegrees(int deg) {
|
public static Rotation fromDegrees(int deg) {
|
||||||
switch(Math.floorMod(deg, 360)) {
|
switch(Math.floorMod(deg, 360)) {
|
||||||
case 0: return Rotation.NONE;
|
case 0:
|
||||||
case 90: return Rotation.CW_90;
|
return Rotation.NONE;
|
||||||
case 180: return Rotation.CW_180;
|
case 90:
|
||||||
case 270: return Rotation.CCW_90;
|
return Rotation.CW_90;
|
||||||
default: throw new IllegalArgumentException();
|
case 180:
|
||||||
|
return Rotation.CW_180;
|
||||||
|
case 270:
|
||||||
|
return Rotation.CCW_90;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rotation inverse() {
|
public Rotation inverse() {
|
||||||
switch(this) {
|
switch(this) {
|
||||||
case NONE: return NONE;
|
case NONE:
|
||||||
case CCW_90: return CW_90;
|
return NONE;
|
||||||
case CW_90: return CCW_90;
|
case CCW_90:
|
||||||
case CW_180: return CW_180;
|
return CW_90;
|
||||||
default: throw new IllegalArgumentException();
|
case CW_90:
|
||||||
|
return CCW_90;
|
||||||
|
case CW_180:
|
||||||
|
return CW_180;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class StructureContainedBlock implements Serializable {
|
|||||||
private final int z;
|
private final int z;
|
||||||
private final SerializableBlockState state;
|
private final SerializableBlockState state;
|
||||||
private final StructureSpawnRequirement requirement;
|
private final StructureSpawnRequirement requirement;
|
||||||
|
|
||||||
public StructureContainedBlock(int x, int y, int z, BlockState state, BlockData d, StructureSpawnRequirement spawn, Pull pull, int pullOffset) {
|
public StructureContainedBlock(int x, int y, int z, BlockState state, BlockData d, StructureSpawnRequirement spawn, Pull pull, int pullOffset) {
|
||||||
if(state instanceof Sign) {
|
if(state instanceof Sign) {
|
||||||
Debug.info("Sign at (" + x + ", " + y + ", " + z + ").");
|
Debug.info("Sign at (" + x + ", " + y + ", " + z + ").");
|
||||||
@@ -44,6 +45,7 @@ public class StructureContainedBlock implements Serializable {
|
|||||||
this.pull = pull;
|
this.pull = pull;
|
||||||
this.pullOffset = pullOffset;
|
this.pullOffset = pullOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StructureContainedBlock(int x, int y, int z, SerializableBlockState state, BlockData d, StructureSpawnRequirement spawn, Pull pull, int pullOffset) {
|
public StructureContainedBlock(int x, int y, int z, SerializableBlockState state, BlockData d, StructureSpawnRequirement spawn, Pull pull, int pullOffset) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class StructureContainedInventory implements Serializable {
|
|||||||
public static final long serialVersionUID = - 175339605585943678L;
|
public static final long serialVersionUID = - 175339605585943678L;
|
||||||
private final int uid;
|
private final int uid;
|
||||||
private final int x, y, z;
|
private final int x, y, z;
|
||||||
|
|
||||||
public StructureContainedInventory(Inventory orig, StructureContainedBlock link) {
|
public StructureContainedInventory(Inventory orig, StructureContainedBlock link) {
|
||||||
ItemStack stack = orig.getItem(0);
|
ItemStack stack = orig.getItem(0);
|
||||||
x = link.getX();
|
x = link.getX();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.structure;
|
package com.dfsek.terra.structure;
|
||||||
|
|
||||||
import com.dfsek.terra.procgen.math.Vector2;
|
import com.dfsek.terra.procgen.math.Vector2;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@@ -12,6 +11,7 @@ public class StructureInfo implements Serializable {
|
|||||||
private final int sizeZ;
|
private final int sizeZ;
|
||||||
private final int centerX;
|
private final int centerX;
|
||||||
private final int centerZ;
|
private final int centerZ;
|
||||||
|
|
||||||
public StructureInfo(int sizeX, int sizeY, int sizeZ, Vector2 center) {
|
public StructureInfo(int sizeX, int sizeY, int sizeZ, Vector2 center) {
|
||||||
this.sizeX = sizeX;
|
this.sizeX = sizeX;
|
||||||
this.sizeY = sizeY;
|
this.sizeY = sizeY;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.dfsek.terra.structure;
|
|||||||
import com.dfsek.terra.TerraWorld;
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.polydev.gaea.generation.GenerationPhase;
|
import org.polydev.gaea.generation.GenerationPhase;
|
||||||
import org.polydev.gaea.math.FastNoiseLite;
|
import org.polydev.gaea.math.FastNoiseLite;
|
||||||
@@ -43,10 +42,13 @@ public enum StructureSpawnRequirement implements Serializable {
|
|||||||
};
|
};
|
||||||
private static final long serialVersionUID = - 175639605885943679L;
|
private static final long serialVersionUID = - 175639605885943679L;
|
||||||
private static final transient Map<World, FastNoiseLite> noiseMap = new HashMap<>();
|
private static final transient Map<World, FastNoiseLite> noiseMap = new HashMap<>();
|
||||||
|
|
||||||
public abstract boolean matches(World w, int x, int y, int z);
|
public abstract boolean matches(World w, int x, int y, int z);
|
||||||
|
|
||||||
public static void putNoise(World w, FastNoiseLite noise) {
|
public static void putNoise(World w, FastNoiseLite noise) {
|
||||||
noiseMap.putIfAbsent(w, noise);
|
noiseMap.putIfAbsent(w, noise);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FastNoiseLite getNoise(World w) {
|
private static FastNoiseLite getNoise(World w) {
|
||||||
return noiseMap.get(w);
|
return noiseMap.get(w);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ import java.io.Serializable;
|
|||||||
public class SerializableBlockData implements Serializable {
|
public class SerializableBlockData implements Serializable {
|
||||||
public static final long serialVersionUID = 5298928608478640008L;
|
public static final long serialVersionUID = 5298928608478640008L;
|
||||||
private final String data;
|
private final String data;
|
||||||
|
|
||||||
public SerializableBlockData(BlockData d) {
|
public SerializableBlockData(BlockData d) {
|
||||||
this.data = d.getAsString(false);
|
this.data = d.getAsString(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getData() {
|
public BlockData getData() {
|
||||||
return Bukkit.createBlockData(data);
|
return Bukkit.createBlockData(data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package com.dfsek.terra.structure.serialize.block;
|
|||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.block.Banner;
|
import org.bukkit.block.Banner;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.block.banner.Pattern;
|
|
||||||
import org.bukkit.block.banner.PatternType;
|
import org.bukkit.block.banner.PatternType;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -32,9 +30,11 @@ public class SerializableBanner implements SerializableBlockState {
|
|||||||
}
|
}
|
||||||
return banner;
|
return banner;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Pattern implements Serializable {
|
private static final class Pattern implements Serializable {
|
||||||
private final DyeColor color;
|
private final DyeColor color;
|
||||||
private final PatternType type;
|
private final PatternType type;
|
||||||
|
|
||||||
public Pattern(PatternType type, DyeColor color) {
|
public Pattern(PatternType type, DyeColor color) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|||||||
@@ -6,5 +6,6 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
public interface SerializableBlockState extends Serializable {
|
public interface SerializableBlockState extends Serializable {
|
||||||
long serialVersionUID = 5298928608478640000L;
|
long serialVersionUID = 5298928608478640000L;
|
||||||
|
|
||||||
BlockState getState(BlockState orig);
|
BlockState getState(BlockState orig);
|
||||||
}
|
}
|
||||||
+4
-4
@@ -3,9 +3,6 @@ package com.dfsek.terra.structure.serialize.block;
|
|||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.CreatureSpawner;
|
import org.bukkit.block.CreatureSpawner;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.polydev.gaea.math.Range;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class SerializableMonsterCage implements SerializableBlockState {
|
public class SerializableMonsterCage implements SerializableBlockState {
|
||||||
public static final long serialVersionUID = 529892860847864007L;
|
public static final long serialVersionUID = 529892860847864007L;
|
||||||
@@ -16,6 +13,7 @@ public class SerializableMonsterCage implements SerializableBlockState {
|
|||||||
private final int playerRange;
|
private final int playerRange;
|
||||||
private final int delay;
|
private final int delay;
|
||||||
private final int count;
|
private final int count;
|
||||||
|
|
||||||
public SerializableMonsterCage(CreatureSpawner orig) {
|
public SerializableMonsterCage(CreatureSpawner orig) {
|
||||||
this.type = orig.getSpawnedType();
|
this.type = orig.getSpawnedType();
|
||||||
this.minDelay = orig.getMinSpawnDelay();
|
this.minDelay = orig.getMinSpawnDelay();
|
||||||
@@ -25,9 +23,11 @@ public class SerializableMonsterCage implements SerializableBlockState {
|
|||||||
this.delay = orig.getDelay();
|
this.delay = orig.getDelay();
|
||||||
this.count = orig.getSpawnCount();
|
this.count = orig.getSpawnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getState(BlockState orig) {
|
public BlockState getState(BlockState orig) {
|
||||||
if(!(orig instanceof CreatureSpawner)) throw new IllegalArgumentException("BlockState is not a Monster Spawner!");
|
if(! (orig instanceof CreatureSpawner))
|
||||||
|
throw new IllegalArgumentException("BlockState is not a Monster Spawner!");
|
||||||
CreatureSpawner spawner = (CreatureSpawner) orig;
|
CreatureSpawner spawner = (CreatureSpawner) orig;
|
||||||
spawner.setSpawnedType(type);
|
spawner.setSpawnedType(type);
|
||||||
spawner.setMinSpawnDelay(minDelay);
|
spawner.setMinSpawnDelay(minDelay);
|
||||||
|
|||||||
@@ -7,10 +7,12 @@ public class SerializableSign implements SerializableBlockState {
|
|||||||
public static final long serialVersionUID = 5298928608478640001L;
|
public static final long serialVersionUID = 5298928608478640001L;
|
||||||
private final String[] text;
|
private final String[] text;
|
||||||
private final boolean isEditable;
|
private final boolean isEditable;
|
||||||
|
|
||||||
public SerializableSign(Sign orig) {
|
public SerializableSign(Sign orig) {
|
||||||
text = orig.getLines();
|
text = orig.getLines();
|
||||||
this.isEditable = orig.isEditable();
|
this.isEditable = orig.isEditable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getState(BlockState orig) {
|
public BlockState getState(BlockState orig) {
|
||||||
if(! (orig instanceof Sign)) throw new IllegalArgumentException("Provided BlockState is not a sign.");
|
if(! (orig instanceof Sign)) throw new IllegalArgumentException("Provided BlockState is not a sign.");
|
||||||
@@ -25,6 +27,7 @@ public class SerializableSign implements SerializableBlockState {
|
|||||||
public String[] getLines() {
|
public String[] getLines() {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLine(int index) {
|
public String getLine(int index) {
|
||||||
return text[index];
|
return text[index];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public enum StructureTypeEnum {
|
|||||||
NETHER_FOSSIL(StructureType.NETHER_FOSSIL),
|
NETHER_FOSSIL(StructureType.NETHER_FOSSIL),
|
||||||
RUINED_PORTAL(StructureType.RUINED_PORTAL),
|
RUINED_PORTAL(StructureType.RUINED_PORTAL),
|
||||||
BASTION_REMNANT(StructureType.BASTION_REMNANT);
|
BASTION_REMNANT(StructureType.BASTION_REMNANT);
|
||||||
|
|
||||||
StructureTypeEnum(StructureType type) {
|
StructureTypeEnum(StructureType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.bukkit.block.data.Rail;
|
|||||||
public final class RotationUtil {
|
public final class RotationUtil {
|
||||||
/**
|
/**
|
||||||
* Rotate and mirror a coordinate pair.
|
* Rotate and mirror a coordinate pair.
|
||||||
|
*
|
||||||
* @param orig Vector to rotate.
|
* @param orig Vector to rotate.
|
||||||
* @param r Rotation
|
* @param r Rotation
|
||||||
* @return Rotated coordinate pair
|
* @return Rotated coordinate pair
|
||||||
@@ -30,6 +31,7 @@ public final class RotationUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the BlockFace with rotation and mirrors applied to it
|
* Get the BlockFace with rotation and mirrors applied to it
|
||||||
|
*
|
||||||
* @param f BlockFace to apply rotation to
|
* @param f BlockFace to apply rotation to
|
||||||
* @param r Rotation
|
* @param r Rotation
|
||||||
* @return Rotated BlockFace
|
* @return Rotated BlockFace
|
||||||
@@ -61,6 +63,7 @@ public final class RotationUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to rotate the incredibly obnoxious Rail.Shape enum
|
* Method to rotate the incredibly obnoxious Rail.Shape enum
|
||||||
|
*
|
||||||
* @param orig Original shape
|
* @param orig Original shape
|
||||||
* @param r Rotate
|
* @param r Rotate
|
||||||
* @return Rotated/mirrored shape
|
* @return Rotated/mirrored shape
|
||||||
@@ -69,42 +72,72 @@ public final class RotationUtil {
|
|||||||
switch(r) {
|
switch(r) {
|
||||||
case CCW_90:
|
case CCW_90:
|
||||||
switch(orig) {
|
switch(orig) {
|
||||||
case NORTH_WEST: return Rail.Shape.SOUTH_WEST;
|
case NORTH_WEST:
|
||||||
case NORTH_SOUTH: return Rail.Shape.EAST_WEST;
|
return Rail.Shape.SOUTH_WEST;
|
||||||
case SOUTH_WEST: return Rail.Shape.SOUTH_EAST;
|
case NORTH_SOUTH:
|
||||||
case SOUTH_EAST: return Rail.Shape.NORTH_EAST;
|
return Rail.Shape.EAST_WEST;
|
||||||
case EAST_WEST: return Rail.Shape.NORTH_SOUTH;
|
case SOUTH_WEST:
|
||||||
case NORTH_EAST: return Rail.Shape.NORTH_WEST;
|
return Rail.Shape.SOUTH_EAST;
|
||||||
case ASCENDING_EAST: return Rail.Shape.ASCENDING_NORTH;
|
case SOUTH_EAST:
|
||||||
case ASCENDING_WEST: return Rail.Shape.ASCENDING_SOUTH;
|
return Rail.Shape.NORTH_EAST;
|
||||||
case ASCENDING_NORTH: return Rail.Shape.ASCENDING_WEST;
|
case EAST_WEST:
|
||||||
case ASCENDING_SOUTH: return Rail.Shape.ASCENDING_EAST;
|
return Rail.Shape.NORTH_SOUTH;
|
||||||
|
case NORTH_EAST:
|
||||||
|
return Rail.Shape.NORTH_WEST;
|
||||||
|
case ASCENDING_EAST:
|
||||||
|
return Rail.Shape.ASCENDING_NORTH;
|
||||||
|
case ASCENDING_WEST:
|
||||||
|
return Rail.Shape.ASCENDING_SOUTH;
|
||||||
|
case ASCENDING_NORTH:
|
||||||
|
return Rail.Shape.ASCENDING_WEST;
|
||||||
|
case ASCENDING_SOUTH:
|
||||||
|
return Rail.Shape.ASCENDING_EAST;
|
||||||
}
|
}
|
||||||
case CW_90:
|
case CW_90:
|
||||||
switch(orig) {
|
switch(orig) {
|
||||||
case NORTH_WEST: return Rail.Shape.NORTH_EAST;
|
case NORTH_WEST:
|
||||||
case NORTH_SOUTH: return Rail.Shape.EAST_WEST;
|
return Rail.Shape.NORTH_EAST;
|
||||||
case SOUTH_WEST: return Rail.Shape.NORTH_WEST;
|
case NORTH_SOUTH:
|
||||||
case SOUTH_EAST: return Rail.Shape.SOUTH_WEST;
|
return Rail.Shape.EAST_WEST;
|
||||||
case EAST_WEST: return Rail.Shape.NORTH_SOUTH;
|
case SOUTH_WEST:
|
||||||
case NORTH_EAST: return Rail.Shape.SOUTH_EAST;
|
return Rail.Shape.NORTH_WEST;
|
||||||
case ASCENDING_EAST: return Rail.Shape.ASCENDING_SOUTH;
|
case SOUTH_EAST:
|
||||||
case ASCENDING_WEST: return Rail.Shape.ASCENDING_NORTH;
|
return Rail.Shape.SOUTH_WEST;
|
||||||
case ASCENDING_NORTH: return Rail.Shape.ASCENDING_EAST;
|
case EAST_WEST:
|
||||||
case ASCENDING_SOUTH: return Rail.Shape.ASCENDING_WEST;
|
return Rail.Shape.NORTH_SOUTH;
|
||||||
|
case NORTH_EAST:
|
||||||
|
return Rail.Shape.SOUTH_EAST;
|
||||||
|
case ASCENDING_EAST:
|
||||||
|
return Rail.Shape.ASCENDING_SOUTH;
|
||||||
|
case ASCENDING_WEST:
|
||||||
|
return Rail.Shape.ASCENDING_NORTH;
|
||||||
|
case ASCENDING_NORTH:
|
||||||
|
return Rail.Shape.ASCENDING_EAST;
|
||||||
|
case ASCENDING_SOUTH:
|
||||||
|
return Rail.Shape.ASCENDING_WEST;
|
||||||
}
|
}
|
||||||
case CW_180:
|
case CW_180:
|
||||||
switch(orig) {
|
switch(orig) {
|
||||||
case NORTH_WEST: return Rail.Shape.SOUTH_EAST;
|
case NORTH_WEST:
|
||||||
case NORTH_SOUTH: return Rail.Shape.NORTH_SOUTH;
|
return Rail.Shape.SOUTH_EAST;
|
||||||
case SOUTH_WEST: return Rail.Shape.NORTH_EAST;
|
case NORTH_SOUTH:
|
||||||
case SOUTH_EAST: return Rail.Shape.NORTH_WEST;
|
return Rail.Shape.NORTH_SOUTH;
|
||||||
case EAST_WEST: return Rail.Shape.EAST_WEST;
|
case SOUTH_WEST:
|
||||||
case NORTH_EAST: return Rail.Shape.SOUTH_WEST;
|
return Rail.Shape.NORTH_EAST;
|
||||||
case ASCENDING_EAST: return Rail.Shape.ASCENDING_WEST;
|
case SOUTH_EAST:
|
||||||
case ASCENDING_WEST: return Rail.Shape.ASCENDING_EAST;
|
return Rail.Shape.NORTH_WEST;
|
||||||
case ASCENDING_NORTH: return Rail.Shape.ASCENDING_SOUTH;
|
case EAST_WEST:
|
||||||
case ASCENDING_SOUTH: return Rail.Shape.ASCENDING_NORTH;
|
return Rail.Shape.EAST_WEST;
|
||||||
|
case NORTH_EAST:
|
||||||
|
return Rail.Shape.SOUTH_WEST;
|
||||||
|
case ASCENDING_EAST:
|
||||||
|
return Rail.Shape.ASCENDING_WEST;
|
||||||
|
case ASCENDING_WEST:
|
||||||
|
return Rail.Shape.ASCENDING_EAST;
|
||||||
|
case ASCENDING_NORTH:
|
||||||
|
return Rail.Shape.ASCENDING_SOUTH;
|
||||||
|
case ASCENDING_SOUTH:
|
||||||
|
return Rail.Shape.ASCENDING_NORTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return orig;
|
return orig;
|
||||||
@@ -112,55 +145,91 @@ public final class RotationUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an integer representation of a BlockFace, to perform math on.
|
* Get an integer representation of a BlockFace, to perform math on.
|
||||||
|
*
|
||||||
* @param f BlockFace to get integer for
|
* @param f BlockFace to get integer for
|
||||||
* @return integer representation of BlockFace
|
* @return integer representation of BlockFace
|
||||||
*/
|
*/
|
||||||
public static int faceRotation(BlockFace f) {
|
public static int faceRotation(BlockFace f) {
|
||||||
switch(f) {
|
switch(f) {
|
||||||
case NORTH: return 0;
|
case NORTH:
|
||||||
case NORTH_NORTH_EAST: return 1;
|
return 0;
|
||||||
case NORTH_EAST: return 2;
|
case NORTH_NORTH_EAST:
|
||||||
case EAST_NORTH_EAST: return 3;
|
return 1;
|
||||||
case EAST: return 4;
|
case NORTH_EAST:
|
||||||
case EAST_SOUTH_EAST: return 5;
|
return 2;
|
||||||
case SOUTH_EAST: return 6;
|
case EAST_NORTH_EAST:
|
||||||
case SOUTH_SOUTH_EAST: return 7;
|
return 3;
|
||||||
case SOUTH: return 8;
|
case EAST:
|
||||||
case SOUTH_SOUTH_WEST: return 9;
|
return 4;
|
||||||
case SOUTH_WEST: return 10;
|
case EAST_SOUTH_EAST:
|
||||||
case WEST_SOUTH_WEST: return 11;
|
return 5;
|
||||||
case WEST: return 12;
|
case SOUTH_EAST:
|
||||||
case WEST_NORTH_WEST: return 13;
|
return 6;
|
||||||
case NORTH_WEST: return 14;
|
case SOUTH_SOUTH_EAST:
|
||||||
case NORTH_NORTH_WEST: return 15;
|
return 7;
|
||||||
default: return -1;
|
case SOUTH:
|
||||||
|
return 8;
|
||||||
|
case SOUTH_SOUTH_WEST:
|
||||||
|
return 9;
|
||||||
|
case SOUTH_WEST:
|
||||||
|
return 10;
|
||||||
|
case WEST_SOUTH_WEST:
|
||||||
|
return 11;
|
||||||
|
case WEST:
|
||||||
|
return 12;
|
||||||
|
case WEST_NORTH_WEST:
|
||||||
|
return 13;
|
||||||
|
case NORTH_WEST:
|
||||||
|
return 14;
|
||||||
|
case NORTH_NORTH_WEST:
|
||||||
|
return 15;
|
||||||
|
default:
|
||||||
|
return - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert integer to BlockFace representation
|
* Convert integer to BlockFace representation
|
||||||
|
*
|
||||||
* @param r integer to get BlockFace for
|
* @param r integer to get BlockFace for
|
||||||
* @return BlockFace represented by integer.
|
* @return BlockFace represented by integer.
|
||||||
*/
|
*/
|
||||||
public static BlockFace fromRotation(int r) {
|
public static BlockFace fromRotation(int r) {
|
||||||
switch(Math.floorMod(r, 16)) {
|
switch(Math.floorMod(r, 16)) {
|
||||||
case 0: return BlockFace.NORTH;
|
case 0:
|
||||||
case 1: return BlockFace.NORTH_NORTH_EAST;
|
return BlockFace.NORTH;
|
||||||
case 2: return BlockFace.NORTH_EAST;
|
case 1:
|
||||||
case 3: return BlockFace.EAST_NORTH_EAST;
|
return BlockFace.NORTH_NORTH_EAST;
|
||||||
case 4: return BlockFace.EAST;
|
case 2:
|
||||||
case 5: return BlockFace.EAST_SOUTH_EAST;
|
return BlockFace.NORTH_EAST;
|
||||||
case 6: return BlockFace.SOUTH_EAST;
|
case 3:
|
||||||
case 7: return BlockFace.SOUTH_SOUTH_EAST;
|
return BlockFace.EAST_NORTH_EAST;
|
||||||
case 8: return BlockFace.SOUTH;
|
case 4:
|
||||||
case 9: return BlockFace.SOUTH_SOUTH_WEST;
|
return BlockFace.EAST;
|
||||||
case 10: return BlockFace.SOUTH_WEST;
|
case 5:
|
||||||
case 11: return BlockFace.WEST_SOUTH_WEST;
|
return BlockFace.EAST_SOUTH_EAST;
|
||||||
case 12: return BlockFace.WEST;
|
case 6:
|
||||||
case 13: return BlockFace.WEST_NORTH_WEST;
|
return BlockFace.SOUTH_EAST;
|
||||||
case 14: return BlockFace.NORTH_WEST;
|
case 7:
|
||||||
case 15: return BlockFace.NORTH_NORTH_WEST;
|
return BlockFace.SOUTH_SOUTH_EAST;
|
||||||
default: throw new IllegalArgumentException();
|
case 8:
|
||||||
|
return BlockFace.SOUTH;
|
||||||
|
case 9:
|
||||||
|
return BlockFace.SOUTH_SOUTH_WEST;
|
||||||
|
case 10:
|
||||||
|
return BlockFace.SOUTH_WEST;
|
||||||
|
case 11:
|
||||||
|
return BlockFace.WEST_SOUTH_WEST;
|
||||||
|
case 12:
|
||||||
|
return BlockFace.WEST;
|
||||||
|
case 13:
|
||||||
|
return BlockFace.WEST_NORTH_WEST;
|
||||||
|
case 14:
|
||||||
|
return BlockFace.NORTH_WEST;
|
||||||
|
case 15:
|
||||||
|
return BlockFace.NORTH_NORTH_WEST;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,7 @@ public final class WorldEditUtil {
|
|||||||
Bukkit.getLogger().severe("[Terra] a command requiring WorldEdit was executed, but WorldEdit was not detected!");
|
Bukkit.getLogger().severe("[Terra] a command requiring WorldEdit was executed, but WorldEdit was not detected!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location[] getSelectionLocations(Player sender) {
|
public static Location[] getSelectionLocations(Player sender) {
|
||||||
WorldEditPlugin we = WorldEditUtil.getWorldEdit();
|
WorldEditPlugin we = WorldEditUtil.getWorldEdit();
|
||||||
if(we == null) {
|
if(we == null) {
|
||||||
@@ -41,6 +42,7 @@ public final class WorldEditUtil {
|
|||||||
Location l2 = new Location(sender.getWorld(), max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
Location l2 = new Location(sender.getWorld(), max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
||||||
return new Location[] {l1, l2};
|
return new Location[] {l1, l2};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location[] getSelectionPositions(Player sender) {
|
public static Location[] getSelectionPositions(Player sender) {
|
||||||
WorldEditPlugin we = WorldEditUtil.getWorldEdit();
|
WorldEditPlugin we = WorldEditUtil.getWorldEdit();
|
||||||
if(we == null) {
|
if(we == null) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: Terra
|
name: Terra
|
||||||
depend: [ "Gaea" ]
|
depend: [ "Gaea" ]
|
||||||
main: com.dfsek.terra.Terra
|
main: com.dfsek.terra.Terra
|
||||||
version: 1.0.1-BETA
|
version: 1.0.2-BETA
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
api-version: "1.16"
|
api-version: "1.16"
|
||||||
softdepend: [ "WorldEdit" ]
|
softdepend: [ "WorldEdit" ]
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import org.polydev.gaea.biome.NormalizationUtil;
|
|
||||||
import org.polydev.gaea.math.FastNoiseLite;
|
import org.polydev.gaea.math.FastNoiseLite;
|
||||||
|
|
||||||
public class DistributionTest {
|
public class DistributionTest {
|
||||||
private static final double[] normalMap = new double[] {- 0.8408907651901245D, - 0.8200346231460571D, - 0.8070776462554932D, - 0.7970088720321655D, - 0.7890776991844177D, - 0.7819743156433105D, - 0.7759857773780823D, - 0.7706204056739807D, - 0.765608549118042D, - 0.7611993551254272D, - 0.7569039463996887D, - 0.7528656125068665D, - 0.7492497563362122D, - 0.7458332777023315D, - 0.7424643039703369D, - 0.7392163872718811D, - 0.736059844493866D, - 0.7332375049591064D, - 0.7305010557174683D, - 0.7277776598930359D, - 0.7251102924346924D, - 0.7227165699005127D, - 0.7203239798545837D, - 0.7179931998252869D, - 0.7157421112060547D, - 0.7135322690010071D, - 0.71131432056427D, - 0.7092097997665405D, - 0.7071162462234497D, - 0.7050217390060425D, - 0.703119695186615D, - 0.7011850476264954D, - 0.6992706060409546D, - 0.6974170207977295D, - 0.6955324411392212D, - 0.6937324404716492D, - 0.6919872760772705D, - 0.690233588218689D, - 0.6885692477226257D, - 0.6869722008705139D, - 0.6852975487709045D, - 0.683682382106781D, - 0.6821723580360413D, - 0.6806833744049072D, - 0.679179310798645D, - 0.6776503324508667D, - 0.676136314868927D, - 0.6746450662612915D, - 0.6731522083282471D, - 0.6717588305473328D, - 0.6702994704246521D, - 0.6689524054527283D, - 0.6675862073898315D, - 0.6662633419036865D, - 0.6649606823921204D, - 0.6636543273925781D, - 0.6623714566230774D, - 0.6610865592956543D, - 0.6598274111747742D, - 0.6585804224014282D, - 0.6573819518089294D, - 0.6561920642852783D, - 0.6549379825592041D, - 0.6537073254585266D, - 0.6525376439094543D, - 0.6513495445251465D, - 0.650168240070343D, - 0.649040162563324D, - 0.6479091048240662D, - 0.6467820405960083D, - 0.6456737518310547D, - 0.6445609331130981D, - 0.6434952020645142D, - 0.6424031257629395D, - 0.6413089632987976D, - 0.640256941318512D, - 0.6391684412956238D, - 0.638137936592102D, - 0.6371254324913025D, - 0.6361099481582642D, - 0.6350630521774292D, - 0.6339953541755676D, - 0.6330388188362122D, - 0.632024347782135D, - 0.6310704946517944D, - 0.6300620436668396D, - 0.6290494799613953D, - 0.6280747056007385D, - 0.6271024346351624D, - 0.6261362433433533D, - 0.6251688599586487D, - 0.6242944002151489D, - 0.6233505606651306D, - 0.622406542301178D, - 0.6214921474456787D, - 0.6205630302429199D, - 0.619683563709259D, - 0.6187522411346436D, - 0.6178513169288635D, - 0.6170046925544739D, - 0.6161392331123352D, - 0.615269660949707D, - 0.6144152879714966D, - 0.6135557293891907D, - 0.6127009391784668D, - 0.6117991209030151D, - 0.6109536290168762D, - 0.6101033091545105D, - 0.6092590689659119D, - 0.6084139347076416D, - 0.6075553894042969D, - 0.6067432165145874D, - 0.6058894991874695D, - 0.6050370335578918D, - 0.6042441725730896D, - 0.6034530401229858D, - 0.6026210784912109D, - 0.6018084287643433D, - 0.6010326743125916D, - 0.6002528071403503D, - 0.5994450449943542D, - 0.5986629128456116D, - 0.5978666543960571D, - 0.5971032977104187D, - 0.5963031649589539D, - 0.5955566167831421D, - 0.5947844982147217D, - 0.5940142869949341D, - 0.5932715535163879D, - 0.5925368666648865D, - 0.5917928218841553D, - 0.591031014919281D, - 0.5903055667877197D, - 0.5895851850509644D, - 0.5888315439224243D, - 0.5880893468856812D, - 0.5873630046844482D, - 0.5866444110870361D, - 0.5859208106994629D, - 0.5852057933807373D, - 0.5844889879226685D, - 0.5837893486022949D, - 0.5830587148666382D, - 0.582359254360199D, - 0.5816157460212708D, - 0.5809139013290405D, - 0.5802302956581116D, - 0.5795474052429199D, - 0.5788565874099731D, - 0.5781614184379578D, - 0.5774743556976318D, - 0.5767905712127686D, - 0.5760961771011353D, - 0.5754467248916626D, - 0.5747898817062378D, - 0.5741211175918579D, - 0.5734619498252869D, - 0.5728112459182739D, - 0.5721414089202881D, - 0.5714717507362366D, - 0.5708272457122803D, - 0.5701769590377808D, - 0.5695428252220154D, - 0.568885087966919D, - 0.5682525038719177D, - 0.5675948262214661D, - 0.5669249296188354D, - 0.5663014054298401D, - 0.5656630992889404D, - 0.5650165677070618D, - 0.5643728971481323D, - 0.5637710094451904D, - 0.5631371736526489D, - 0.562507152557373D, - 0.5618733167648315D, - 0.5612503290176392D, - 0.560631513595581D, - 0.5600159168243408D, - 0.559416651725769D, - 0.5587995052337646D, - 0.5581864714622498D, - 0.5575871467590332D, - 0.556957483291626D, - 0.5563494563102722D, - 0.555757999420166D, - 0.5551457405090332D, - 0.5545571446418762D, - 0.5539442300796509D, - 0.5533522367477417D, - 0.5527352094650269D, - 0.5521476864814758D, - 0.5515644550323486D, - 0.5509964823722839D, - 0.550428032875061D, - 0.5498668551445007D, - 0.5492658615112305D, - 0.5486577749252319D, - 0.5480945110321045D, - 0.5475296378135681D, - 0.5469772815704346D, - 0.5463858246803284D, - 0.5458088517189026D, - 0.545259952545166D, - 0.5447098016738892D, - 0.5441542863845825D, - 0.5436179041862488D, - 0.5430275201797485D, - 0.5424584746360779D, - 0.5419116616249084D, - 0.5413541197776794D, - 0.5408090353012085D, - 0.5402546525001526D, - 0.5396901369094849D, - 0.539120078086853D, - 0.5385692715644836D, - 0.5380025506019592D,Line truncated
|
private static final double[] normalMap = new double[] {- 0.8408907651901245D, - 0.8200346231460571D, - 0.8070776462554932D, - 0.7970088720321655D, - 0.7890776991844177D, - 0.7819743156433105D, - 0.7759857773780823D, - 0.7706204056739807D, - 0.765608549118042D, - 0.7611993551254272D, - 0.7569039463996887D, - 0.7528656125068665D, - 0.7492497563362122D, - 0.7458332777023315D, - 0.7424643039703369D, - 0.7392163872718811D, - 0.736059844493866D, - 0.7332375049591064D, - 0.7305010557174683D, - 0.7277776598930359D, - 0.7251102924346924D, - 0.7227165699005127D, - 0.7203239798545837D, - 0.7179931998252869D, - 0.7157421112060547D, - 0.7135322690010071D, - 0.71131432056427D, - 0.7092097997665405D, - 0.7071162462234497D, - 0.7050217390060425D, - 0.703119695186615D, - 0.7011850476264954D, - 0.6992706060409546D, - 0.6974170207977295D, - 0.6955324411392212D, - 0.6937324404716492D, - 0.6919872760772705D, - 0.690233588218689D, - 0.6885692477226257D, - 0.6869722008705139D, - 0.6852975487709045D, - 0.683682382106781D, - 0.6821723580360413D, - 0.6806833744049072D, - 0.679179310798645D, - 0.6776503324508667D, - 0.676136314868927D, - 0.6746450662612915D, - 0.6731522083282471D, - 0.6717588305473328D, - 0.6702994704246521D, - 0.6689524054527283D, - 0.6675862073898315D, - 0.6662633419036865D, - 0.6649606823921204D, - 0.6636543273925781D, - 0.6623714566230774D, - 0.6610865592956543D, - 0.6598274111747742D, - 0.6585804224014282D, - 0.6573819518089294D, - 0.6561920642852783D, - 0.6549379825592041D, - 0.6537073254585266D, - 0.6525376439094543D, - 0.6513495445251465D, - 0.650168240070343D, - 0.649040162563324D, - 0.6479091048240662D, - 0.6467820405960083D, - 0.6456737518310547D, - 0.6445609331130981D, - 0.6434952020645142D, - 0.6424031257629395D, - 0.6413089632987976D, - 0.640256941318512D, - 0.6391684412956238D, - 0.638137936592102D, - 0.6371254324913025D, - 0.6361099481582642D, - 0.6350630521774292D, - 0.6339953541755676D, - 0.6330388188362122D, - 0.632024347782135D, - 0.6310704946517944D, - 0.6300620436668396D, - 0.6290494799613953D, - 0.6280747056007385D, - 0.6271024346351624D, - 0.6261362433433533D, - 0.6251688599586487D, - 0.6242944002151489D, - 0.6233505606651306D, - 0.622406542301178D, - 0.6214921474456787D, - 0.6205630302429199D, - 0.619683563709259D, - 0.6187522411346436D, - 0.6178513169288635D, - 0.6170046925544739D, - 0.6161392331123352D, - 0.615269660949707D, - 0.6144152879714966D, - 0.6135557293891907D, - 0.6127009391784668D, - 0.6117991209030151D, - 0.6109536290168762D, - 0.6101033091545105D, - 0.6092590689659119D, - 0.6084139347076416D, - 0.6075553894042969D, - 0.6067432165145874D, - 0.6058894991874695D, - 0.6050370335578918D, - 0.6042441725730896D, - 0.6034530401229858D, - 0.6026210784912109D, - 0.6018084287643433D, - 0.6010326743125916D, - 0.6002528071403503D, - 0.5994450449943542D, - 0.5986629128456116D, - 0.5978666543960571D, - 0.5971032977104187D, - 0.5963031649589539D, - 0.5955566167831421D, - 0.5947844982147217D, - 0.5940142869949341D, - 0.5932715535163879D, - 0.5925368666648865D, - 0.5917928218841553D, - 0.591031014919281D, - 0.5903055667877197D, - 0.5895851850509644D, - 0.5888315439224243D, - 0.5880893468856812D, - 0.5873630046844482D, - 0.5866444110870361D, - 0.5859208106994629D, - 0.5852057933807373D, - 0.5844889879226685D, - 0.5837893486022949D, - 0.5830587148666382D, - 0.582359254360199D, - 0.5816157460212708D, - 0.5809139013290405D, - 0.5802302956581116D, - 0.5795474052429199D, - 0.5788565874099731D, - 0.5781614184379578D, - 0.5774743556976318D, - 0.5767905712127686D, - 0.5760961771011353D, - 0.5754467248916626D, - 0.5747898817062378D, - 0.5741211175918579D, - 0.5734619498252869D, - 0.5728112459182739D, - 0.5721414089202881D, - 0.5714717507362366D, - 0.5708272457122803D, - 0.5701769590377808D, - 0.5695428252220154D, - 0.568885087966919D, - 0.5682525038719177D, - 0.5675948262214661D, - 0.5669249296188354D, - 0.5663014054298401D, - 0.5656630992889404D, - 0.5650165677070618D, - 0.5643728971481323D, - 0.5637710094451904D, - 0.5631371736526489D, - 0.562507152557373D, - 0.5618733167648315D, - 0.5612503290176392D, - 0.560631513595581D, - 0.5600159168243408D, - 0.559416651725769D, - 0.5587995052337646D, - 0.5581864714622498D, - 0.5575871467590332D, - 0.556957483291626D, - 0.5563494563102722D, - 0.555757999420166D, - 0.5551457405090332D, - 0.5545571446418762D, - 0.5539442300796509D, - 0.5533522367477417D, - 0.5527352094650269D, - 0.5521476864814758D, - 0.5515644550323486D, - 0.5509964823722839D, - 0.550428032875061D, - 0.5498668551445007D, - 0.5492658615112305D, - 0.5486577749252319D, - 0.5480945110321045D, - 0.5475296378135681D, - 0.5469772815704346D, - 0.5463858246803284D, - 0.5458088517189026D, - 0.545259952545166D, - 0.5447098016738892D, - 0.5441542863845825D, - 0.5436179041862488D, - 0.5430275201797485D, - 0.5424584746360779D, - 0.5419116616249084D, - 0.5413541197776794D, - 0.5408090353012085D, - 0.5402546525001526D, - 0.5396901369094849D, - 0.539120078086853D, - 0.5385692715644836D, - 0.5380025506019592D,Line truncated
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
FastNoiseLite noise = new FastNoiseLite();
|
FastNoiseLite noise = new FastNoiseLite();
|
||||||
@@ -20,7 +18,6 @@ public class DistributionTest {
|
|||||||
double max = Integer.MIN_VALUE;
|
double max = Integer.MIN_VALUE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < attempts; i++) {
|
for(int i = 0; i < attempts; i++) {
|
||||||
numbers[i] = 0;
|
numbers[i] = 0;
|
||||||
}
|
}
|
||||||
@@ -57,10 +54,12 @@ public class DistributionTest {
|
|||||||
System.out.println("max: " + max);
|
System.out.println("max: " + max);
|
||||||
System.out.println("min: " + min);
|
System.out.println("min: " + min);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int normal(double d, int max) {
|
public static int normal(double d, int max) {
|
||||||
double ranged = Math.max(0, Math.min((d + 1) / 2D, 1));
|
double ranged = Math.max(0, Math.min((d + 1) / 2D, 1));
|
||||||
return (int) (ranged * max);
|
return (int) (ranged * max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int normalize(double d, int num) {
|
public static int normalize(double d, int num) {
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int end = normalMap.length - 1;
|
int end = normalMap.length - 1;
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import com.dfsek.terra.biome.BiomeZone;
|
|
||||||
import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
|
||||||
import org.polydev.gaea.math.FastNoiseLite;
|
import org.polydev.gaea.math.FastNoiseLite;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class LookupGenerator {
|
public class LookupGenerator {
|
||||||
private static double[] lookup;
|
private static double[] lookup;
|
||||||
@@ -91,6 +88,7 @@ public class LookupGenerator {
|
|||||||
System.out.println(s.toString());
|
System.out.println(s.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int normalize(double i, int n) {
|
public static int normalize(double i, int n) {
|
||||||
i *= 1.42; // Magic simplex value (sqrt(2) plus a little)
|
i *= 1.42; // Magic simplex value (sqrt(2) plus a little)
|
||||||
i = Math.min(Math.max(i, - 1), 1);
|
i = Math.min(Math.max(i, - 1), 1);
|
||||||
@@ -108,6 +106,7 @@ public class LookupGenerator {
|
|||||||
private final List<Double> l;
|
private final List<Double> l;
|
||||||
private final int searches;
|
private final int searches;
|
||||||
private final FastNoiseLite noise;
|
private final FastNoiseLite noise;
|
||||||
|
|
||||||
public Worker(List<Double> l, int searches, FastNoiseLite noise) {
|
public Worker(List<Double> l, int searches, FastNoiseLite noise) {
|
||||||
this.l = l;
|
this.l = l;
|
||||||
this.searches = searches;
|
this.searches = searches;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import org.polydev.gaea.math.Range;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.polydev.gaea.math.Range;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ public class RangeTest {
|
|||||||
}
|
}
|
||||||
assertEquals(100, i);
|
assertEquals(100, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void intersect() {
|
public void intersect() {
|
||||||
Range one = new Range(10, 100);
|
Range one = new Range(10, 100);
|
||||||
@@ -26,6 +28,7 @@ public class RangeTest {
|
|||||||
one = new Range(25, 50);
|
one = new Range(25, 50);
|
||||||
assertNull(one.intersects(two));
|
assertNull(one.intersects(two));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void reflect() {
|
public void reflect() {
|
||||||
Range t = new Range(3, 10);
|
Range t = new Range(3, 10);
|
||||||
|
|||||||
Reference in new issue
Block a user