mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Biome Systems
This commit is contained in:
parent
152b1bd24e
commit
7e9cea94f3
@ -10,6 +10,9 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
|
||||
public class CommandIris implements CommandExecutor
|
||||
{
|
||||
public void msg(CommandSender s, String msg)
|
||||
@ -22,12 +25,74 @@ public class CommandIris implements CommandExecutor
|
||||
{
|
||||
if(args.length == 0)
|
||||
{
|
||||
msg(sender, "/iris rtp [biome] - RTP to a biome");
|
||||
msg(sender, "/iris gen - Gen a new Iris World");
|
||||
msg(sender, "/ish - Iris Schematic Commands");
|
||||
}
|
||||
|
||||
if(args.length > 0)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("rtp"))
|
||||
{
|
||||
if(sender instanceof Player)
|
||||
{
|
||||
Player p = (Player) sender;
|
||||
World w = p.getWorld();
|
||||
|
||||
if(w.getGenerator() instanceof IrisGenerator)
|
||||
{
|
||||
if(args.length > 1)
|
||||
{
|
||||
IrisGenerator g = (IrisGenerator) w.getGenerator();
|
||||
IrisBiome b = null;
|
||||
for(IrisBiome i : IrisBiome.getBiomes())
|
||||
{
|
||||
if(args[1].toLowerCase().equals(i.getName().toLowerCase().replaceAll("\\Q \\E", "_")))
|
||||
{
|
||||
b = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(b == null)
|
||||
{
|
||||
msg(sender, "Unknown Biome: " + args[1]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
msg(sender, "Looking for " + b.getName() + "...");
|
||||
boolean f = false;
|
||||
for(int i = 0; i < 10000; i++)
|
||||
{
|
||||
int x = (int) ((int) (29999983 / 1.2) * Math.random());
|
||||
int z = (int) ((int) (29999983 / 1.2) * Math.random());
|
||||
|
||||
if(g.getBiome(x, z).equals(b))
|
||||
{
|
||||
f = true;
|
||||
p.teleport(w.getHighestBlockAt(x, z).getLocation());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!f)
|
||||
{
|
||||
msg(sender, "Looked for " + b.getName() + " in 10,000 different locations and could not find it. Try again!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int x = (int) ((int) (29999983 / 1.2) * Math.random());
|
||||
int z = (int) ((int) (29999983 / 1.2) * Math.random());
|
||||
p.teleport(w.getHighestBlockAt(x, z).getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("gen"))
|
||||
{
|
||||
if(sender instanceof Player)
|
||||
|
@ -1,5 +1,7 @@
|
||||
package ninja.bytecode.iris;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ -18,12 +20,20 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.schematic.Schematic;
|
||||
import ninja.bytecode.iris.schematic.SchematicGroup;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.spec.IrisDimension;
|
||||
import ninja.bytecode.iris.spec.IrisPack;
|
||||
import ninja.bytecode.iris.util.Direction;
|
||||
import ninja.bytecode.shuriken.bench.Profiler;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.collections.GSet;
|
||||
import ninja.bytecode.shuriken.execution.TaskExecutor;
|
||||
import ninja.bytecode.shuriken.io.IO;
|
||||
import ninja.bytecode.shuriken.json.JSONException;
|
||||
import ninja.bytecode.shuriken.json.JSONObject;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
|
||||
public class Iris extends JavaPlugin implements Listener
|
||||
{
|
||||
@ -34,14 +44,21 @@ public class Iris extends JavaPlugin implements Listener
|
||||
public static Settings settings;
|
||||
public static Iris instance;
|
||||
public static GMap<String, GMap<String, Function<Vector, Double>>> values;
|
||||
public static GMap<String, IrisDimension> dimensions;
|
||||
public static GMap<String, IrisBiome> biomes;
|
||||
public static GMap<String, SchematicGroup> schematics;
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
Direction.calculatePermutations();
|
||||
dimensions = new GMap<>();
|
||||
biomes = new GMap<>();
|
||||
schematics = new GMap<>();
|
||||
profiler = new Profiler(512);
|
||||
values = new GMap<>();
|
||||
instance = this;
|
||||
settings = new Settings();
|
||||
loadContent();
|
||||
gen = new IrisGenerator();
|
||||
genPool = new TaskExecutor(getTC(), settings.performance.threadPriority, "Iris Generator");
|
||||
getServer().getPluginManager().registerEvents((Listener) this, this);
|
||||
@ -70,20 +87,27 @@ public class Iris extends JavaPlugin implements Listener
|
||||
Bukkit.unloadWorld(i, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
|
||||
for(World i : Bukkit.getWorlds())
|
||||
private void loadContent()
|
||||
{
|
||||
if(i.getGenerator() instanceof IrisGenerator)
|
||||
L.i("Loading Content");
|
||||
|
||||
try
|
||||
{
|
||||
for(Player j : i.getPlayers())
|
||||
IrisPack master = new IrisPack(loadJSON("pack/manifest.json"));
|
||||
master.load();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
IrisBiome biome = IrisBiome.findByBiome(j.getLocation().getBlock().getBiome());
|
||||
biome.applyEffects(j);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, 15);
|
||||
|
||||
L.i("Dimensions: " + dimensions.size());
|
||||
L.i("Biomes: " + biomes.size());
|
||||
L.i("Schematic Groups: " + schematics.size());
|
||||
L.flush();
|
||||
}
|
||||
|
||||
private int getTC()
|
||||
@ -138,4 +162,32 @@ public class Iris extends JavaPlugin implements Listener
|
||||
|
||||
values.get(w).put(t, d);
|
||||
}
|
||||
|
||||
public static IrisDimension loadDimension(String s) throws JSONException, IOException
|
||||
{
|
||||
L.i("Loading Iris Dimension " + s);
|
||||
return new IrisDimension(loadJSON("pack/dimensions/" + s + ".json"));
|
||||
}
|
||||
|
||||
public static IrisBiome loadBiome(String s) throws JSONException, IOException
|
||||
{
|
||||
L.i("Loading Iris Biome " + s);
|
||||
return new IrisBiome(loadJSON("pack/biomes/" + s + ".json"));
|
||||
}
|
||||
|
||||
public static Schematic loadSchematic(String s) throws IOException
|
||||
{
|
||||
L.i("Loading Iris Object " + s);
|
||||
return Schematic.load(loadResource("pack/objects/" + s + ".ish"));
|
||||
}
|
||||
|
||||
public static JSONObject loadJSON(String s) throws JSONException, IOException
|
||||
{
|
||||
return new JSONObject(IO.readAll(loadResource(s)));
|
||||
}
|
||||
|
||||
public static InputStream loadResource(String string)
|
||||
{
|
||||
return Iris.class.getResourceAsStream("/" + string);
|
||||
}
|
||||
}
|
||||
|
@ -12,22 +12,25 @@ public class Settings
|
||||
public PerformanceMode performanceMode = PerformanceMode.UNLIMITED;
|
||||
public int threadCount = 12;
|
||||
public int threadPriority = Thread.MAX_PRIORITY;
|
||||
public boolean loadonstart = false;
|
||||
public boolean loadonstart = true;
|
||||
}
|
||||
|
||||
public static class GeneratorSettings
|
||||
{
|
||||
public double horizontalZoom = 0.525; // 0.525
|
||||
public double horizontalZoom = 1; // 0.525
|
||||
public double heightFracture = 155;
|
||||
public double landScale = 0.125;
|
||||
public double landChance = 0.529;
|
||||
public double roughness = 1.333;
|
||||
public double heightMultiplier = 0.806;
|
||||
public double heightExponentBase = 1;
|
||||
public double heightExponentMultiplier = 1.41;
|
||||
public double heightScale = 1;
|
||||
public double heightScale = 0.56;
|
||||
public double superHeightScale = 0.95;
|
||||
public double baseHeight = 0.165;
|
||||
public int seaLevel = 63;
|
||||
public double caveDensity = 1;
|
||||
public double biomeScale = 2.46;
|
||||
public double biomeScale = 2.5;
|
||||
public boolean flatBedrock = false;
|
||||
public boolean doSchematics = true;
|
||||
}
|
||||
|
@ -5,15 +5,12 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerBase;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerBiome;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerCaves;
|
||||
@ -28,6 +25,8 @@ import ninja.bytecode.iris.generator.layer.GenLayerRidge;
|
||||
import ninja.bytecode.iris.generator.populator.BiomeBiasSchematicPopulator;
|
||||
import ninja.bytecode.iris.schematic.Schematic;
|
||||
import ninja.bytecode.iris.schematic.SchematicGroup;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.spec.IrisDimension;
|
||||
import ninja.bytecode.iris.util.AtomicChunkData;
|
||||
import ninja.bytecode.iris.util.ChunkPlan;
|
||||
import ninja.bytecode.iris.util.IrisInterpolation;
|
||||
@ -75,9 +74,21 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
private GenLayerOreEmerald glOreEmerald;
|
||||
private GenLayerOreDiamond glOreDiamond;
|
||||
private RNG rTerrain;
|
||||
private IrisDimension dim;
|
||||
private World world;
|
||||
private GMap<String, SchematicGroup> schematicCache = new GMap<>();
|
||||
|
||||
public IrisGenerator()
|
||||
{
|
||||
this(Iris.dimensions.get("overworld"));
|
||||
}
|
||||
|
||||
public IrisGenerator(IrisDimension dim)
|
||||
{
|
||||
this.dim = dim;
|
||||
L.i("Preparing Dimension: " + dim.getName() + " With " + dim.getBiomes().size() + " Biomes...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit(World world, Random random)
|
||||
{
|
||||
@ -86,7 +97,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
glBase = new GenLayerBase(this, world, random, rTerrain.nextParallelRNG(1));
|
||||
glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2));
|
||||
glRidge = new GenLayerRidge(this, world, random, rTerrain.nextParallelRNG(3));
|
||||
glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4));
|
||||
glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes());
|
||||
glCaves = new GenLayerCaves(this, world, random, rTerrain.nextParallelRNG(-1));
|
||||
glOreIron = new GenLayerOreIron(this, world, random, rTerrain.nextParallelRNG(-500), 10);
|
||||
glOreLapis = new GenLayerOreLapis(this, world, random, rTerrain.nextParallelRNG(-501), 15);
|
||||
@ -102,20 +113,55 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
return new ChunkPlan();
|
||||
}
|
||||
|
||||
public IrisBiome getBiome(int wxx, int wzx)
|
||||
{
|
||||
double wx = Math.round((double) wxx * Iris.settings.gen.horizontalZoom);
|
||||
double wz = Math.round((double) wzx * Iris.settings.gen.horizontalZoom);
|
||||
return glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan)
|
||||
{
|
||||
int seaLevel = Iris.settings.gen.seaLevel;
|
||||
double wx = Math.round((double) wxx * Iris.settings.gen.horizontalZoom);
|
||||
double wz = Math.round((double) wzx * Iris.settings.gen.horizontalZoom);
|
||||
IrisBiome biome = glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
|
||||
IrisBiome biome = getBiome(wxx, wzx);
|
||||
double hv = IrisInterpolation.getBicubicNoise(wxx, wzx, (xf, zf) -> getBiomedHeight((int) Math.round(xf), (int) Math.round(zf), plan));
|
||||
hv += glLNoise.generateLayer(hv, wxx, wzx);
|
||||
hv += glLNoise.generateLayer(hv * Iris.settings.gen.roughness * 215, wxx * Iris.settings.gen.roughness * 0.82, wzx * Iris.settings.gen.roughness * 0.82) * (1.6918 * (hv * 2.35));
|
||||
hv -= glRidge.generateLayer(hv, wxx, wzx);
|
||||
int height = (int) Math.round(M.clip(hv, 0D, 1D) * 253);
|
||||
int max = Math.max(height, seaLevel);
|
||||
IrisBiome override = null;
|
||||
|
||||
if(height > 61 && height < 65)
|
||||
{
|
||||
override = IrisBiome.BEACH;
|
||||
}
|
||||
|
||||
else if(height < 63)
|
||||
{
|
||||
if(height < 36)
|
||||
{
|
||||
override = IrisBiome.DEEP_OCEAN;
|
||||
}
|
||||
|
||||
else if(height < 50)
|
||||
{
|
||||
override = IrisBiome.OCEAN;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
override = IrisBiome.LAKE;
|
||||
}
|
||||
}
|
||||
|
||||
if(override != null)
|
||||
{
|
||||
biome = override;
|
||||
}
|
||||
|
||||
for(int i = 0; i < max; i++)
|
||||
{
|
||||
MB mb = ROCK.get(glBase.scatterInt(wzx, i, wxx, ROCK.size()));
|
||||
@ -134,34 +180,6 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
|
||||
if(i == height - 1)
|
||||
{
|
||||
if(height > 61 && height < glBase.scatterInt(x, i, z, 4) + 65)
|
||||
{
|
||||
override = IrisBiome.BEACH;
|
||||
}
|
||||
|
||||
else if(height < 63)
|
||||
{
|
||||
if(i < 36)
|
||||
{
|
||||
override = IrisBiome.DEEP_OCEAN;
|
||||
}
|
||||
|
||||
else if(i < 50)
|
||||
{
|
||||
override = IrisBiome.OCEAN;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
override = IrisBiome.LAKE;
|
||||
}
|
||||
}
|
||||
|
||||
if(override != null)
|
||||
{
|
||||
biome = override;
|
||||
}
|
||||
|
||||
mb = biome.getSurface(wx, wz, rTerrain);
|
||||
MB mbx = biome.getScatterChanceSingle();
|
||||
|
||||
@ -192,11 +210,6 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
glOreEmerald.genOre(wxx, wzx, x, z, height, this, biome);
|
||||
glOreDiamond.genOre(wxx, wzx, x, z, height, this, biome);
|
||||
|
||||
if(override != null)
|
||||
{
|
||||
return override.getRealBiome();
|
||||
}
|
||||
|
||||
return biome.getRealBiome();
|
||||
}
|
||||
|
||||
@ -221,7 +234,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
int b = 0;
|
||||
int sch = 0;
|
||||
for(IrisBiome i : IrisBiome.getAllBiomes())
|
||||
for(IrisBiome i : IrisBiome.getAllBiomes().copy().add(dim.getBiomes()))
|
||||
{
|
||||
b++;
|
||||
L.i("Processing Populators for Biome " + i.getName());
|
||||
@ -319,7 +332,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
int wz = (int) Math.round((double) z * Iris.settings.gen.horizontalZoom);
|
||||
IrisBiome biome = glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
|
||||
double h = Iris.settings.gen.baseHeight + biome.getHeight();
|
||||
h += (glBase.getHeight(wx, wz) * biome.getAmp()) - (0.33 * biome.getAmp());
|
||||
h += (glBase.getHeight(wx, wz) * 0.5) - (0.33 * 0.5);
|
||||
|
||||
return h;
|
||||
});
|
||||
|
@ -1,566 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.biome;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.PolygonGenerator;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class IrisBiome
|
||||
{
|
||||
//@builder
|
||||
public static final IrisBiome RIVER = new IrisBiome("River", Biome.RIVER)
|
||||
.surface(MB.of(Material.SAND));
|
||||
public static final IrisBiome BEACH = new IrisBiome("Beach", Biome.BEACHES)
|
||||
.surface(MB.of(Material.SAND))
|
||||
.schematic("boulder/sandy", 0.009)
|
||||
.height(0.12)
|
||||
.schematic("tree/palm", 0.83);
|
||||
public static final IrisBiome ROAD_GRAVEL = new IrisBiome("Gravel Road", Biome.PLAINS)
|
||||
.surface(MB.of(Material.GRAVEL), MB.of(Material.COBBLESTONE))
|
||||
.schematic("boulder/smooth", 0.001)
|
||||
.scatter(MB.of(Material.TORCH), 0.05);
|
||||
public static final IrisBiome ROAD_GRASSY = new IrisBiome("Grass Path", Biome.PLAINS)
|
||||
.surface(MB.of(Material.GRASS_PATH))
|
||||
.scatter(MB.of(Material.TORCH), 0.05);
|
||||
public static final IrisBiome OCEAN = new IrisBiome("Ocean", Biome.OCEAN)
|
||||
.surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
|
||||
.simplexSurface()
|
||||
.height(-0.03);
|
||||
public static final IrisBiome LAKE = new IrisBiome("Lake", Biome.OCEAN)
|
||||
.surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.GRAVEL), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
|
||||
.simplexSurface()
|
||||
.height(-0.03);
|
||||
public static final IrisBiome DEEP_OCEAN = new IrisBiome("Deep Ocean", Biome.DEEP_OCEAN)
|
||||
.surface(MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
|
||||
.simplexSurface()
|
||||
.height(-0.07);
|
||||
public static final IrisBiome DESERT = new IrisBiome("Desert", Biome.DESERT)
|
||||
.surface(MB.of(Material.SAND))
|
||||
.schematic("boulder/sandy", 0.023)
|
||||
.schematic("tree/deadwood", 0.03)
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.008)
|
||||
.dirt(MB.of(Material.SANDSTONE));
|
||||
public static final IrisBiome DESERT_RED = new IrisBiome("Red Desert", Biome.DESERT)
|
||||
.surface(MB.of(Material.SAND, 1))
|
||||
.schematic("tree/deadwood", 0.045)
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.008)
|
||||
.dirt(MB.of(Material.RED_SANDSTONE));
|
||||
public static final IrisBiome DESERT_COMBINED = new IrisBiome("Combined Desert", Biome.DESERT)
|
||||
.surface(MB.of(Material.SAND), MB.of(Material.SAND, 1))
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.008)
|
||||
.schematic("tree/deadwood", 0.0443)
|
||||
.dirt(MB.of(Material.SANDSTONE), MB.of(Material.RED_SANDSTONE))
|
||||
.simplexSurface();
|
||||
public static final IrisBiome DESERT_HILLS = new IrisBiome("Desert Hills", Biome.DESERT_HILLS)
|
||||
.surface(MB.of(Material.SAND))
|
||||
.amp(0.75)
|
||||
.height(0.137)
|
||||
.schematic("tree/deadwood", 0.03)
|
||||
.schematic("boulder/sandy", 0.015)
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.08)
|
||||
.dirt(MB.of(Material.SANDSTONE));
|
||||
public static final IrisBiome MESA = new IrisBiome("Mesa", Biome.MESA)
|
||||
.surface(MB.of(Material.HARD_CLAY), MB.of(Material.STAINED_CLAY, 1), MB.of(Material.STAINED_CLAY, 8), MB.of(Material.STAINED_CLAY, 12))
|
||||
.dirt(MB.of(Material.CLAY), MB.of(Material.SAND), MB.of(Material.SAND, 1))
|
||||
.schematic("boulder/sandy", 0.02)
|
||||
.simplexSurface();
|
||||
public static final IrisBiome SAVANNA = new IrisBiome("Savanna", Biome.SAVANNA)
|
||||
.schematic("tree/deadwood", 0.03)
|
||||
.schematic("boulder/sandy", 0.02)
|
||||
.schematic("boulder", 0.02)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.18);
|
||||
public static final IrisBiome SAVANNA_HILLS = new IrisBiome("Savanna Hills", Biome.SAVANNA_ROCK)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.18)
|
||||
.schematic("tree/deadwood", 0.01)
|
||||
.schematic("boulder", 0.02)
|
||||
.schematic("boulder/sandy", 0.02)
|
||||
.height(0.13)
|
||||
.amp(0.75);
|
||||
public static final IrisBiome JUNGLE = new IrisBiome("Jungle", Biome.JUNGLE)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.058)
|
||||
.schematic("boulder/smooth", 0.02)
|
||||
.schematic("tree/oak/massive", 0.045)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.013);
|
||||
public static final IrisBiome JUNGLE_HILLS = new IrisBiome("Jungle Hills", Biome.JUNGLE_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.081)
|
||||
.schematic("boulder/smooth", 0.02)
|
||||
.schematic("tree/oak/massive", 0.045)
|
||||
.amp(1.75)
|
||||
.height(0.13)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.02);
|
||||
public static final IrisBiome SWAMP = new IrisBiome("Swamp", Biome.SWAMPLAND)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.04)
|
||||
.schematic("tree/willow", 2.5)
|
||||
.schematic("tree/god/willow", 0.01)
|
||||
.schematic("boulder", 0.02)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.03);
|
||||
public static final IrisBiome PLAINS = new IrisBiome("Plains", Biome.PLAINS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.38)
|
||||
.schematic("tree/oak/bush", 0.25)
|
||||
.schematic("boulder", 0.02)
|
||||
.amp(0.4)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.03);
|
||||
public static final IrisBiome DECAYING_PLAINS = new IrisBiome("Decaying Plains", Biome.PLAINS)
|
||||
.surface(MB.of(Material.GRASS_PATH), MB.of(Material.GRASS))
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.04)
|
||||
.schematic("tree/deadwood", 0.03)
|
||||
.schematic("boulder/sandy", 0.01)
|
||||
.simplexSurface();
|
||||
public static final IrisBiome FOREST = new IrisBiome("Forest", Biome.FOREST)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.schematic("tree/oak", 2.31)
|
||||
.schematic("boulder", 0.02)
|
||||
.schematic("boulder/smooth", 0.01)
|
||||
.schematic("tree/oak/cracked", 0.03)
|
||||
.schematic("tree/oak/large", 1.41)
|
||||
.schematic("tree/oak/massive", 0.045)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final IrisBiome FOREST_HILLS = new IrisBiome("Forest Hills", Biome.FOREST_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.schematic("tree/oak", 2.31)
|
||||
.schematic("boulder", 0.02)
|
||||
.schematic("boulder/smooth", 0.01)
|
||||
.schematic("tree/oak/cracked", 0.03)
|
||||
.schematic("tree/oak/massive", 0.045)
|
||||
.schematic("tree/oak/large", 0.31)
|
||||
.amp(0.75)
|
||||
.height(0.13)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final IrisBiome FOREST_MOUNTAINS = new IrisBiome("Forest Mountains", Biome.MUTATED_EXTREME_HILLS_WITH_TREES)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.13)
|
||||
.amp(2.25)
|
||||
.schematic("tree/pine", 2.31)
|
||||
.schematic("boulder", 0.04)
|
||||
.schematic("boulder/smooth", 0.01)
|
||||
.schematic("tree/redwood", 1.11)
|
||||
.schematic("tree/redwood/tall", 2.51)
|
||||
.height(0.365)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final IrisBiome HAUNTED_FOREST = new IrisBiome("Haunted Forest", Biome.MUTATED_SWAMPLAND)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.13)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13)
|
||||
.schematic("tree/willow", 1.21)
|
||||
.schematic("tree/god/willow", 0.04)
|
||||
.schematic("tree/oak", 0.71)
|
||||
.schematic("boulder", 0.01)
|
||||
.schematic("boulder/smooth", 0.02)
|
||||
.schematic("tree/oak/cracked", 0.03)
|
||||
.schematic("tree/oak/massive", 0.4)
|
||||
.schematic("tree/oak/bush", 1.83)
|
||||
.schematic("structure/magical", 0.002)
|
||||
.addEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 100, 0))
|
||||
.addEffect(new PotionEffect(PotionEffectType.SLOW, 100, 0))
|
||||
.addEffect(new PotionEffect(PotionEffectType.HUNGER, 100, 0))
|
||||
.surface(MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.SOUL_SAND), MB.of(Material.DIRT), MB.of(Material.DIRT, 1), MB.of(Material.DIRT, 2))
|
||||
.scatterSurface();
|
||||
public static final IrisBiome BIRCH_FOREST = new IrisBiome("Birch Forest", Biome.BIRCH_FOREST)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.schematic("tree/birch", 2.51)
|
||||
.schematic("boulder", 0.02)
|
||||
.schematic("boulder/smooth", 0.01)
|
||||
.schematic("tree/birch/small", 3.25)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final IrisBiome BIRCH_FOREST_HILLS = new IrisBiome("Birch Forest Hills", Biome.BIRCH_FOREST_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.schematic("tree/birch", 2.51)
|
||||
.schematic("boulder/smooth", 0.01)
|
||||
.schematic("boulder", 0.02)
|
||||
.schematic("tree/birch/small", 3.25)
|
||||
.amp(0.75)
|
||||
.height(0.13)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final IrisBiome ROOFED_FOREST = new IrisBiome("Roofed Forest", Biome.ROOFED_FOREST)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.schematic("boulder", 0.02)
|
||||
.schematic("tree/oak/massive", 0.02)
|
||||
.schematic("tree/oak/roofed", 0.78)
|
||||
.schematic("boulder/smooth", 0.01)
|
||||
.schematic("structure/magical", 0.009)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final IrisBiome TAIGA = new IrisBiome("Taiga", Biome.TAIGA)
|
||||
.schematic("tree/pine/cracked", 0.03)
|
||||
.schematic("tree/pine", 2.51)
|
||||
.schematic("boulder", 0.02)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.07);
|
||||
public static final IrisBiome EXTREME_HILLS = new IrisBiome("Extreme Hills", Biome.EXTREME_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.04)
|
||||
.amp(1.565)
|
||||
.schematic("boulder/smooth", 0.01)
|
||||
.height(0.342);
|
||||
public static final IrisBiome EXTREME_HILLS_TREES = new IrisBiome("Extreme Hills +", Biome.EXTREME_HILLS_WITH_TREES)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.09)
|
||||
.schematic("boulder", 0.02)
|
||||
.schematic("tree/pine", 1.02)
|
||||
.schematic("boulder/smooth", 0.01)
|
||||
.schematic("tree/redwood/tall", 3.02)
|
||||
.amp(1.525)
|
||||
.height(0.352);
|
||||
public static final IrisBiome TAIGA_COLD = new IrisBiome("Taiga Cold", Biome.TAIGA_COLD)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.04)
|
||||
.schematic("tree/pine", 2.51)
|
||||
.schematic("boulder/snowy", 0.02)
|
||||
.schematic("tree/pine/cracked", 0.03);
|
||||
public static final IrisBiome TAIGA_COLD_HILLS = new IrisBiome("Taiga Cold Hills", Biome.TAIGA_COLD_HILLS)
|
||||
.schematic("tree/pine", 2.51)
|
||||
.schematic("boulder/snowy", 0.02)
|
||||
.schematic("tree/pine/cracked", 0.03);
|
||||
public static final IrisBiome ICE_FLATS = new IrisBiome("Ice Flats", Biome.ICE_FLATS)
|
||||
.schematic("boulder/snowy", 0.03);
|
||||
public static final IrisBiome ICE_MOUNTAINS = new IrisBiome("Ice Mountains", Biome.ICE_MOUNTAINS)
|
||||
.schematic("boulder/snowy", 0.03)
|
||||
.amp(1.45);
|
||||
public static final IrisBiome REDWOOD_TAIGA = new IrisBiome("Redwood Taiga", Biome.REDWOOD_TAIGA)
|
||||
.surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
|
||||
.schematic("tree/redwood/large", 0.87)
|
||||
.schematic("tree/redwood/massive", 0.2)
|
||||
.schematic("tree/pine/cracked", 0.03)
|
||||
.schematic("boulder", 0.02)
|
||||
.schematic("tree/redwood", 3.5)
|
||||
.simplexSurface();
|
||||
public static final IrisBiome REDWOOD_TAIGA_HILLS = new IrisBiome("Redwood Taiga Hills", Biome.REDWOOD_TAIGA_HILLS)
|
||||
.surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
|
||||
.schematic("tree/redwood/large", 0.87)
|
||||
.schematic("tree/pine/cracked", 0.03)
|
||||
.schematic("boulder", 0.02)
|
||||
.schematic("tree/redwood", 3.5)
|
||||
.amp(0.75)
|
||||
.height(0.167)
|
||||
.simplexSurface();
|
||||
|
||||
//@done
|
||||
private static final GMap<Biome, IrisBiome> map = build();
|
||||
private String name;
|
||||
private Biome realBiome;
|
||||
private double height;
|
||||
private double amp;
|
||||
private GList<PotionEffect> effects;
|
||||
private GList<MB> surface;
|
||||
private GList<MB> dirt;
|
||||
private GMap<MB, Double> scatterChance;
|
||||
private boolean scatterSurface;
|
||||
private boolean simplexScatter;
|
||||
private GMap<String, Double> schematicGroups;
|
||||
private PolygonGenerator.EnumPolygonGenerator<MB> poly;
|
||||
|
||||
public IrisBiome(String name, Biome realBiome)
|
||||
{
|
||||
this.name = name;
|
||||
effects = new GList<>();
|
||||
this.realBiome = realBiome;
|
||||
this.height = 0.125;
|
||||
this.amp = 0.5;
|
||||
scatterChance = new GMap<>();
|
||||
schematicGroups = new GMap<>();
|
||||
surface(new MB(Material.GRASS)).dirt(new MB(Material.DIRT), new MB(Material.DIRT, 1));
|
||||
}
|
||||
|
||||
private static GMap<Biome, IrisBiome> build()
|
||||
{
|
||||
GMap<Biome, IrisBiome> g = new GMap<Biome, IrisBiome>();
|
||||
|
||||
for(Field i : IrisBiome.class.getDeclaredFields())
|
||||
{
|
||||
J.attempt(() ->
|
||||
{
|
||||
i.setAccessible(true);
|
||||
|
||||
IrisBiome bb = (IrisBiome) i.get(null);
|
||||
|
||||
if(!g.containsKey(bb.realBiome))
|
||||
{
|
||||
g.put(bb.realBiome, bb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
public IrisBiome scatter(MB mb, Double chance)
|
||||
{
|
||||
scatterChance.put(mb, chance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome schematic(String t, double chance)
|
||||
{
|
||||
schematicGroups.put(t, chance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome simplexSurface()
|
||||
{
|
||||
simplexScatter = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome scatterSurface()
|
||||
{
|
||||
scatterSurface = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome surface(MB... mbs)
|
||||
{
|
||||
surface = new GList<>(mbs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome dirt(MB... mbs)
|
||||
{
|
||||
dirt = new GList<>(mbs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome height(double height)
|
||||
{
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome amp(double amp)
|
||||
{
|
||||
this.amp = amp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public Biome getRealBiome()
|
||||
{
|
||||
return realBiome;
|
||||
}
|
||||
|
||||
public double getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public double getAmp()
|
||||
{
|
||||
return amp;
|
||||
}
|
||||
|
||||
public GList<MB> getSurface()
|
||||
{
|
||||
return surface;
|
||||
}
|
||||
|
||||
public GList<MB> getDirt()
|
||||
{
|
||||
return dirt;
|
||||
}
|
||||
|
||||
public MB getSurface(double x, double z, RNG rng)
|
||||
{
|
||||
double wx = x + 1000D;
|
||||
double wz = z + 1000D;
|
||||
if(simplexScatter)
|
||||
{
|
||||
if(poly == null)
|
||||
{
|
||||
poly = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 0.25, 2, getSurface().toArray(new MB[getSurface().size()]), (g) ->
|
||||
{
|
||||
return g.fractureWith(new CNG(rng.nextParallelRNG(56), 1D, 2).scale(0.0155), 242);
|
||||
});
|
||||
}
|
||||
|
||||
return poly.getChoice(wx * 0.2D, wz * 0.2D);
|
||||
}
|
||||
|
||||
if(scatterSurface)
|
||||
{
|
||||
if(poly == null)
|
||||
{
|
||||
poly = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 15.05, 2, getSurface().toArray(new MB[getSurface().size()]), (g) ->
|
||||
{
|
||||
return g.fractureWith(new CNG(rng.nextParallelRNG(55), 1D, 2).scale(0.0155), 224);
|
||||
});
|
||||
}
|
||||
|
||||
return poly.getChoice(wx * 0.2D, wz * 0.2D);
|
||||
}
|
||||
|
||||
return getSurface().getRandom();
|
||||
}
|
||||
|
||||
public MB getDirtRNG()
|
||||
{
|
||||
return getDirt().getRandom();
|
||||
}
|
||||
|
||||
public GMap<MB, Double> getScatterChance()
|
||||
{
|
||||
return scatterChance;
|
||||
}
|
||||
|
||||
public IrisBiome addEffect(PotionEffect effect)
|
||||
{
|
||||
effects.add(effect);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MB getScatterChanceSingle()
|
||||
{
|
||||
for(MB i : getScatterChance().keySet())
|
||||
{
|
||||
if(M.r(getScatterChance().get(i)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return MB.of(Material.AIR);
|
||||
}
|
||||
|
||||
public static GList<IrisBiome> getBiomes()
|
||||
{
|
||||
return map.v().remove(IrisBiome.ROAD_GRASSY, IrisBiome.ROAD_GRAVEL, IrisBiome.BEACH, IrisBiome.LAKE, IrisBiome.RIVER);
|
||||
}
|
||||
|
||||
public static GList<IrisBiome> getAllBiomes()
|
||||
{
|
||||
return map.v();
|
||||
}
|
||||
|
||||
public static IrisBiome findByBiome(Biome biome)
|
||||
{
|
||||
if(map.containsKey(biome))
|
||||
{
|
||||
return map.get(biome);
|
||||
}
|
||||
|
||||
return IrisBiome.PLAINS;
|
||||
}
|
||||
|
||||
public GMap<String, Double> getSchematicGroups()
|
||||
{
|
||||
return schematicGroups;
|
||||
}
|
||||
|
||||
public void applyEffects(Player j)
|
||||
{
|
||||
if(j.getLocation().getY() < 63)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(PotionEffect i : effects)
|
||||
{
|
||||
j.getPlayer().removePotionEffect(i.getType());
|
||||
j.addPotionEffect(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(amp);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result + ((dirt == null) ? 0 : dirt.hashCode());
|
||||
result = prime * result + ((effects == null) ? 0 : effects.hashCode());
|
||||
temp = Double.doubleToLongBits(height);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((poly == null) ? 0 : poly.hashCode());
|
||||
result = prime * result + ((realBiome == null) ? 0 : realBiome.hashCode());
|
||||
result = prime * result + ((scatterChance == null) ? 0 : scatterChance.hashCode());
|
||||
result = prime * result + (scatterSurface ? 1231 : 1237);
|
||||
result = prime * result + ((schematicGroups == null) ? 0 : schematicGroups.hashCode());
|
||||
result = prime * result + (simplexScatter ? 1231 : 1237);
|
||||
result = prime * result + ((surface == null) ? 0 : surface.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(obj == null)
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
IrisBiome other = (IrisBiome) obj;
|
||||
if(Double.doubleToLongBits(amp) != Double.doubleToLongBits(other.amp))
|
||||
return false;
|
||||
if(dirt == null)
|
||||
{
|
||||
if(other.dirt != null)
|
||||
return false;
|
||||
}
|
||||
else if(!dirt.equals(other.dirt))
|
||||
return false;
|
||||
if(effects == null)
|
||||
{
|
||||
if(other.effects != null)
|
||||
return false;
|
||||
}
|
||||
else if(!effects.equals(other.effects))
|
||||
return false;
|
||||
if(Double.doubleToLongBits(height) != Double.doubleToLongBits(other.height))
|
||||
return false;
|
||||
if(name == null)
|
||||
{
|
||||
if(other.name != null)
|
||||
return false;
|
||||
}
|
||||
else if(!name.equals(other.name))
|
||||
return false;
|
||||
if(poly == null)
|
||||
{
|
||||
if(other.poly != null)
|
||||
return false;
|
||||
}
|
||||
else if(!poly.equals(other.poly))
|
||||
return false;
|
||||
if(realBiome != other.realBiome)
|
||||
return false;
|
||||
if(scatterChance == null)
|
||||
{
|
||||
if(other.scatterChance != null)
|
||||
return false;
|
||||
}
|
||||
else if(!scatterChance.equals(other.scatterChance))
|
||||
return false;
|
||||
if(scatterSurface != other.scatterSurface)
|
||||
return false;
|
||||
if(schematicGroups == null)
|
||||
{
|
||||
if(other.schematicGroups != null)
|
||||
return false;
|
||||
}
|
||||
else if(!schematicGroups.equals(other.schematicGroups))
|
||||
return false;
|
||||
if(simplexScatter != other.simplexScatter)
|
||||
return false;
|
||||
if(surface == null)
|
||||
{
|
||||
if(other.surface != null)
|
||||
return false;
|
||||
}
|
||||
else if(!surface.equals(other.surface))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -8,11 +8,13 @@ import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MaxingGenerator;
|
||||
import ninja.bytecode.iris.util.MaxingGenerator.EnumMaxingGenerator;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerBiome extends GenLayer
|
||||
@ -23,17 +25,19 @@ public class GenLayerBiome extends GenLayer
|
||||
private CNG pathCheck;
|
||||
private CNG riverCheck;
|
||||
private CNG fracture;
|
||||
private CNG island;
|
||||
|
||||
public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng, GList<IrisBiome> biomes)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
island = new CNG(rng.nextParallelRNG(10334), 1D, 3).scale(0.003 * Iris.settings.gen.landScale).fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 12).scale(0.6), 180);
|
||||
fracture = new CNG(rng.nextParallelRNG(28), 1D, 24).scale(0.0021).fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 12).scale(0.01), 12250);
|
||||
factory = (g) -> g.fractureWith(new CNG(rng.nextParallelRNG(29), 1D, 4).scale(0.02), 56);
|
||||
riverCheck = new CNG(rng.nextParallelRNG(30), 1D, 2).scale(0.00096);
|
||||
pathCheck = new CNG(rng.nextParallelRNG(31), 1D, 1).scale(0.00096);
|
||||
roads = new MaxingGenerator(rng.nextParallelRNG(32), 5, 0.00055, 8, factory);
|
||||
biomeGenerator = new EnumMaxingGenerator<IrisBiome>(rng.nextParallelRNG(33), 0.00755 * Iris.settings.gen.biomeScale, 1, IrisBiome.getBiomes().toArray(new IrisBiome[IrisBiome.getBiomes().size()]), factory);
|
||||
biomeGenerator = new EnumMaxingGenerator<IrisBiome>(rng.nextParallelRNG(33), 0.00755 * Iris.settings.gen.biomeScale, 1, biomes.toArray(new IrisBiome[biomes.size()]), factory);
|
||||
//@done
|
||||
}
|
||||
|
||||
@ -41,7 +45,17 @@ public class GenLayerBiome extends GenLayer
|
||||
{
|
||||
double x = xx + (fracture.noise(zz, xx) * 1550D);
|
||||
double z = zz - (fracture.noise(xx, zz) * 1550D);
|
||||
IrisBiome cbi = IrisBiome.OCEAN;
|
||||
double land = island.noise(x, z);
|
||||
double landChance = 1D - M.clip(Iris.settings.gen.landChance, 0D, 1D);
|
||||
|
||||
if(land > landChance && land < landChance + 0.0175)
|
||||
{
|
||||
cbi = IrisBiome.BEACH;
|
||||
}
|
||||
|
||||
else if(land > landChance + 0.0175)
|
||||
{
|
||||
if(riverCheck.noise(x, z) > 0.75)
|
||||
{
|
||||
if(biomeGenerator.hasBorder(3, 3 + Math.pow(riverCheck.noise(x, z), 1.25) * 16, x, z))
|
||||
@ -50,7 +64,7 @@ public class GenLayerBiome extends GenLayer
|
||||
}
|
||||
}
|
||||
|
||||
IrisBiome cbi = biomeGenerator.getChoice(x, z);
|
||||
cbi = biomeGenerator.getChoice(x, z);
|
||||
|
||||
if(pathCheck.noise(x, z) > 0.33)
|
||||
{
|
||||
@ -66,6 +80,12 @@ public class GenLayerBiome extends GenLayer
|
||||
return road;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(land < 0.3)
|
||||
{
|
||||
cbi = IrisBiome.DEEP_OCEAN;
|
||||
}
|
||||
|
||||
return cbi;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
|
@ -5,8 +5,8 @@ import java.util.Random;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.schematic.Schematic;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
|
||||
public class BiomeBiasSchematicPopulator extends SurfaceBiasSchematicPopulator
|
||||
|
@ -171,12 +171,22 @@ public class Schematic
|
||||
}
|
||||
}
|
||||
|
||||
public static Schematic load(InputStream in) throws IOException
|
||||
{
|
||||
Schematic s = new Schematic(1, 1, 1);
|
||||
s.read(in);
|
||||
|
||||
L.i("Loaded Internal Schematic: " + s.getSchematic().size());
|
||||
return s;
|
||||
}
|
||||
|
||||
public static Schematic load(File f) throws IOException
|
||||
{
|
||||
Schematic s = new Schematic(1, 1, 1);
|
||||
FileInputStream fin = new FileInputStream(f);
|
||||
s.read(fin);
|
||||
|
||||
|
||||
L.i("Loaded Schematic: " + f.getPath() + " Size: " + s.getSchematic().size());
|
||||
return s;
|
||||
}
|
||||
|
431
src/main/java/ninja/bytecode/iris/spec/IrisBiome.java
Normal file
431
src/main/java/ninja/bytecode/iris/spec/IrisBiome.java
Normal file
@ -0,0 +1,431 @@
|
||||
package ninja.bytecode.iris.spec;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.PolygonGenerator;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.json.JSONArray;
|
||||
import ninja.bytecode.shuriken.json.JSONObject;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class IrisBiome
|
||||
{
|
||||
public static final double MAX_HEIGHT = 0.77768;
|
||||
public static final double IDEAL_HEIGHT = 0.1127;
|
||||
public static final double MIN_HEIGHT = -0.0218;
|
||||
|
||||
//@builder
|
||||
public static final IrisBiome RIVER = new IrisBiome("River", Biome.RIVER)
|
||||
.surface(MB.of(Material.SAND))
|
||||
.coreBiome();
|
||||
public static final IrisBiome BEACH = new IrisBiome("Beach", Biome.BEACHES)
|
||||
.height(-0.078)
|
||||
.coreBiome()
|
||||
.surface(MB.of(Material.SAND));
|
||||
public static final IrisBiome ROAD_GRAVEL = new IrisBiome("Gravel Road", Biome.PLAINS)
|
||||
.surface(MB.of(Material.GRAVEL), MB.of(Material.COBBLESTONE))
|
||||
.coreBiome()
|
||||
.scatter(MB.of(Material.TORCH), 0.05);
|
||||
public static final IrisBiome ROAD_GRASSY = new IrisBiome("Grass Path", Biome.PLAINS)
|
||||
.surface(MB.of(Material.GRASS_PATH))
|
||||
.coreBiome()
|
||||
.scatter(MB.of(Material.TORCH), 0.05);
|
||||
public static final IrisBiome OCEAN = new IrisBiome("Ocean", Biome.OCEAN)
|
||||
.height(-0.5)
|
||||
.coreBiome()
|
||||
.surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
|
||||
.simplexSurface();
|
||||
public static final IrisBiome LAKE = new IrisBiome("Lake", Biome.DESERT)
|
||||
.height(-0.38)
|
||||
.coreBiome()
|
||||
.surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.GRAVEL), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
|
||||
.simplexSurface();
|
||||
public static final IrisBiome DEEP_OCEAN = new IrisBiome("Deep Ocean", Biome.DEEP_OCEAN)
|
||||
.height(-0.88)
|
||||
.coreBiome()
|
||||
.surface(MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
|
||||
.simplexSurface();
|
||||
|
||||
// public static final IrisBiome FOREST = new IrisBiome("Forest", Biome.FOREST)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
// public static final IrisBiome FOREST_HILLS = new IrisBiome("Forest Hills", Biome.FOREST_HILLS)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
// public static final IrisBiome FOREST_MOUNTAINS = new IrisBiome("Forest Mountains", Biome.MUTATED_EXTREME_HILLS_WITH_TREES)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 1), 0.13)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
// public static final IrisBiome HAUNTED_FOREST = new IrisBiome("Haunted Forest", Biome.MUTATED_SWAMPLAND)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 1), 0.13)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.13)
|
||||
// .surface(MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.SOUL_SAND), MB.of(Material.DIRT), MB.of(Material.DIRT, 1), MB.of(Material.DIRT, 2))
|
||||
// .scatterSurface();
|
||||
// public static final IrisBiome BIRCH_FOREST = new IrisBiome("Birch Forest", Biome.BIRCH_FOREST)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
// public static final IrisBiome BIRCH_FOREST_HILLS = new IrisBiome("Birch Forest Hills", Biome.BIRCH_FOREST_HILLS)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
// public static final IrisBiome ROOFED_FOREST = new IrisBiome("Roofed Forest", Biome.ROOFED_FOREST)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
// public static final IrisBiome TAIGA = new IrisBiome("Taiga", Biome.TAIGA)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.07);
|
||||
// public static final IrisBiome EXTREME_HILLS = new IrisBiome("Extreme Hills", Biome.EXTREME_HILLS)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.04)
|
||||
// .height(0.28);
|
||||
// public static final IrisBiome EXTREME_HILLS_TREES = new IrisBiome("Extreme Hills +", Biome.EXTREME_HILLS_WITH_TREES)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.09);
|
||||
// public static final IrisBiome TAIGA_COLD = new IrisBiome("Taiga Cold", Biome.TAIGA_COLD)
|
||||
// .scatter(MB.of(Material.LONG_GRASS, 2), 0.04);
|
||||
// public static final IrisBiome TAIGA_COLD_HILLS = new IrisBiome("Taiga Cold Hills", Biome.TAIGA_COLD_HILLS);
|
||||
// public static final IrisBiome ICE_FLATS = new IrisBiome("Ice Flats", Biome.ICE_FLATS);
|
||||
// public static final IrisBiome ICE_MOUNTAINS = new IrisBiome("Ice Mountains", Biome.ICE_MOUNTAINS);
|
||||
// public static final IrisBiome REDWOOD_TAIGA = new IrisBiome("Redwood Taiga", Biome.REDWOOD_TAIGA)
|
||||
// .surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
|
||||
// .simplexSurface();
|
||||
// public static final IrisBiome REDWOOD_TAIGA_HILLS = new IrisBiome("Redwood Taiga Hills", Biome.REDWOOD_TAIGA_HILLS)
|
||||
// .surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
|
||||
// .simplexSurface();
|
||||
|
||||
//@done
|
||||
private static final GMap<Biome, IrisBiome> map = build();
|
||||
private String name;
|
||||
private Biome realBiome;
|
||||
private double height;
|
||||
private double amp;
|
||||
private GList<MB> surface;
|
||||
private GList<MB> dirt;
|
||||
private GMap<MB, Double> scatterChance;
|
||||
private boolean scatterSurface;
|
||||
private boolean core;
|
||||
private boolean simplexScatter;
|
||||
private GMap<String, Double> schematicGroups;
|
||||
private PolygonGenerator.EnumPolygonGenerator<MB> poly;
|
||||
|
||||
public IrisBiome(JSONObject json)
|
||||
{
|
||||
this("Loading", Biome.OCEAN);
|
||||
fromJSON(json);
|
||||
}
|
||||
|
||||
public IrisBiome(String name, Biome realBiome)
|
||||
{
|
||||
this.core = false;
|
||||
this.name = name;
|
||||
this.realBiome = realBiome;
|
||||
this.height = IDEAL_HEIGHT;
|
||||
this.amp = 0.31;
|
||||
scatterChance = new GMap<>();
|
||||
schematicGroups = new GMap<>();
|
||||
surface(new MB(Material.GRASS)).dirt(new MB(Material.DIRT), new MB(Material.DIRT, 1));
|
||||
}
|
||||
|
||||
public void fromJSON(JSONObject o)
|
||||
{
|
||||
name = o.getString("name");
|
||||
realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_"));
|
||||
J.attempt(() -> height = o.getDouble("height"));
|
||||
J.attempt(() -> surface = mbListFromJSON(o.getJSONArray("surface")));
|
||||
J.attempt(() -> dirt = mbListFromJSON(o.getJSONArray("dirt")));
|
||||
J.attempt(() -> scatterChance = scatterFromJSON(o.getJSONArray("scatter")));
|
||||
J.attempt(() -> simplexScatter = o.getString("surfaceType").equalsIgnoreCase("simplex"));
|
||||
J.attempt(() -> scatterSurface = o.getString("surfaceType").equalsIgnoreCase("scatter"));
|
||||
J.attempt(() -> schematicGroups = strFromJSON(o.getJSONArray("schematics")));
|
||||
}
|
||||
|
||||
public JSONObject toJSON()
|
||||
{
|
||||
JSONObject j = new JSONObject();
|
||||
j.put("name", name);
|
||||
J.attempt(() -> j.put("derivative", realBiome.name().toLowerCase().replaceAll("_", " ")));
|
||||
J.attempt(() -> j.put("height", height));
|
||||
J.attempt(() -> j.put("surface", mbListToJSON(surface)));
|
||||
J.attempt(() -> j.put("dirt", mbListToJSON(dirt)));
|
||||
J.attempt(() -> j.put("scatter", scatterToJson(scatterChance)));
|
||||
J.attempt(() -> j.put("surfaceType", simplexScatter ? "simplex" : scatterSurface ? "scatter" : "na"));
|
||||
J.attempt(() -> j.put("schematics", strToJson(schematicGroups)));
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
private GList<MB> mbListFromJSON(JSONArray ja)
|
||||
{
|
||||
GList<MB> mb = new GList<>();
|
||||
|
||||
for(int i = 0; i < ja.length(); i++)
|
||||
{
|
||||
mb.add(MB.of(ja.getString(i)));
|
||||
}
|
||||
|
||||
return mb;
|
||||
}
|
||||
|
||||
private JSONArray mbListToJSON(GList<MB> mbs)
|
||||
{
|
||||
JSONArray ja = new JSONArray();
|
||||
|
||||
for(MB i : mbs)
|
||||
{
|
||||
ja.put(i.toString());
|
||||
}
|
||||
|
||||
return ja;
|
||||
}
|
||||
|
||||
public IrisBiome coreBiome()
|
||||
{
|
||||
this.core = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
private GMap<MB, Double> scatterFromJSON(JSONArray ja)
|
||||
{
|
||||
GMap<MB, Double> mb = new GMap<MB, Double>();
|
||||
|
||||
for(int i = 0; i < ja.length(); i++)
|
||||
{
|
||||
String s = ja.getString(i);
|
||||
mb.put(MB.of(s.split("\\Q=\\E")[0]), Double.valueOf(s.split("\\Q=\\E")[1]));
|
||||
}
|
||||
|
||||
return mb;
|
||||
}
|
||||
|
||||
private JSONArray scatterToJson(GMap<MB, Double> mbs)
|
||||
{
|
||||
JSONArray ja = new JSONArray();
|
||||
|
||||
for(MB i : mbs.k())
|
||||
{
|
||||
ja.put(i.toString() + "=" + mbs.get(i));
|
||||
}
|
||||
|
||||
return ja;
|
||||
}
|
||||
|
||||
private GMap<String, Double> strFromJSON(JSONArray ja)
|
||||
{
|
||||
GMap<String, Double> mb = new GMap<String, Double>();
|
||||
|
||||
for(int i = 0; i < ja.length(); i++)
|
||||
{
|
||||
String s = ja.getString(i);
|
||||
mb.put(s.split("\\Q=\\E")[0], Double.valueOf(s.split("\\Q=\\E")[1]));
|
||||
}
|
||||
|
||||
return mb;
|
||||
}
|
||||
|
||||
private JSONArray strToJson(GMap<String, Double> mbs)
|
||||
{
|
||||
JSONArray ja = new JSONArray();
|
||||
|
||||
for(String i : mbs.k())
|
||||
{
|
||||
ja.put(i.toString() + "=" + mbs.get(i));
|
||||
}
|
||||
|
||||
return ja;
|
||||
}
|
||||
|
||||
private static GMap<Biome, IrisBiome> build()
|
||||
{
|
||||
GMap<Biome, IrisBiome> g = new GMap<Biome, IrisBiome>();
|
||||
|
||||
for(Field i : IrisBiome.class.getDeclaredFields())
|
||||
{
|
||||
J.attempt(() ->
|
||||
{
|
||||
i.setAccessible(true);
|
||||
|
||||
IrisBiome bb = (IrisBiome) i.get(null);
|
||||
|
||||
if(!g.containsKey(bb.realBiome))
|
||||
{
|
||||
g.put(bb.realBiome, bb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
public IrisBiome scatter(MB mb, Double chance)
|
||||
{
|
||||
scatterChance.put(mb, chance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome schematic(String t, double chance)
|
||||
{
|
||||
schematicGroups.put(t, chance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome simplexSurface()
|
||||
{
|
||||
simplexScatter = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome scatterSurface()
|
||||
{
|
||||
scatterSurface = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome surface(MB... mbs)
|
||||
{
|
||||
surface = new GList<>(mbs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome dirt(MB... mbs)
|
||||
{
|
||||
dirt = new GList<>(mbs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome height(double height)
|
||||
{
|
||||
if(height >= 0)
|
||||
{
|
||||
this.height = M.lerp(IDEAL_HEIGHT, MAX_HEIGHT, M.clip(height, 0D, 1D));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
this.height = M.lerp(MIN_HEIGHT, IDEAL_HEIGHT, M.clip(height, -1D, 0D));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public IrisBiome amp(double amp)
|
||||
{
|
||||
this.amp = amp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public Biome getRealBiome()
|
||||
{
|
||||
return realBiome;
|
||||
}
|
||||
|
||||
public double getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public double getAmp()
|
||||
{
|
||||
return amp;
|
||||
}
|
||||
|
||||
public GList<MB> getSurface()
|
||||
{
|
||||
return surface;
|
||||
}
|
||||
|
||||
public GList<MB> getDirt()
|
||||
{
|
||||
return dirt;
|
||||
}
|
||||
|
||||
public MB getSurface(double x, double z, RNG rng)
|
||||
{
|
||||
double wx = x + 1000D;
|
||||
double wz = z + 1000D;
|
||||
if(simplexScatter)
|
||||
{
|
||||
if(poly == null)
|
||||
{
|
||||
poly = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 0.125, 2, getSurface().toArray(new MB[getSurface().size()]), (g) ->
|
||||
{
|
||||
return g.scale(0.05).fractureWith(new CNG(rng.nextParallelRNG(56), 1D, 2).scale(0.0955), 55);
|
||||
});
|
||||
}
|
||||
|
||||
return poly.getChoice(wx / 3, wz /3);
|
||||
}
|
||||
|
||||
if(scatterSurface)
|
||||
{
|
||||
if(poly == null)
|
||||
{
|
||||
poly = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 15.05, 2, getSurface().toArray(new MB[getSurface().size()]), (g) ->
|
||||
{
|
||||
return g.fractureWith(new CNG(rng.nextParallelRNG(55), 1D, 2).scale(0.0155), 224);
|
||||
});
|
||||
}
|
||||
|
||||
return poly.getChoice(wx * 0.2D, wz * 0.2D);
|
||||
}
|
||||
|
||||
return getSurface().getRandom();
|
||||
}
|
||||
|
||||
public MB getDirtRNG()
|
||||
{
|
||||
return getDirt().getRandom();
|
||||
}
|
||||
|
||||
public GMap<MB, Double> getScatterChance()
|
||||
{
|
||||
return scatterChance;
|
||||
}
|
||||
|
||||
public MB getScatterChanceSingle()
|
||||
{
|
||||
for(MB i : getScatterChance().keySet())
|
||||
{
|
||||
if(M.r(getScatterChance().get(i)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return MB.of(Material.AIR);
|
||||
}
|
||||
|
||||
public static GList<IrisBiome> getBiomes()
|
||||
{
|
||||
return map.v().remove(IrisBiome.BEACH, IrisBiome.OCEAN, IrisBiome.DEEP_OCEAN, IrisBiome.LAKE, IrisBiome.ROAD_GRASSY, IrisBiome.ROAD_GRAVEL, IrisBiome.BEACH, IrisBiome.LAKE, IrisBiome.RIVER);
|
||||
}
|
||||
|
||||
public static GList<IrisBiome> getAllBiomes()
|
||||
{
|
||||
return map.v();
|
||||
}
|
||||
|
||||
public static IrisBiome findByBiome(Biome biome)
|
||||
{
|
||||
if(map.containsKey(biome))
|
||||
{
|
||||
return map.get(biome);
|
||||
}
|
||||
|
||||
return IrisBiome.OCEAN;
|
||||
}
|
||||
|
||||
public GMap<String, Double> getSchematicGroups()
|
||||
{
|
||||
return schematicGroups;
|
||||
}
|
||||
}
|
95
src/main/java/ninja/bytecode/iris/spec/IrisDimension.java
Normal file
95
src/main/java/ninja/bytecode/iris/spec/IrisDimension.java
Normal file
@ -0,0 +1,95 @@
|
||||
package ninja.bytecode.iris.spec;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.json.JSONArray;
|
||||
import ninja.bytecode.shuriken.json.JSONException;
|
||||
import ninja.bytecode.shuriken.json.JSONObject;
|
||||
|
||||
public class IrisDimension
|
||||
{
|
||||
private String name;
|
||||
private Environment environment;
|
||||
GList<IrisBiome> biomes;
|
||||
|
||||
public IrisDimension(JSONObject o) throws JSONException, IOException
|
||||
{
|
||||
this();
|
||||
fromJSON(o);
|
||||
}
|
||||
|
||||
public IrisDimension()
|
||||
{
|
||||
biomes = new GList<IrisBiome>();
|
||||
environment = Environment.NORMAL;
|
||||
}
|
||||
|
||||
public void fromJSON(JSONObject o) throws JSONException, IOException
|
||||
{
|
||||
name = o.getString("name");
|
||||
J.attempt(() -> environment = Environment.valueOf(o.getString("environment").toUpperCase().replaceAll(" ", "_")));
|
||||
|
||||
try
|
||||
{
|
||||
biomes = biomesFromArray(o.getJSONArray("biomes"));
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject toJSON()
|
||||
{
|
||||
JSONObject o = new JSONObject();
|
||||
|
||||
o.put("name", name);
|
||||
o.put("environment", environment.name().toLowerCase().replaceAll("_", " "));
|
||||
o.put("biomes", biomesToArray(biomes));
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
private GList<IrisBiome> biomesFromArray(JSONArray a) throws JSONException, IOException
|
||||
{
|
||||
GList<IrisBiome> b = new GList<>();
|
||||
|
||||
for(int i = 0; i < a.length(); i++)
|
||||
{
|
||||
IrisBiome bb = Iris.loadBiome(a.getString(i));
|
||||
Iris.biomes.put(a.getString(i), bb);
|
||||
b.add(bb);
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
private JSONArray biomesToArray(GList<IrisBiome> b)
|
||||
{
|
||||
JSONArray a = new JSONArray();
|
||||
|
||||
for(IrisBiome i : b)
|
||||
{
|
||||
a.put(i.getName().toLowerCase().replaceAll(" ", "_"));
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
public GList<IrisBiome> getBiomes()
|
||||
{
|
||||
return biomes;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
86
src/main/java/ninja/bytecode/iris/spec/IrisPack.java
Normal file
86
src/main/java/ninja/bytecode/iris/spec/IrisPack.java
Normal file
@ -0,0 +1,86 @@
|
||||
package ninja.bytecode.iris.spec;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.json.JSONArray;
|
||||
import ninja.bytecode.shuriken.json.JSONException;
|
||||
import ninja.bytecode.shuriken.json.JSONObject;
|
||||
|
||||
public class IrisPack
|
||||
{
|
||||
private GList<String> dimensions;
|
||||
private GList<String> biomes;
|
||||
private GList<String> objects;
|
||||
|
||||
public IrisPack()
|
||||
{
|
||||
this.dimensions = new GList<>();
|
||||
this.biomes = new GList<>();
|
||||
this.objects = new GList<>();
|
||||
}
|
||||
|
||||
public IrisPack(JSONObject o)
|
||||
{
|
||||
this();
|
||||
fromJSON(o);
|
||||
}
|
||||
|
||||
public void fromJSON(JSONObject o)
|
||||
{
|
||||
J.attempt(() -> dimensions = fromArray(o.getJSONArray("dimensions")));
|
||||
J.attempt(() -> biomes = fromArray(o.getJSONArray("biomes")));
|
||||
J.attempt(() -> objects = fromArray(o.getJSONArray("objects")));
|
||||
}
|
||||
|
||||
public JSONObject toJSON()
|
||||
{
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("dimensions", toArray(dimensions));
|
||||
o.put("biomes", toArray(biomes));
|
||||
o.put("objects", toArray(objects));
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
public GList<String> fromArray(JSONArray ja)
|
||||
{
|
||||
GList<String> g = new GList<>();
|
||||
|
||||
for(int i = 0; i < ja.length(); i++)
|
||||
{
|
||||
g.add(ja.getString(i));
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
public JSONArray toArray(GList<String> s)
|
||||
{
|
||||
JSONArray ja = new JSONArray();
|
||||
|
||||
for(String i : s)
|
||||
{
|
||||
ja.put(i);
|
||||
}
|
||||
|
||||
return ja;
|
||||
}
|
||||
|
||||
public void load() throws JSONException, IOException
|
||||
{
|
||||
for(String i : dimensions)
|
||||
{
|
||||
IrisDimension d = Iris.loadDimension(i);
|
||||
Iris.dimensions.put(i, d);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadBiome(String s) throws JSONException, IOException
|
||||
{
|
||||
IrisBiome b = Iris.loadBiome(s);
|
||||
Iris.biomes.put(s, b);
|
||||
}
|
||||
}
|
@ -4,8 +4,8 @@ import java.util.function.Supplier;
|
||||
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.iris.schematic.Schematic;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
|
||||
public class ChunkPlan
|
||||
|
@ -4,25 +4,54 @@ import ninja.bytecode.shuriken.math.M;
|
||||
|
||||
public class IrisInterpolation
|
||||
{
|
||||
public static double bezier(double t)
|
||||
{
|
||||
return t * t * (3.0d - 2.0d * t);
|
||||
}
|
||||
|
||||
public static double parametric(double t, double alpha)
|
||||
{
|
||||
double sqt = Math.pow(t, alpha);
|
||||
return sqt / (alpha * (sqt - Math.pow(t, alpha - 1)) + 1.0d);
|
||||
}
|
||||
|
||||
public static double lerp(double a, double b, double f)
|
||||
{
|
||||
return a + (f * (b - a));
|
||||
}
|
||||
|
||||
public static double lerpBezier(double a, double b, double f)
|
||||
{
|
||||
return a + (bezier(f) * (b - a));
|
||||
}
|
||||
|
||||
public static double lerpParametric(double a, double b, double f, double v)
|
||||
{
|
||||
return a + (parametric(f, v) * (b - a));
|
||||
}
|
||||
|
||||
public static double blerp(double a, double b, double c, double d, double tx, double ty)
|
||||
{
|
||||
return lerp(lerp(a, b, tx), lerp(c, d, tx), ty);
|
||||
}
|
||||
|
||||
public static double getBilinearNoise(int x, int z, NoiseProvider n)
|
||||
public static double blerpBezier(double a, double b, double c, double d, double tx, double ty)
|
||||
{
|
||||
int h = 3;
|
||||
int fx = x >> h;
|
||||
int fz = z >> h;
|
||||
int xa = (fx << h) - 2;
|
||||
int za = (fz << h) - 2;
|
||||
int xb = ((fx + 1) << h) + 2;
|
||||
int zb = ((fz + 1) << h) + 2;
|
||||
return lerpBezier(lerpBezier(a, b, tx), lerpBezier(c, d, tx), ty);
|
||||
}
|
||||
|
||||
public static double blerpParametric(double a, double b, double c, double d, double tx, double ty, double v)
|
||||
{
|
||||
return lerpParametric(lerpParametric(a, b, tx, v), lerpParametric(c, d, tx, v), ty, v);
|
||||
}
|
||||
|
||||
public static double getLinearNoise(int x, int z, NoiseProvider n)
|
||||
{
|
||||
int h = 29;
|
||||
int xa = x - h;
|
||||
int za = z - h;
|
||||
int xb = x + h;
|
||||
int zb = z + h;
|
||||
double na = n.noise(xa, za);
|
||||
double nb = n.noise(xa, zb);
|
||||
double nc = n.noise(xb, za);
|
||||
@ -30,7 +59,26 @@ public class IrisInterpolation
|
||||
double px = M.rangeScale(0, 1, xa, xb, x);
|
||||
double pz = M.rangeScale(0, 1, za, zb, z);
|
||||
|
||||
return blerp(na, nc, nb, nd, px, pz);
|
||||
return blerpBezier(na, nc, nb, nd, px, pz);
|
||||
}
|
||||
|
||||
public static double getBilinearNoise(int x, int z, NoiseProvider n)
|
||||
{
|
||||
int h = 1;
|
||||
int fx = x >> h;
|
||||
int fz = z >> h;
|
||||
int xa = (fx << h) - 15;
|
||||
int za = (fz << h) - 15;
|
||||
int xb = ((fx + 1) << h) + 15;
|
||||
int zb = ((fz + 1) << h) + 15;
|
||||
double na = getLinearNoise(xa, za, n);
|
||||
double nb = getLinearNoise(xa, zb, n);
|
||||
double nc = getLinearNoise(xb, za, n);
|
||||
double nd = getLinearNoise(xb, zb, n);
|
||||
double px = M.rangeScale(0, 1, xa, xb, x);
|
||||
double pz = M.rangeScale(0, 1, za, zb, z);
|
||||
|
||||
return blerpBezier(na, nc, nb, nd, px, pz);
|
||||
}
|
||||
|
||||
public static double getBicubicNoise(int x, int z, NoiseProvider n)
|
||||
@ -49,6 +97,6 @@ public class IrisInterpolation
|
||||
double px = M.rangeScale(0, 1, xa, xb, x);
|
||||
double pz = M.rangeScale(0, 1, za, zb, z);
|
||||
|
||||
return blerp(na, nc, nb, nd, px, pz);
|
||||
return blerpBezier(na, nc, nb, nd, px, pz);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,51 @@ public class MB
|
||||
public final Material material;
|
||||
public final byte data;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static MB of(String dat)
|
||||
{
|
||||
String material = dat;
|
||||
byte data = 0;
|
||||
|
||||
if(dat.contains(":"))
|
||||
{
|
||||
material = dat.split("\\Q:\\E")[0];
|
||||
data = Integer.valueOf(dat.split("\\Q:\\E")[1]).byteValue();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return new MB(Material.getMaterial(Integer.valueOf(material)), data);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return new MB(Material.getMaterial(material), data);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return MB.of(Material.AIR);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
if(data == 0)
|
||||
{
|
||||
return material.name();
|
||||
}
|
||||
|
||||
return material.name() + ":" + data;
|
||||
}
|
||||
|
||||
public MB(Material material, int data)
|
||||
{
|
||||
this.material = material;
|
||||
|
@ -100,6 +100,12 @@ public class MaxingGenerator
|
||||
public EnumMaxingGenerator(RNG rng, double scale, int octaves, T[] choices, Function<CNG, CNG> factory)
|
||||
{
|
||||
super(rng, choices.length, scale / (double) choices.length, octaves, factory);
|
||||
|
||||
if(choices.length == 0)
|
||||
{
|
||||
throw new RuntimeException("Must contain more than 0 choices!");
|
||||
}
|
||||
|
||||
this.choices = choices;
|
||||
}
|
||||
|
||||
|
13
src/main/resources/pack/biomes/desert.json
Normal file
13
src/main/resources/pack/biomes/desert.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "Desert",
|
||||
"derivative": "DESERT",
|
||||
"surface": [
|
||||
"SAND"
|
||||
],
|
||||
"dirt": [
|
||||
"SANDSTONE"
|
||||
],
|
||||
"scatter":[
|
||||
"DEAD_BUSH=0.008"
|
||||
]
|
||||
}
|
13
src/main/resources/pack/biomes/desert_hills.json
Normal file
13
src/main/resources/pack/biomes/desert_hills.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "Desert Hills",
|
||||
"derivative": "DESERT_HILLS",
|
||||
"surface": [
|
||||
"SAND"
|
||||
],
|
||||
"dirt": [
|
||||
"SANDSTONE"
|
||||
],
|
||||
"scatter":[
|
||||
"DEAD_BUSH=0.005"
|
||||
]
|
||||
}
|
13
src/main/resources/pack/biomes/desert_red.json
Normal file
13
src/main/resources/pack/biomes/desert_red.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "Desert Red",
|
||||
"derivative": "MUTATED_DESERT",
|
||||
"surface": [
|
||||
"SAND:1"
|
||||
],
|
||||
"dirt": [
|
||||
"RED_SANDSTONE"
|
||||
],
|
||||
"scatter":[
|
||||
"DEAD_BUSH=0.008"
|
||||
]
|
||||
}
|
8
src/main/resources/pack/biomes/jungle.json
Normal file
8
src/main/resources/pack/biomes/jungle.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "Jungle",
|
||||
"derivative": "JUNGLE",
|
||||
"scatter":[
|
||||
"LONG_GRASS:1=0.58",
|
||||
"LONG_GRASS:2=0.13"
|
||||
]
|
||||
}
|
8
src/main/resources/pack/biomes/jungle_hills.json
Normal file
8
src/main/resources/pack/biomes/jungle_hills.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "Jungle Hills",
|
||||
"derivative": "JUNGLE_HILLS",
|
||||
"scatter":[
|
||||
"LONG_GRASS:1=0.33",
|
||||
"LONG_GRASS:2=0.02"
|
||||
]
|
||||
}
|
16
src/main/resources/pack/biomes/mesa.json
Normal file
16
src/main/resources/pack/biomes/mesa.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Mesa",
|
||||
"derivative": "Mesa",
|
||||
"surface": [
|
||||
"HARD_CLAY",
|
||||
"STAINED_CLAY:1",
|
||||
"STAINED_CLAY:8",
|
||||
"STAINED_CLAY:12"
|
||||
],
|
||||
"dirt": [
|
||||
"CLAY",
|
||||
"SAND:1",
|
||||
"SAND"
|
||||
],
|
||||
"surfaceType": "simplex"
|
||||
}
|
8
src/main/resources/pack/biomes/plains.json
Normal file
8
src/main/resources/pack/biomes/plains.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "Plains",
|
||||
"derivative": "PLAINS",
|
||||
"scatter":[
|
||||
"LONG_GRASS:1=0.37",
|
||||
"LONG_GRASS:2=0.09"
|
||||
]
|
||||
}
|
7
src/main/resources/pack/biomes/savanna.json
Normal file
7
src/main/resources/pack/biomes/savanna.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "Savanna",
|
||||
"derivative": "SAVANNA",
|
||||
"scatter":[
|
||||
"LONG_GRASS:1=0.18"
|
||||
]
|
||||
}
|
7
src/main/resources/pack/biomes/savanna_hills.json
Normal file
7
src/main/resources/pack/biomes/savanna_hills.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "Savanna Hills",
|
||||
"derivative": "SAVANNA_ROCK",
|
||||
"scatter":[
|
||||
"LONG_GRASS:1=0.18"
|
||||
]
|
||||
}
|
8
src/main/resources/pack/biomes/swamp.json
Normal file
8
src/main/resources/pack/biomes/swamp.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "Swamp",
|
||||
"derivative": "SWAMPLAND",
|
||||
"scatter":[
|
||||
"LONG_GRASS:1=0.04",
|
||||
"LONG_GRASS:2=0.03"
|
||||
]
|
||||
}
|
17
src/main/resources/pack/biomes/temp.json
Normal file
17
src/main/resources/pack/biomes/temp.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "Biome Name",
|
||||
"derivative": "PLAINS",
|
||||
"height": 0,
|
||||
"surface": [
|
||||
"GRASS"
|
||||
],
|
||||
"dirt": [
|
||||
"DIRT",
|
||||
"DIRT:1"
|
||||
],
|
||||
"scatter":[
|
||||
"LONG_GRASS:1=0.13"
|
||||
],
|
||||
"surfaceType": "na",
|
||||
"schematics": []
|
||||
}
|
16
src/main/resources/pack/dimensions/overworld.json
Normal file
16
src/main/resources/pack/dimensions/overworld.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "Overworld",
|
||||
"environment": "normal",
|
||||
"biomes": [
|
||||
"desert",
|
||||
"desert_red",
|
||||
"desert_hills",
|
||||
"mesa",
|
||||
"savanna",
|
||||
"savanna_hills",
|
||||
"jungle",
|
||||
"jungle_hills",
|
||||
"swamp",
|
||||
"plains"
|
||||
]
|
||||
}
|
5
src/main/resources/pack/manifest.json
Normal file
5
src/main/resources/pack/manifest.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"dimensions":[
|
||||
"overworld"
|
||||
]
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user