Update pack

This commit is contained in:
Daniel Mills 2020-01-08 06:13:01 -05:00
parent c620a9388f
commit 7e9417b186
34 changed files with 377 additions and 127 deletions

View File

@ -29,6 +29,7 @@ public class CommandIsh implements CommandExecutor
s.sendMessage(ChatColor.DARK_PURPLE + "[" + ChatColor.GRAY + "Iris" + ChatColor.DARK_PURPLE + "]" + ChatColor.GRAY + ": " + msg); s.sendMessage(ChatColor.DARK_PURPLE + "[" + ChatColor.GRAY + "Iris" + ChatColor.DARK_PURPLE + "]" + ChatColor.GRAY + ": " + msg);
} }
@SuppressWarnings("deprecation")
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{ {

View File

@ -32,6 +32,7 @@ import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.spec.IrisDimension; import ninja.bytecode.iris.spec.IrisDimension;
import ninja.bytecode.iris.spec.IrisPack; import ninja.bytecode.iris.spec.IrisPack;
import ninja.bytecode.iris.util.Direction; import ninja.bytecode.iris.util.Direction;
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
import ninja.bytecode.shuriken.bench.Profiler; import ninja.bytecode.shuriken.bench.Profiler;
import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.collections.GSet; import ninja.bytecode.shuriken.collections.GSet;
@ -48,6 +49,7 @@ public class Iris extends JavaPlugin implements Listener
public static GSet<Chunk> refresh = new GSet<>(); public static GSet<Chunk> refresh = new GSet<>();
public static Profiler profiler; public static Profiler profiler;
public static TaskExecutor genPool; public static TaskExecutor genPool;
public static TaskExecutor buildPool;
public static IrisGenerator gen; public static IrisGenerator gen;
public static Settings settings; public static Settings settings;
public static Iris instance; public static Iris instance;
@ -58,6 +60,7 @@ public class Iris extends JavaPlugin implements Listener
public void onEnable() public void onEnable()
{ {
PrecisionStopwatch stopwatch = PrecisionStopwatch.start();
Direction.calculatePermutations(); Direction.calculatePermutations();
dimensions = new GMap<>(); dimensions = new GMap<>();
biomes = new GMap<>(); biomes = new GMap<>();
@ -66,6 +69,7 @@ public class Iris extends JavaPlugin implements Listener
values = new GMap<>(); values = new GMap<>();
instance = this; instance = this;
settings = new Settings(); settings = new Settings();
buildPool = new TaskExecutor(getTC(), settings.performance.threadPriority, "Iris Compiler");
J.attempt(() -> createTempCache()); J.attempt(() -> createTempCache());
loadContent(); loadContent();
processContent(); processContent();
@ -97,12 +101,20 @@ public class Iris extends JavaPlugin implements Listener
Bukkit.unloadWorld(i, false); Bukkit.unloadWorld(i, false);
} }
} }
double ms = stopwatch.getMilliseconds();
J.a(() ->
{
J.sleep(5000);
L.i("Iris Startup Took " + F.duration(ms, 2));
});
} }
private void processContent() private void processContent()
{ {
L.v("Processing Content"); L.v("Processing Content");
for(SchematicGroup i : schematics.v()) for(SchematicGroup i : schematics.v())
{ {
i.processVariants(); i.processVariants();
@ -115,7 +127,7 @@ public class Iris extends JavaPlugin implements Listener
{ {
return new File(Iris.instance.getDataFolder(), resource); return new File(Iris.instance.getDataFolder(), resource);
} }
return new File(System.getProperty("java.io.tmpdir") + "/Iris/" + resource); return new File(System.getProperty("java.io.tmpdir") + "/Iris/" + resource);
} }
@ -160,17 +172,16 @@ public class Iris extends JavaPlugin implements Listener
} }
int m = 0; int m = 0;
for(SchematicGroup i : schematics.v()) for(SchematicGroup i : schematics.v())
{ {
m+=i.size(); m += i.size();
} }
L.i("Dimensions: " + dimensions.size()); L.i("Dimensions: " + dimensions.size());
L.i("Biomes: " + biomes.size()); L.i("Biomes: " + biomes.size());
L.i("Object Groups: " + schematics.size()); L.i("Object Groups: " + schematics.size());
L.i("Objects: " + F.f(m)); L.i("Objects: " + F.f(m));
L.flush(); L.flush();
} }
@ -238,23 +249,23 @@ public class Iris extends JavaPlugin implements Listener
L.i("Loading Iris Biome " + s); L.i("Loading Iris Biome " + s);
return new IrisBiome(loadJSON("pack/biomes/" + s + ".json")); return new IrisBiome(loadJSON("pack/biomes/" + s + ".json"));
} }
public static SchematicGroup loadSchematicGroup(String s) public static SchematicGroup loadSchematicGroup(String s)
{ {
SchematicGroup g = SchematicGroup.load("pack/objects/" + s); SchematicGroup g = SchematicGroup.load("pack/objects/" + s);
if(g != null) if(g != null)
{ {
schematics.put(s, g); schematics.put(s, g);
L.i("Loaded Object Group: " + g.getName() + " (" + g.getSchematics().size() + " Objects)"); L.i("Loaded Object Group: " + g.getName() + " (" + g.getSchematics().size() + " Objects)");
return g; return g;
} }
L.i("Cannot load Object Group: " + s); L.i("Cannot load Object Group: " + s);
return null; return null;
} }
public static Schematic loadSchematic(String s) throws IOException public static Schematic loadSchematic(String s) throws IOException
{ {
L.i("Loading Iris Object " + s); L.i("Loading Iris Object " + s);
@ -269,28 +280,28 @@ public class Iris extends JavaPlugin implements Listener
public static File loadFolder(String string) public static File loadFolder(String string)
{ {
File internal = internalResource(string); File internal = internalResource(string);
if(internal.exists()) if(internal.exists())
{ {
L.v("Loading Group: " + string); L.v("Loading Group: " + string);
return internal; return internal;
} }
L.f("Cannot find folder: " + internal.getAbsolutePath()); L.f("Cannot find folder: " + internal.getAbsolutePath());
return null; return null;
} }
public static InputStream loadResource(String string) throws IOException public static InputStream loadResource(String string) throws IOException
{ {
File internal = internalResource(string); File internal = internalResource(string);
if(internal.exists()) if(internal.exists())
{ {
L.v("Loading Resource: " + internal.getAbsolutePath()); L.v("Loading Resource: " + internal.getAbsolutePath());
L.flush(); L.flush();
return new FileInputStream(internal); return new FileInputStream(internal);
} }
else else
{ {
L.f("Cannot find Resource: " + internal.getAbsolutePath()); L.f("Cannot find Resource: " + internal.getAbsolutePath());

View File

@ -9,9 +9,9 @@ public class Settings
public static class PerformanceSettings public static class PerformanceSettings
{ {
public PerformanceMode performanceMode = PerformanceMode.UNLIMITED; public PerformanceMode performanceMode = PerformanceMode.MATCH_CPU;
public int threadCount = 12; public int threadCount = 1;
public int threadPriority = Thread.MAX_PRIORITY; public int threadPriority = Thread.MIN_PRIORITY;
public boolean loadonstart = true; public boolean loadonstart = true;
} }
@ -20,7 +20,7 @@ public class Settings
public double horizontalZoom = 1; // 0.525 public double horizontalZoom = 1; // 0.525
public double heightFracture = 155; public double heightFracture = 155;
public double landScale = 0.205; public double landScale = 0.205;
public double landChance = 0.529; public double landChance = 0.6;
public double roughness = 1.333; public double roughness = 1.333;
public double heightMultiplier = 0.806; public double heightMultiplier = 0.806;
public double heightExponentBase = 1; public double heightExponentBase = 1;
@ -30,7 +30,7 @@ public class Settings
public double baseHeight = 0.165; public double baseHeight = 0.165;
public int seaLevel = 63; public int seaLevel = 63;
public double caveDensity = 1; public double caveDensity = 1;
public double biomeScale = 2.5; public double biomeScale = 2;
public boolean flatBedrock = false; public boolean flatBedrock = false;
public boolean doSchematics = true; public boolean doSchematics = true;
} }

View File

@ -55,9 +55,11 @@ public class IrisGenerator extends ParallelChunkGenerator
MB.of(Material.SMOOTH_BRICK, 2), MB.of(Material.SMOOTH_BRICK, 2),
MB.of(Material.SMOOTH_BRICK, 3), MB.of(Material.SMOOTH_BRICK, 3),
}); });
public GMap<String, IrisBiome> biomeCache = new GMap<>();
//@done //@done
private MB WATER = new MB(Material.STATIONARY_WATER); private MB WATER = new MB(Material.STATIONARY_WATER);
private MB BEDROCK = new MB(Material.BEDROCK); private MB BEDROCK = new MB(Material.BEDROCK);
private GList<IrisBiome> internal;
private GenLayerBase glBase; private GenLayerBase glBase;
private GenLayerLayeredNoise glLNoise; private GenLayerLayeredNoise glLNoise;
private GenLayerRidge glRidge; private GenLayerRidge glRidge;
@ -78,18 +80,38 @@ public class IrisGenerator extends ParallelChunkGenerator
{ {
this(Iris.dimensions.get("overworld")); this(Iris.dimensions.get("overworld"));
} }
public GList<IrisBiome> getLoadedBiomes() public GList<IrisBiome> getLoadedBiomes()
{ {
return IrisBiome.getAllBiomes().copy().add(dim.getBiomes()); return internal;
} }
public IrisGenerator(IrisDimension dim) public IrisGenerator(IrisDimension dim)
{ {
this.dim = dim; this.dim = dim;
L.i("Preparing Dimension: " + dim.getName() + " With " + dim.getBiomes().size() + " Biomes..."); L.i("Preparing Dimension: " + dim.getName() + " With " + dim.getBiomes().size() + " Biomes...");
internal = IrisBiome.getAllBiomes();
for(IrisBiome i : dim.getBiomes())
{
for(IrisBiome j : internal.copy())
{
if(j.getName().equals(i.getName()))
{
internal.remove(j);
L.i("Internal Biome: " + j.getName() + " overwritten by dimension " + dim.getName());
}
}
}
internal.addAll(dim.getBiomes());
for(IrisBiome i : internal)
{
biomeCache.put(i.getName(), i);
}
} }
@Override @Override
public void onInit(World world, Random random) public void onInit(World world, Random random)
{ {
@ -121,6 +143,11 @@ public class IrisGenerator extends ParallelChunkGenerator
return glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale); return glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
} }
public IrisBiome biome(String name)
{
return biomeCache.get(name);
}
@Override @Override
public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan) public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan)
{ {
@ -137,24 +164,19 @@ public class IrisGenerator extends ParallelChunkGenerator
if(height > 61 && height < 65) if(height > 61 && height < 65)
{ {
override = IrisBiome.BEACH; override = biome("Beach");
} }
else if(height < 63) else if(height < 63)
{ {
if(height < 36) if(height < 36)
{ {
override = IrisBiome.DEEP_OCEAN; override = biome("Deep Ocean");
}
else if(height < 50)
{
override = IrisBiome.OCEAN;
} }
else else
{ {
override = IrisBiome.LAKE; override = biome("Ocean");
} }
} }
@ -277,4 +299,14 @@ public class IrisGenerator extends ParallelChunkGenerator
{ {
return world; return world;
} }
public GMap<String, SchematicGroup> getSchematicCache()
{
return schematicCache;
}
public void setSchematicCache(GMap<String, SchematicGroup> schematicCache)
{
this.schematicCache = schematicCache;
}
} }

View File

@ -45,13 +45,13 @@ public class GenLayerBiome extends GenLayer
{ {
double x = xx + (fracture.noise(zz, xx) * 1550D); double x = xx + (fracture.noise(zz, xx) * 1550D);
double z = zz - (fracture.noise(xx, zz) * 1550D); double z = zz - (fracture.noise(xx, zz) * 1550D);
IrisBiome cbi = IrisBiome.OCEAN; IrisBiome cbi = iris.biome("Ocean");
double land = island.noise(x, z); double land = island.noise(x, z);
double landChance = 1D - M.clip(Iris.settings.gen.landChance, 0D, 1D); double landChance = 1D - M.clip(Iris.settings.gen.landChance, 0D, 1D);
if(land > landChance && land < landChance + 0.0175) if(land > landChance && land < landChance + 0.0175)
{ {
cbi = IrisBiome.BEACH; cbi = iris.biome("Beach");
} }
else if(land > landChance + 0.0175) else if(land > landChance + 0.0175)
@ -60,7 +60,7 @@ public class GenLayerBiome extends GenLayer
{ {
if(biomeGenerator.hasBorder(3, 3 + Math.pow(riverCheck.noise(x, z), 1.25) * 16, x, z)) if(biomeGenerator.hasBorder(3, 3 + Math.pow(riverCheck.noise(x, z), 1.25) * 16, x, z))
{ {
return IrisBiome.RIVER; return iris.biome("River");
} }
} }
@ -68,7 +68,7 @@ public class GenLayerBiome extends GenLayer
if(pathCheck.noise(x, z) > 0.33) if(pathCheck.noise(x, z) > 0.33)
{ {
IrisBiome road = IrisBiome.ROAD_GRAVEL; IrisBiome road = iris.biome("Beach");
if(cbi.getSurface().get(0).material.equals(Material.GRASS)) if(cbi.getSurface().get(0).material.equals(Material.GRASS))
{ {
@ -84,7 +84,7 @@ public class GenLayerBiome extends GenLayer
else if(land < 0.3) else if(land < 0.3)
{ {
cbi = IrisBiome.DEEP_OCEAN; cbi = iris.biome("Deep Ocean");
} }
return cbi; return cbi;

View File

@ -17,7 +17,9 @@ import org.bukkit.util.Vector;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.util.Catalyst12; import ninja.bytecode.iris.util.Catalyst12;
import ninja.bytecode.iris.util.Direction;
import ninja.bytecode.iris.util.MB; import ninja.bytecode.iris.util.MB;
import ninja.bytecode.iris.util.VectorMath;
import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.io.CustomOutputStream; import ninja.bytecode.shuriken.io.CustomOutputStream;
@ -82,7 +84,7 @@ public class Schematic
mountHeight = avg(avy); mountHeight = avg(avy);
mount = new BlockVector(avg(avx), 0, avg(avz)); mount = new BlockVector(avg(avx), 0, avg(avz));
L.i(" Corrected Mount Point: 0,0,0 -> " + mount.getBlockX() + "," + mount.getBlockY() + "," + mount.getBlockZ()); L.i("Corrected " + getName() + "'s Mount Point: 0,0,0 -> " + mount.getBlockX() + "," + mount.getBlockY() + "," + mount.getBlockZ());
} }
private int avg(double[] v) private int avg(double[] v)
@ -183,6 +185,7 @@ public class Schematic
Schematic s = new Schematic(w, h, d); Schematic s = new Schematic(w, h, d);
s.fill(this.s); s.fill(this.s);
s.centeredHeight = centeredHeight; s.centeredHeight = centeredHeight;
s.name = name;
return s; return s;
} }
@ -203,9 +206,11 @@ public class Schematic
return g % 2 == 0 ? m : m + 1; return g % 2 == 0 ? m : m + 1;
} }
@SuppressWarnings("deprecation")
public void place(World source, int wx, int wy, int wz) public void place(World source, int wx, int wy, int wz)
{ {
Location start = new Location(source, wx, wy, wz).clone().add(sh(w), sh(h) + 1, sh(d)).subtract(mount); Location start = new Location(source, wx, wy, wz).clone().add(sh(w), sh(h) + 1, sh(d));
start.subtract(mount);
int highestY = source.getHighestBlockYAt(start); int highestY = source.getHighestBlockYAt(start);
if(start.getBlockY() + mountHeight > highestY) if(start.getBlockY() + mountHeight > highestY)
@ -214,12 +219,24 @@ public class Schematic
} }
start.add(shift); start.add(shift);
GMap<Location, MB> undo = new GMap<>();
for(BlockVector i : getSchematic().k()) for(BlockVector i : getSchematic().k())
{ {
MB b = getSchematic().get(i); MB b = getSchematic().get(i);
Location f = start.clone().add(i); Location f = start.clone().add(i);
if(i.getBlockY() == mountHeight && f.clone().subtract(0, 1, 0).getBlock().isLiquid())
{
for(Location j : undo.k())
{
Catalyst12.setBlock(source, j.getBlockX(), j.getBlockY(), j.getBlockZ(), undo.get(j));
Iris.refresh.add(j.getChunk());
}
return;
}
if(b.material.equals(Material.SKULL)) if(b.material.equals(Material.SKULL))
{ {
continue; continue;
@ -228,6 +245,7 @@ public class Schematic
try try
{ {
Iris.refresh.add(f.getChunk()); Iris.refresh.add(f.getChunk());
undo.put(f, MB.of(f.getBlock().getType(), f.getBlock().getData()));
Catalyst12.setBlock(source, f.getBlockX(), f.getBlockY(), f.getBlockZ(), b); Catalyst12.setBlock(source, f.getBlockX(), f.getBlockY(), f.getBlockZ(), b);
} }
@ -243,7 +261,7 @@ public class Schematic
Schematic s = new Schematic(1, 1, 1); Schematic s = new Schematic(1, 1, 1);
s.read(in); s.read(in);
L.i("Loaded Internal Schematic: " + s.getSchematic().size()); L.i("Loaded Internal Object: " + s.getSchematic().size());
return s; return s;
} }
@ -254,7 +272,7 @@ public class Schematic
FileInputStream fin = new FileInputStream(f); FileInputStream fin = new FileInputStream(f);
s.read(fin); s.read(fin);
L.i("Loaded Schematic: " + f.getPath() + " Size: " + s.getSchematic().size()); L.i("Loaded Object: " + f.getPath() + " Size: " + s.getSchematic().size());
return s; return s;
} }
@ -263,6 +281,19 @@ public class Schematic
return name; return name;
} }
public void rotate(Direction from, Direction to)
{
GMap<BlockVector, MB> g = s.copy();
s.clear();
for(BlockVector i : g.k())
{
s.put(VectorMath.rotate(from, to, i).toBlockVector(), g.get(i));
}
name = name + "-rt" + to.name();
}
public void computeFlag(String j) public void computeFlag(String j)
{ {
try try
@ -271,7 +302,7 @@ public class Schematic
{ {
int downshift = Integer.valueOf(j.split("\\Q=\\E")[1]); int downshift = Integer.valueOf(j.split("\\Q=\\E")[1]);
shift.subtract(new Vector(0, downshift, 0)); shift.subtract(new Vector(0, downshift, 0));
L.i(" Sank Object: 0,0,0 -> " + shift.getBlockX() + "," + shift.getBlockY() + "," + shift.getBlockZ()); L.i("Corrected " + getName() + "'s Mount Height: 0,0,0 -> " + shift.getBlockX() + "," + shift.getBlockY() + "," + shift.getBlockZ());
} }
} }

View File

@ -2,9 +2,12 @@ package ninja.bytecode.iris.schematic;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.locks.ReentrantLock;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.util.Direction;
import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
import ninja.bytecode.shuriken.io.IO; import ninja.bytecode.shuriken.io.IO;
import ninja.bytecode.shuriken.logging.L; import ninja.bytecode.shuriken.logging.L;
@ -71,26 +74,27 @@ public class SchematicGroup
public static SchematicGroup load(String string) public static SchematicGroup load(String string)
{ {
File folder = Iris.loadFolder(string); File folder = Iris.loadFolder(string);
if(folder != null) if(folder != null)
{ {
SchematicGroup g = new SchematicGroup(string); SchematicGroup g = new SchematicGroup(string);
for(File i : folder.listFiles()) for(File i : folder.listFiles())
{ {
if(i.getName().endsWith(".ifl")) if(i.getName().endsWith(".ifl"))
{ {
try try
{ {
g.flags.add(IO.readAll(i).split("\\Q\n\\E")); g.flags.add(IO.readAll(i).split("\\Q\n\\E"));
} }
catch(IOException e) catch(IOException e)
{ {
L.ex(e); L.ex(e);
} }
} }
if(i.getName().endsWith(".ish")) if(i.getName().endsWith(".ish"))
{ {
try try
@ -98,7 +102,7 @@ public class SchematicGroup
Schematic s = Schematic.load(i); Schematic s = Schematic.load(i);
g.getSchematics().add(s); g.getSchematics().add(s);
} }
catch(IOException e) catch(IOException e)
{ {
L.f("Cannot load Schematic: " + string + "/" + i.getName()); L.f("Cannot load Schematic: " + string + "/" + i.getName());
@ -106,27 +110,55 @@ public class SchematicGroup
} }
} }
} }
return g; return g;
} }
return null; return null;
} }
public void processVariants() public void processVariants()
{ {
GList<Schematic> inject = new GList<>();
L.v("Processing " + name + " Objects"); L.v("Processing " + name + " Objects");
L.v("# Creating Rotations for " + getSchematics().size() + " Objects");
ReentrantLock rr = new ReentrantLock();
TaskGroup gg = Iris.buildPool.startWork();
for(Schematic i : getSchematics()) for(Schematic i : getSchematics())
{ {
L.v("# Processing " + i.getName()); for(Direction j : new Direction[] {Direction.S, Direction.E, Direction.W})
L.flush();
i.computeMountShift();
for(String j : flags)
{ {
i.computeFlag(j); Schematic cp = i.copy();
gg.queue(() -> {
Schematic f = cp;
f.rotate(Direction.N, j);
rr.lock();
inject.add(f);
rr.unlock();
});
} }
} }
gg.execute();
gg = Iris.buildPool.startWork();
getSchematics().add(inject);
L.v("# Generated " + inject.size() + " Rotated Objects to " + getName());
for(Schematic i : getSchematics())
{
gg.queue(() -> {
i.computeMountShift();
for(String j : flags)
{
i.computeFlag(j);
}
});
}
gg.execute();
} }
} }

View File

@ -23,12 +23,12 @@ public class IrisBiome
public static final double MAX_HEIGHT = 0.77768; public static final double MAX_HEIGHT = 0.77768;
public static final double IDEAL_HEIGHT = 0.1127; public static final double IDEAL_HEIGHT = 0.1127;
public static final double MIN_HEIGHT = -0.0218; public static final double MIN_HEIGHT = -0.0218;
//@builder //@builder
public static final IrisBiome RIVER = new IrisBiome("River", Biome.RIVER) private static final IrisBiome RIVER = new IrisBiome("River", Biome.RIVER)
.surface(MB.of(Material.SAND)) .surface(MB.of(Material.SAND))
.coreBiome(); .coreBiome();
public static final IrisBiome BEACH = new IrisBiome("Beach", Biome.BEACHES) private static final IrisBiome BEACH = new IrisBiome("Beach", Biome.BEACHES)
.height(-0.078) .height(-0.078)
.coreBiome() .coreBiome()
.surface(MB.of(Material.SAND)); .surface(MB.of(Material.SAND));
@ -40,17 +40,12 @@ public class IrisBiome
.surface(MB.of(Material.GRASS_PATH)) .surface(MB.of(Material.GRASS_PATH))
.coreBiome() .coreBiome()
.scatter(MB.of(Material.TORCH), 0.05); .scatter(MB.of(Material.TORCH), 0.05);
public static final IrisBiome OCEAN = new IrisBiome("Ocean", Biome.OCEAN) private static final IrisBiome OCEAN = new IrisBiome("Ocean", Biome.OCEAN)
.height(-0.5) .height(-0.5)
.coreBiome() .coreBiome()
.surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL)) .surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
.simplexSurface(); .simplexSurface();
public static final IrisBiome LAKE = new IrisBiome("Lake", Biome.DESERT) private static final IrisBiome DEEP_OCEAN = new IrisBiome("Deep Ocean", Biome.DEEP_OCEAN)
.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) .height(-0.88)
.coreBiome() .coreBiome()
.surface(MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL)) .surface(MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
@ -71,6 +66,76 @@ public class IrisBiome
private GMap<String, Double> schematicGroups; private GMap<String, Double> schematicGroups;
private PolygonGenerator.EnumPolygonGenerator<MB> poly; private PolygonGenerator.EnumPolygonGenerator<MB> poly;
public static double getMaxHeight()
{
return MAX_HEIGHT;
}
public static double getIdealHeight()
{
return IDEAL_HEIGHT;
}
public static double getMinHeight()
{
return MIN_HEIGHT;
}
public static IrisBiome getRiver()
{
return RIVER;
}
public static IrisBiome getBeach()
{
return BEACH;
}
public static IrisBiome getRoadGravel()
{
return ROAD_GRAVEL;
}
public static IrisBiome getRoadGrassy()
{
return ROAD_GRASSY;
}
public static IrisBiome getOcean()
{
return OCEAN;
}
public static IrisBiome getDeepOcean()
{
return DEEP_OCEAN;
}
public static GMap<Biome, IrisBiome> getMap()
{
return map;
}
public boolean isScatterSurface()
{
return scatterSurface;
}
public boolean isCore()
{
return core;
}
public boolean isSimplexScatter()
{
return simplexScatter;
}
public PolygonGenerator.EnumPolygonGenerator<MB> getPoly()
{
return poly;
}
public IrisBiome(JSONObject json) public IrisBiome(JSONObject json)
{ {
this("Loading", Biome.OCEAN); this("Loading", Biome.OCEAN);
@ -88,7 +153,7 @@ public class IrisBiome
schematicGroups = new GMap<>(); schematicGroups = new GMap<>();
surface(new MB(Material.GRASS)).dirt(new MB(Material.DIRT), new MB(Material.DIRT, 1)); surface(new MB(Material.GRASS)).dirt(new MB(Material.DIRT), new MB(Material.DIRT, 1));
} }
public void fromJSON(JSONObject o) public void fromJSON(JSONObject o)
{ {
name = o.getString("name"); name = o.getString("name");
@ -99,9 +164,10 @@ public class IrisBiome
J.attempt(() -> scatterChance = scatterFromJSON(o.getJSONArray("scatter"))); J.attempt(() -> scatterChance = scatterFromJSON(o.getJSONArray("scatter")));
J.attempt(() -> simplexScatter = o.getString("surfaceType").equalsIgnoreCase("simplex")); J.attempt(() -> simplexScatter = o.getString("surfaceType").equalsIgnoreCase("simplex"));
J.attempt(() -> scatterSurface = o.getString("surfaceType").equalsIgnoreCase("scatter")); J.attempt(() -> scatterSurface = o.getString("surfaceType").equalsIgnoreCase("scatter"));
J.attempt(() -> { J.attempt(() ->
{
schematicGroups = strFromJSON(o.getJSONArray("objects")); schematicGroups = strFromJSON(o.getJSONArray("objects"));
for(String i : schematicGroups.k()) for(String i : schematicGroups.k())
{ {
L.v("Loading Object Group: " + i); L.v("Loading Object Group: " + i);
@ -109,7 +175,7 @@ public class IrisBiome
} }
}); });
} }
public JSONObject toJSON() public JSONObject toJSON()
{ {
JSONObject j = new JSONObject(); JSONObject j = new JSONObject();
@ -121,34 +187,34 @@ public class IrisBiome
J.attempt(() -> j.put("scatter", scatterToJson(scatterChance))); J.attempt(() -> j.put("scatter", scatterToJson(scatterChance)));
J.attempt(() -> j.put("surfaceType", simplexScatter ? "simplex" : scatterSurface ? "scatter" : "na")); J.attempt(() -> j.put("surfaceType", simplexScatter ? "simplex" : scatterSurface ? "scatter" : "na"));
J.attempt(() -> j.put("objects", strToJson(schematicGroups))); J.attempt(() -> j.put("objects", strToJson(schematicGroups)));
return j; return j;
} }
private GList<MB> mbListFromJSON(JSONArray ja) private GList<MB> mbListFromJSON(JSONArray ja)
{ {
GList<MB> mb = new GList<>(); GList<MB> mb = new GList<>();
for(int i = 0; i < ja.length(); i++) for(int i = 0; i < ja.length(); i++)
{ {
mb.add(MB.of(ja.getString(i))); mb.add(MB.of(ja.getString(i)));
} }
return mb; return mb;
} }
private JSONArray mbListToJSON(GList<MB> mbs) private JSONArray mbListToJSON(GList<MB> mbs)
{ {
JSONArray ja = new JSONArray(); JSONArray ja = new JSONArray();
for(MB i : mbs) for(MB i : mbs)
{ {
ja.put(i.toString()); ja.put(i.toString());
} }
return ja; return ja;
} }
public IrisBiome coreBiome() public IrisBiome coreBiome()
{ {
this.core = true; this.core = true;
@ -158,50 +224,50 @@ public class IrisBiome
private GMap<MB, Double> scatterFromJSON(JSONArray ja) private GMap<MB, Double> scatterFromJSON(JSONArray ja)
{ {
GMap<MB, Double> mb = new GMap<MB, Double>(); GMap<MB, Double> mb = new GMap<MB, Double>();
for(int i = 0; i < ja.length(); i++) for(int i = 0; i < ja.length(); i++)
{ {
String s = ja.getString(i); String s = ja.getString(i);
mb.put(MB.of(s.split("\\Q=\\E")[0]), Double.valueOf(s.split("\\Q=\\E")[1])); mb.put(MB.of(s.split("\\Q=\\E")[0]), Double.valueOf(s.split("\\Q=\\E")[1]));
} }
return mb; return mb;
} }
private JSONArray scatterToJson(GMap<MB, Double> mbs) private JSONArray scatterToJson(GMap<MB, Double> mbs)
{ {
JSONArray ja = new JSONArray(); JSONArray ja = new JSONArray();
for(MB i : mbs.k()) for(MB i : mbs.k())
{ {
ja.put(i.toString() + "=" + mbs.get(i)); ja.put(i.toString() + "=" + mbs.get(i));
} }
return ja; return ja;
} }
private GMap<String, Double> strFromJSON(JSONArray ja) private GMap<String, Double> strFromJSON(JSONArray ja)
{ {
GMap<String, Double> mb = new GMap<String, Double>(); GMap<String, Double> mb = new GMap<String, Double>();
for(int i = 0; i < ja.length(); i++) for(int i = 0; i < ja.length(); i++)
{ {
String s = ja.getString(i); String s = ja.getString(i);
mb.put(s.split("\\Q=\\E")[0], Double.valueOf(s.split("\\Q=\\E")[1])); mb.put(s.split("\\Q=\\E")[0], Double.valueOf(s.split("\\Q=\\E")[1]));
} }
return mb; return mb;
} }
private JSONArray strToJson(GMap<String, Double> mbs) private JSONArray strToJson(GMap<String, Double> mbs)
{ {
JSONArray ja = new JSONArray(); JSONArray ja = new JSONArray();
for(String i : mbs.k()) for(String i : mbs.k())
{ {
ja.put(i.toString() + "=" + mbs.get(i)); ja.put(i.toString() + "=" + mbs.get(i));
} }
return ja; return ja;
} }
@ -233,7 +299,7 @@ public class IrisBiome
return this; return this;
} }
public IrisBiome schematic(String t, double chance) public IrisBiome schematic(String t, double chance)
{ {
schematicGroups.put(t, chance); schematicGroups.put(t, chance);
@ -271,12 +337,12 @@ public class IrisBiome
{ {
this.height = M.lerp(IDEAL_HEIGHT, MAX_HEIGHT, M.clip(height, 0D, 1D)); this.height = M.lerp(IDEAL_HEIGHT, MAX_HEIGHT, M.clip(height, 0D, 1D));
} }
else else
{ {
this.height = M.lerp(MIN_HEIGHT, IDEAL_HEIGHT, M.clip(height, -1D, 0D)); this.height = M.lerp(MIN_HEIGHT, IDEAL_HEIGHT, M.clip(height, -1D, 0D));
} }
return this; return this;
} }
@ -300,7 +366,7 @@ public class IrisBiome
{ {
return height; return height;
} }
public double getAmp() public double getAmp()
{ {
return amp; return amp;
@ -330,7 +396,7 @@ public class IrisBiome
}); });
} }
return poly.getChoice(wx / 3, wz /3); return poly.getChoice(wx / 3, wz / 3);
} }
if(scatterSurface) if(scatterSurface)
@ -358,7 +424,7 @@ public class IrisBiome
{ {
return scatterChance; return scatterChance;
} }
public MB getScatterChanceSingle() public MB getScatterChanceSingle()
{ {
for(MB i : getScatterChance().keySet()) for(MB i : getScatterChance().keySet())
@ -374,9 +440,9 @@ public class IrisBiome
public static GList<IrisBiome> getBiomes() 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); return map.v().remove(IrisBiome.BEACH, IrisBiome.OCEAN, IrisBiome.DEEP_OCEAN, IrisBiome.ROAD_GRASSY, IrisBiome.ROAD_GRAVEL, IrisBiome.BEACH, IrisBiome.RIVER);
} }
public static GList<IrisBiome> getAllBiomes() public static GList<IrisBiome> getAllBiomes()
{ {
return map.v(); return map.v();

View File

@ -1,13 +1,14 @@
package ninja.bytecode.iris.spec; package ninja.bytecode.iris.spec;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.locks.ReentrantLock;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.execution.J; import ninja.bytecode.shuriken.execution.J;
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
import ninja.bytecode.shuriken.json.JSONArray; import ninja.bytecode.shuriken.json.JSONArray;
import ninja.bytecode.shuriken.json.JSONException; import ninja.bytecode.shuriken.json.JSONException;
import ninja.bytecode.shuriken.json.JSONObject; import ninja.bytecode.shuriken.json.JSONObject;
@ -44,6 +45,19 @@ public class IrisDimension
{ {
e.printStackTrace(); e.printStackTrace();
} }
if(o.has("focus"))
{
String focus = o.getString("focus");
for(IrisBiome i : biomes.copy())
{
if(!i.getName().toLowerCase().replaceAll(" ", "_").equals(focus))
{
biomes.remove(i);
}
}
}
} }
public JSONObject toJSON() public JSONObject toJSON()
@ -60,14 +74,23 @@ public class IrisDimension
private GList<IrisBiome> biomesFromArray(JSONArray a) throws JSONException, IOException private GList<IrisBiome> biomesFromArray(JSONArray a) throws JSONException, IOException
{ {
GList<IrisBiome> b = new GList<>(); GList<IrisBiome> b = new GList<>();
TaskGroup g = Iris.buildPool.startWork();
ReentrantLock lock = new ReentrantLock();
for(int i = 0; i < a.length(); i++) for(int i = 0; i < a.length(); i++)
{ {
IrisBiome bb = Iris.loadBiome(a.getString(i)); int ii = i;
Iris.biomes.put(a.getString(i), bb); g.queue(() -> {
b.add(bb); IrisBiome bb = Iris.loadBiome(a.getString(ii));
lock.lock();
Iris.biomes.put(a.getString(ii), bb);
b.add(bb);
lock.unlock();
});
} }
g.execute();
return b; return b;
} }

View File

@ -0,0 +1,19 @@
{
"name": "Beach",
"derivative": "BEACHES",
"height": -0.078,
"surface": [
"SAND"
],
"dirt": [
"SAND",
"SAND",
"SAND",
"CLAY",
"GRAVEL"
],
"objects": [
"tree/palm/medium=0.35",
"tree/palm/small=1.95"
]
}

View File

@ -11,7 +11,6 @@
"DEAD_BUSH=0.008" "DEAD_BUSH=0.008"
], ],
"objects": [ "objects": [
"tree/palm/medium=0.25", "colossal/dead/massive=0.00023"
"tree/palm/small=2.5"
] ]
} }

View File

@ -9,5 +9,8 @@
], ],
"scatter":[ "scatter":[
"DEAD_BUSH=0.005" "DEAD_BUSH=0.005"
],
"objects": [
"colossal/dead/massive=0.00023"
] ]
} }

View File

@ -9,5 +9,8 @@
], ],
"scatter":[ "scatter":[
"DEAD_BUSH=0.008" "DEAD_BUSH=0.008"
],
"objects": [
"colossal/willow/dead/supermassive=0.00033"
] ]
} }

View File

@ -8,8 +8,8 @@
"objects": [ "objects": [
"tree/oak/medium=0.33", "tree/oak/medium=0.33",
"tree/oak/small=2.2", "tree/oak/small=2.2",
"colossal/oak/massive=0.004", "colossal/oak/massive=0.001",
"colossal/oak/superlarge=0.002", "colossal/oak/superlarge=0.0004",
"colossal/oak/supermassive=0.001" "colossal/oak/supermassive=0.0001"
] ]
} }

View File

@ -4,5 +4,9 @@
"scatter":[ "scatter":[
"LONG_GRASS:1=0.23", "LONG_GRASS:1=0.23",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"
],
"objects": [
"tree/birch/medium=0.33",
"tree/birch/small=2.2"
] ]
} }

View File

@ -4,5 +4,9 @@
"scatter":[ "scatter":[
"LONG_GRASS:1=0.23", "LONG_GRASS:1=0.23",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"
],
"objects": [
"tree/birch/medium=0.33",
"tree/birch/small=2.2"
] ]
} }

View File

@ -19,5 +19,13 @@
"scatter":[ "scatter":[
"LONG_GRASS:1=0.13" "LONG_GRASS:1=0.13"
], ],
"surfaceType": "simplex" "surfaceType": "simplex",
"objects": [
"colossal/dead/fallen/massive=0.0005",
"colossal/dead/massive=0.0007",
"colossal/dead/tainted/massive=0.0007",
"colossal/dead/superlarge=0.0006",
"colossal/dead/wilted/supermassive=0.0004",
"colossal/dead/supermassive=0.0005"
]
} }

View File

@ -4,5 +4,12 @@
"scatter":[ "scatter":[
"LONG_GRASS:1=0.23", "LONG_GRASS:1=0.23",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"
],
"objects": [
"tree/oak/medium=0.23",
"tree/oak/small=2.5",
"colossal/oak/massive=0.001",
"colossal/oak/superlarge=0.0004",
"colossal/oak/supermassive=0.0001"
] ]
} }

View File

@ -4,5 +4,10 @@
"scatter":[ "scatter":[
"LONG_GRASS:1=0.13", "LONG_GRASS:1=0.13",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"
],
"objects": [
"tree/oak/medium=0.11",
"tree/oak/small=3.2",
"colossal/oak/massive=0.0005"
] ]
} }

View File

@ -4,5 +4,8 @@
"scatter":[ "scatter":[
"LONG_GRASS:1=0.33", "LONG_GRASS:1=0.33",
"LONG_GRASS:2=0.02" "LONG_GRASS:2=0.02"
],
"objects": [
"colossal/jungle/massive=0.001"
] ]
} }

View File

@ -1,5 +1,6 @@
{ {
"name": "Mountains", "name": "Mountains",
"height": 0.35,
"derivative": "EXTREME_HILLS", "derivative": "EXTREME_HILLS",
"scatter":[ "scatter":[
"LONG_GRASS:2=0.04" "LONG_GRASS:2=0.04"

View File

@ -9,5 +9,10 @@
"surfaceType": "simplex", "surfaceType": "simplex",
"scatter": [ "scatter": [
"LONG_GRASS:2=0.07" "LONG_GRASS:2=0.07"
],
"objects": [
"tree/spruce/medium=0.67",
"tree/spruce/small=2.7",
"tree/spruce/dead/medium=0.09"
] ]
} }

View File

@ -1,17 +0,0 @@
{
"name": "Biome Name",
"derivative": "PLAINS",
"height": 0,
"surface": [
"GRASS"
],
"dirt": [
"DIRT",
"DIRT:1"
],
"scatter":[
"LONG_GRASS:1=0.13"
],
"surfaceType": "na",
"schematics": []
}

View File

@ -27,6 +27,6 @@
"ice_mountains", "ice_mountains",
"redwood_forest", "redwood_forest",
"redwood_forest_hills", "redwood_forest_hills",
"mushroom_island" "beach"
] ]
} }

View File

@ -0,0 +1 @@
sink=2

View File

@ -0,0 +1 @@
sink=6

View File

@ -0,0 +1 @@
sink=8

View File

@ -0,0 +1 @@
sink=9

View File

@ -0,0 +1 @@
sink=6

View File

@ -0,0 +1 @@
sink=8

View File

@ -0,0 +1 @@
sink=10

View File

@ -0,0 +1 @@
sink=2