diff --git a/src/main/java/ninja/bytecode/iris/CommandIsh.java b/src/main/java/ninja/bytecode/iris/CommandIsh.java index 8b684312e..26c801658 100644 --- a/src/main/java/ninja/bytecode/iris/CommandIsh.java +++ b/src/main/java/ninja/bytecode/iris/CommandIsh.java @@ -29,6 +29,7 @@ public class CommandIsh implements CommandExecutor s.sendMessage(ChatColor.DARK_PURPLE + "[" + ChatColor.GRAY + "Iris" + ChatColor.DARK_PURPLE + "]" + ChatColor.GRAY + ": " + msg); } + @SuppressWarnings("deprecation") @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { diff --git a/src/main/java/ninja/bytecode/iris/Iris.java b/src/main/java/ninja/bytecode/iris/Iris.java index ff3051829..ace1ac92a 100644 --- a/src/main/java/ninja/bytecode/iris/Iris.java +++ b/src/main/java/ninja/bytecode/iris/Iris.java @@ -32,6 +32,7 @@ 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.PrecisionStopwatch; import ninja.bytecode.shuriken.bench.Profiler; import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.collections.GSet; @@ -48,6 +49,7 @@ public class Iris extends JavaPlugin implements Listener public static GSet refresh = new GSet<>(); public static Profiler profiler; public static TaskExecutor genPool; + public static TaskExecutor buildPool; public static IrisGenerator gen; public static Settings settings; public static Iris instance; @@ -58,6 +60,7 @@ public class Iris extends JavaPlugin implements Listener public void onEnable() { + PrecisionStopwatch stopwatch = PrecisionStopwatch.start(); Direction.calculatePermutations(); dimensions = new GMap<>(); biomes = new GMap<>(); @@ -66,6 +69,7 @@ public class Iris extends JavaPlugin implements Listener values = new GMap<>(); instance = this; settings = new Settings(); + buildPool = new TaskExecutor(getTC(), settings.performance.threadPriority, "Iris Compiler"); J.attempt(() -> createTempCache()); loadContent(); processContent(); @@ -97,12 +101,20 @@ public class Iris extends JavaPlugin implements Listener 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() { L.v("Processing Content"); - + for(SchematicGroup i : schematics.v()) { i.processVariants(); @@ -115,7 +127,7 @@ public class Iris extends JavaPlugin implements Listener { return new File(Iris.instance.getDataFolder(), 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; - + for(SchematicGroup i : schematics.v()) { - m+=i.size(); + m += i.size(); } L.i("Dimensions: " + dimensions.size()); L.i("Biomes: " + biomes.size()); L.i("Object Groups: " + schematics.size()); L.i("Objects: " + F.f(m)); - - + L.flush(); } @@ -238,23 +249,23 @@ public class Iris extends JavaPlugin implements Listener L.i("Loading Iris Biome " + s); return new IrisBiome(loadJSON("pack/biomes/" + s + ".json")); } - + public static SchematicGroup loadSchematicGroup(String s) { - SchematicGroup g = SchematicGroup.load("pack/objects/" + s); - + SchematicGroup g = SchematicGroup.load("pack/objects/" + s); + if(g != null) { schematics.put(s, g); L.i("Loaded Object Group: " + g.getName() + " (" + g.getSchematics().size() + " Objects)"); return g; } - + L.i("Cannot load Object Group: " + s); - + return null; } - + public static Schematic loadSchematic(String s) throws IOException { L.i("Loading Iris Object " + s); @@ -269,28 +280,28 @@ public class Iris extends JavaPlugin implements Listener public static File loadFolder(String string) { File internal = internalResource(string); - + if(internal.exists()) { L.v("Loading Group: " + string); return internal; } - + L.f("Cannot find folder: " + internal.getAbsolutePath()); return null; } - + public static InputStream loadResource(String string) throws IOException { File internal = internalResource(string); - + if(internal.exists()) { L.v("Loading Resource: " + internal.getAbsolutePath()); L.flush(); return new FileInputStream(internal); } - + else { L.f("Cannot find Resource: " + internal.getAbsolutePath()); diff --git a/src/main/java/ninja/bytecode/iris/Settings.java b/src/main/java/ninja/bytecode/iris/Settings.java index 44305d2b9..54c78dafa 100644 --- a/src/main/java/ninja/bytecode/iris/Settings.java +++ b/src/main/java/ninja/bytecode/iris/Settings.java @@ -9,9 +9,9 @@ public class Settings public static class PerformanceSettings { - public PerformanceMode performanceMode = PerformanceMode.UNLIMITED; - public int threadCount = 12; - public int threadPriority = Thread.MAX_PRIORITY; + public PerformanceMode performanceMode = PerformanceMode.MATCH_CPU; + public int threadCount = 1; + public int threadPriority = Thread.MIN_PRIORITY; public boolean loadonstart = true; } @@ -20,7 +20,7 @@ public class Settings public double horizontalZoom = 1; // 0.525 public double heightFracture = 155; public double landScale = 0.205; - public double landChance = 0.529; + public double landChance = 0.6; public double roughness = 1.333; public double heightMultiplier = 0.806; public double heightExponentBase = 1; @@ -30,7 +30,7 @@ public class Settings public double baseHeight = 0.165; public int seaLevel = 63; public double caveDensity = 1; - public double biomeScale = 2.5; + public double biomeScale = 2; public boolean flatBedrock = false; public boolean doSchematics = true; } diff --git a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java index 1a580867b..4e55c7cd8 100644 --- a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java @@ -55,9 +55,11 @@ public class IrisGenerator extends ParallelChunkGenerator MB.of(Material.SMOOTH_BRICK, 2), MB.of(Material.SMOOTH_BRICK, 3), }); + public GMap biomeCache = new GMap<>(); //@done private MB WATER = new MB(Material.STATIONARY_WATER); private MB BEDROCK = new MB(Material.BEDROCK); + private GList internal; private GenLayerBase glBase; private GenLayerLayeredNoise glLNoise; private GenLayerRidge glRidge; @@ -78,18 +80,38 @@ public class IrisGenerator extends ParallelChunkGenerator { this(Iris.dimensions.get("overworld")); } - + public GList getLoadedBiomes() { - return IrisBiome.getAllBiomes().copy().add(dim.getBiomes()); + return internal; } - + public IrisGenerator(IrisDimension dim) { this.dim = dim; 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 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); } + public IrisBiome biome(String name) + { + return biomeCache.get(name); + } + @Override 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) { - override = IrisBiome.BEACH; + override = biome("Beach"); } else if(height < 63) { if(height < 36) { - override = IrisBiome.DEEP_OCEAN; - } - - else if(height < 50) - { - override = IrisBiome.OCEAN; + override = biome("Deep Ocean"); } else { - override = IrisBiome.LAKE; + override = biome("Ocean"); } } @@ -277,4 +299,14 @@ public class IrisGenerator extends ParallelChunkGenerator { return world; } + + public GMap getSchematicCache() + { + return schematicCache; + } + + public void setSchematicCache(GMap schematicCache) + { + this.schematicCache = schematicCache; + } } \ No newline at end of file diff --git a/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java b/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java index c35e2cfab..5b03c140c 100644 --- a/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java +++ b/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java @@ -45,13 +45,13 @@ 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; + IrisBiome cbi = iris.biome("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; + cbi = iris.biome("Beach"); } 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)) { - return IrisBiome.RIVER; + return iris.biome("River"); } } @@ -68,7 +68,7 @@ public class GenLayerBiome extends GenLayer 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)) { @@ -84,7 +84,7 @@ public class GenLayerBiome extends GenLayer else if(land < 0.3) { - cbi = IrisBiome.DEEP_OCEAN; + cbi = iris.biome("Deep Ocean"); } return cbi; diff --git a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java index 470ec109a..555892a9d 100644 --- a/src/main/java/ninja/bytecode/iris/schematic/Schematic.java +++ b/src/main/java/ninja/bytecode/iris/schematic/Schematic.java @@ -17,7 +17,9 @@ import org.bukkit.util.Vector; import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.util.Catalyst12; +import ninja.bytecode.iris.util.Direction; import ninja.bytecode.iris.util.MB; +import ninja.bytecode.iris.util.VectorMath; import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.io.CustomOutputStream; @@ -82,7 +84,7 @@ public class Schematic mountHeight = avg(avy); 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) @@ -183,6 +185,7 @@ public class Schematic Schematic s = new Schematic(w, h, d); s.fill(this.s); s.centeredHeight = centeredHeight; + s.name = name; return s; } @@ -203,9 +206,11 @@ public class Schematic return g % 2 == 0 ? m : m + 1; } + @SuppressWarnings("deprecation") 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); if(start.getBlockY() + mountHeight > highestY) @@ -214,12 +219,24 @@ public class Schematic } start.add(shift); + GMap undo = new GMap<>(); for(BlockVector i : getSchematic().k()) { MB b = getSchematic().get(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)) { continue; @@ -228,6 +245,7 @@ public class Schematic try { 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); } @@ -243,7 +261,7 @@ public class Schematic Schematic s = new Schematic(1, 1, 1); s.read(in); - L.i("Loaded Internal Schematic: " + s.getSchematic().size()); + L.i("Loaded Internal Object: " + s.getSchematic().size()); return s; } @@ -254,7 +272,7 @@ public class Schematic FileInputStream fin = new FileInputStream(f); 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; } @@ -263,6 +281,19 @@ public class Schematic return name; } + public void rotate(Direction from, Direction to) + { + GMap 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) { try @@ -271,7 +302,7 @@ public class Schematic { int downshift = Integer.valueOf(j.split("\\Q=\\E")[1]); 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()); } } diff --git a/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java b/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java index aa625100a..d191010d2 100644 --- a/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java +++ b/src/main/java/ninja/bytecode/iris/schematic/SchematicGroup.java @@ -2,9 +2,12 @@ package ninja.bytecode.iris.schematic; import java.io.File; import java.io.IOException; +import java.util.concurrent.locks.ReentrantLock; import ninja.bytecode.iris.Iris; +import ninja.bytecode.iris.util.Direction; import ninja.bytecode.shuriken.collections.GList; +import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup; import ninja.bytecode.shuriken.io.IO; import ninja.bytecode.shuriken.logging.L; @@ -71,26 +74,27 @@ public class SchematicGroup public static SchematicGroup load(String string) { File folder = Iris.loadFolder(string); - + if(folder != null) { SchematicGroup g = new SchematicGroup(string); for(File i : folder.listFiles()) { + if(i.getName().endsWith(".ifl")) { try { g.flags.add(IO.readAll(i).split("\\Q\n\\E")); } - + catch(IOException e) { L.ex(e); } } - + if(i.getName().endsWith(".ish")) { try @@ -98,7 +102,7 @@ public class SchematicGroup Schematic s = Schematic.load(i); g.getSchematics().add(s); } - + catch(IOException e) { L.f("Cannot load Schematic: " + string + "/" + i.getName()); @@ -106,27 +110,55 @@ public class SchematicGroup } } } - + return g; } - + return null; } public void processVariants() { + GList inject = new GList<>(); 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()) { - L.v("# Processing " + i.getName()); - L.flush(); - i.computeMountShift(); - - for(String j : flags) + for(Direction j : new Direction[] {Direction.S, Direction.E, Direction.W}) { - 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(); } } diff --git a/src/main/java/ninja/bytecode/iris/spec/IrisBiome.java b/src/main/java/ninja/bytecode/iris/spec/IrisBiome.java index db422bff7..bc59a02c3 100644 --- a/src/main/java/ninja/bytecode/iris/spec/IrisBiome.java +++ b/src/main/java/ninja/bytecode/iris/spec/IrisBiome.java @@ -23,12 +23,12 @@ 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) + private 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) + private static final IrisBiome BEACH = new IrisBiome("Beach", Biome.BEACHES) .height(-0.078) .coreBiome() .surface(MB.of(Material.SAND)); @@ -40,17 +40,12 @@ public class IrisBiome .surface(MB.of(Material.GRASS_PATH)) .coreBiome() .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) .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) + private 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)) @@ -71,6 +66,76 @@ public class IrisBiome private GMap schematicGroups; private PolygonGenerator.EnumPolygonGenerator 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 getMap() + { + return map; + } + + public boolean isScatterSurface() + { + return scatterSurface; + } + + public boolean isCore() + { + return core; + } + + public boolean isSimplexScatter() + { + return simplexScatter; + } + + public PolygonGenerator.EnumPolygonGenerator getPoly() + { + return poly; + } + public IrisBiome(JSONObject json) { this("Loading", Biome.OCEAN); @@ -88,7 +153,7 @@ public class IrisBiome 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"); @@ -99,9 +164,10 @@ public class IrisBiome 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(() -> { + J.attempt(() -> + { schematicGroups = strFromJSON(o.getJSONArray("objects")); - + for(String i : schematicGroups.k()) { L.v("Loading Object Group: " + i); @@ -109,7 +175,7 @@ public class IrisBiome } }); } - + public JSONObject toJSON() { JSONObject j = new JSONObject(); @@ -121,34 +187,34 @@ public class IrisBiome J.attempt(() -> j.put("scatter", scatterToJson(scatterChance))); J.attempt(() -> j.put("surfaceType", simplexScatter ? "simplex" : scatterSurface ? "scatter" : "na")); J.attempt(() -> j.put("objects", strToJson(schematicGroups))); - + return j; } - + private GList mbListFromJSON(JSONArray ja) { GList mb = new GList<>(); - + for(int i = 0; i < ja.length(); i++) { mb.add(MB.of(ja.getString(i))); } - + return mb; } - + private JSONArray mbListToJSON(GList mbs) { JSONArray ja = new JSONArray(); - + for(MB i : mbs) { ja.put(i.toString()); } - + return ja; } - + public IrisBiome coreBiome() { this.core = true; @@ -158,50 +224,50 @@ public class IrisBiome private GMap scatterFromJSON(JSONArray ja) { GMap mb = new GMap(); - + 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 mbs) { JSONArray ja = new JSONArray(); - + for(MB i : mbs.k()) { ja.put(i.toString() + "=" + mbs.get(i)); } - + return ja; } - + private GMap strFromJSON(JSONArray ja) { GMap mb = new GMap(); - + 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 mbs) { JSONArray ja = new JSONArray(); - + for(String i : mbs.k()) { ja.put(i.toString() + "=" + mbs.get(i)); } - + return ja; } @@ -233,7 +299,7 @@ public class IrisBiome return this; } - + public IrisBiome schematic(String t, double 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)); } - + else { this.height = M.lerp(MIN_HEIGHT, IDEAL_HEIGHT, M.clip(height, -1D, 0D)); } - + return this; } @@ -300,7 +366,7 @@ public class IrisBiome { return height; } - + public double getAmp() { 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) @@ -358,7 +424,7 @@ public class IrisBiome { return scatterChance; } - + public MB getScatterChanceSingle() { for(MB i : getScatterChance().keySet()) @@ -374,9 +440,9 @@ public class IrisBiome public static GList 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 getAllBiomes() { return map.v(); diff --git a/src/main/java/ninja/bytecode/iris/spec/IrisDimension.java b/src/main/java/ninja/bytecode/iris/spec/IrisDimension.java index ec7a3bc1b..2e34f7b44 100644 --- a/src/main/java/ninja/bytecode/iris/spec/IrisDimension.java +++ b/src/main/java/ninja/bytecode/iris/spec/IrisDimension.java @@ -1,13 +1,14 @@ package ninja.bytecode.iris.spec; import java.io.IOException; +import java.util.concurrent.locks.ReentrantLock; 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.execution.TaskExecutor.TaskGroup; import ninja.bytecode.shuriken.json.JSONArray; import ninja.bytecode.shuriken.json.JSONException; import ninja.bytecode.shuriken.json.JSONObject; @@ -44,6 +45,19 @@ public class IrisDimension { 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() @@ -60,14 +74,23 @@ public class IrisDimension private GList biomesFromArray(JSONArray a) throws JSONException, IOException { GList b = new GList<>(); + TaskGroup g = Iris.buildPool.startWork(); + ReentrantLock lock = new ReentrantLock(); 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); + int ii = i; + g.queue(() -> { + 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; } diff --git a/src/main/resources/pack/biomes/beach.json b/src/main/resources/pack/biomes/beach.json new file mode 100644 index 000000000..7ece52280 --- /dev/null +++ b/src/main/resources/pack/biomes/beach.json @@ -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" + ] +} \ No newline at end of file diff --git a/src/main/resources/pack/biomes/desert.json b/src/main/resources/pack/biomes/desert.json index 9fc342864..9e8493e78 100644 --- a/src/main/resources/pack/biomes/desert.json +++ b/src/main/resources/pack/biomes/desert.json @@ -11,7 +11,6 @@ "DEAD_BUSH=0.008" ], "objects": [ - "tree/palm/medium=0.25", - "tree/palm/small=2.5" + "colossal/dead/massive=0.00023" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/desert_hills.json b/src/main/resources/pack/biomes/desert_hills.json index 0d64b3b96..d19be418a 100644 --- a/src/main/resources/pack/biomes/desert_hills.json +++ b/src/main/resources/pack/biomes/desert_hills.json @@ -9,5 +9,8 @@ ], "scatter":[ "DEAD_BUSH=0.005" + ], + "objects": [ + "colossal/dead/massive=0.00023" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/desert_red.json b/src/main/resources/pack/biomes/desert_red.json index f4617e56b..cfd8e756d 100644 --- a/src/main/resources/pack/biomes/desert_red.json +++ b/src/main/resources/pack/biomes/desert_red.json @@ -9,5 +9,8 @@ ], "scatter":[ "DEAD_BUSH=0.008" + ], + "objects": [ + "colossal/willow/dead/supermassive=0.00033" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/forest.json b/src/main/resources/pack/biomes/forest.json index a94948978..d3f0a6c9c 100644 --- a/src/main/resources/pack/biomes/forest.json +++ b/src/main/resources/pack/biomes/forest.json @@ -8,8 +8,8 @@ "objects": [ "tree/oak/medium=0.33", "tree/oak/small=2.2", - "colossal/oak/massive=0.004", - "colossal/oak/superlarge=0.002", - "colossal/oak/supermassive=0.001" + "colossal/oak/massive=0.001", + "colossal/oak/superlarge=0.0004", + "colossal/oak/supermassive=0.0001" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/forest_birch.json b/src/main/resources/pack/biomes/forest_birch.json index 2788fab64..a57537ad1 100644 --- a/src/main/resources/pack/biomes/forest_birch.json +++ b/src/main/resources/pack/biomes/forest_birch.json @@ -4,5 +4,9 @@ "scatter":[ "LONG_GRASS:1=0.23", "LONG_GRASS:2=0.13" + ], + "objects": [ + "tree/birch/medium=0.33", + "tree/birch/small=2.2" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/forest_birch_hills.json b/src/main/resources/pack/biomes/forest_birch_hills.json index 5ef39593a..2e7b22ce9 100644 --- a/src/main/resources/pack/biomes/forest_birch_hills.json +++ b/src/main/resources/pack/biomes/forest_birch_hills.json @@ -4,5 +4,9 @@ "scatter":[ "LONG_GRASS:1=0.23", "LONG_GRASS:2=0.13" + ], + "objects": [ + "tree/birch/medium=0.33", + "tree/birch/small=2.2" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/forest_haunted.json b/src/main/resources/pack/biomes/forest_haunted.json index d37cc6aa4..9ce86678f 100644 --- a/src/main/resources/pack/biomes/forest_haunted.json +++ b/src/main/resources/pack/biomes/forest_haunted.json @@ -19,5 +19,13 @@ "scatter":[ "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" + ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/forest_hills.json b/src/main/resources/pack/biomes/forest_hills.json index 401a252a8..7c2c403b7 100644 --- a/src/main/resources/pack/biomes/forest_hills.json +++ b/src/main/resources/pack/biomes/forest_hills.json @@ -4,5 +4,12 @@ "scatter":[ "LONG_GRASS:1=0.23", "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" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/forest_mountains.json b/src/main/resources/pack/biomes/forest_mountains.json index a7ce258bf..aa5235031 100644 --- a/src/main/resources/pack/biomes/forest_mountains.json +++ b/src/main/resources/pack/biomes/forest_mountains.json @@ -4,5 +4,10 @@ "scatter":[ "LONG_GRASS:1=0.13", "LONG_GRASS:2=0.13" + ], + "objects": [ + "tree/oak/medium=0.11", + "tree/oak/small=3.2", + "colossal/oak/massive=0.0005" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/jungle_hills.json b/src/main/resources/pack/biomes/jungle_hills.json index b0d93d117..3e26ef818 100644 --- a/src/main/resources/pack/biomes/jungle_hills.json +++ b/src/main/resources/pack/biomes/jungle_hills.json @@ -4,5 +4,8 @@ "scatter":[ "LONG_GRASS:1=0.33", "LONG_GRASS:2=0.02" + ], + "objects": [ + "colossal/jungle/massive=0.001" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/mountains.json b/src/main/resources/pack/biomes/mountains.json index 8e55b074f..1bf8977ac 100644 --- a/src/main/resources/pack/biomes/mountains.json +++ b/src/main/resources/pack/biomes/mountains.json @@ -1,5 +1,6 @@ { "name": "Mountains", + "height": 0.35, "derivative": "EXTREME_HILLS", "scatter":[ "LONG_GRASS:2=0.04" diff --git a/src/main/resources/pack/biomes/redwood_forest.json b/src/main/resources/pack/biomes/redwood_forest.json index b5351e76a..2c25dde77 100644 --- a/src/main/resources/pack/biomes/redwood_forest.json +++ b/src/main/resources/pack/biomes/redwood_forest.json @@ -9,5 +9,10 @@ "surfaceType": "simplex", "scatter": [ "LONG_GRASS:2=0.07" + ], + "objects": [ + "tree/spruce/medium=0.67", + "tree/spruce/small=2.7", + "tree/spruce/dead/medium=0.09" ] } \ No newline at end of file diff --git a/src/main/resources/pack/biomes/temp.json b/src/main/resources/pack/biomes/temp.json deleted file mode 100644 index 1c3d28071..000000000 --- a/src/main/resources/pack/biomes/temp.json +++ /dev/null @@ -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": [] -} \ No newline at end of file diff --git a/src/main/resources/pack/dimensions/overworld.json b/src/main/resources/pack/dimensions/overworld.json index 048200ca5..0bae4f455 100644 --- a/src/main/resources/pack/dimensions/overworld.json +++ b/src/main/resources/pack/dimensions/overworld.json @@ -27,6 +27,6 @@ "ice_mountains", "redwood_forest", "redwood_forest_hills", - "mushroom_island" + "beach" ] } \ No newline at end of file diff --git a/src/main/resources/pack/objects/colossal/dead/fallen/massive/flags.ifl b/src/main/resources/pack/objects/colossal/dead/fallen/massive/flags.ifl new file mode 100644 index 000000000..ec2ad24ae --- /dev/null +++ b/src/main/resources/pack/objects/colossal/dead/fallen/massive/flags.ifl @@ -0,0 +1 @@ +sink=2 \ No newline at end of file diff --git a/src/main/resources/pack/objects/colossal/dead/massive/flags.ifl b/src/main/resources/pack/objects/colossal/dead/massive/flags.ifl new file mode 100644 index 000000000..dfce70806 --- /dev/null +++ b/src/main/resources/pack/objects/colossal/dead/massive/flags.ifl @@ -0,0 +1 @@ +sink=6 \ No newline at end of file diff --git a/src/main/resources/pack/objects/colossal/dead/superlarge/flags.ifl b/src/main/resources/pack/objects/colossal/dead/superlarge/flags.ifl new file mode 100644 index 000000000..57d0909e8 --- /dev/null +++ b/src/main/resources/pack/objects/colossal/dead/superlarge/flags.ifl @@ -0,0 +1 @@ +sink=8 \ No newline at end of file diff --git a/src/main/resources/pack/objects/colossal/dead/supermassive/flags.ifl b/src/main/resources/pack/objects/colossal/dead/supermassive/flags.ifl new file mode 100644 index 000000000..cac06044d --- /dev/null +++ b/src/main/resources/pack/objects/colossal/dead/supermassive/flags.ifl @@ -0,0 +1 @@ +sink=9 \ No newline at end of file diff --git a/src/main/resources/pack/objects/colossal/dead/tainted/massive/flags.ifl b/src/main/resources/pack/objects/colossal/dead/tainted/massive/flags.ifl new file mode 100644 index 000000000..dfce70806 --- /dev/null +++ b/src/main/resources/pack/objects/colossal/dead/tainted/massive/flags.ifl @@ -0,0 +1 @@ +sink=6 \ No newline at end of file diff --git a/src/main/resources/pack/objects/colossal/dead/wilted/supermassive/flags.ifl b/src/main/resources/pack/objects/colossal/dead/wilted/supermassive/flags.ifl new file mode 100644 index 000000000..cac06044d --- /dev/null +++ b/src/main/resources/pack/objects/colossal/dead/wilted/supermassive/flags.ifl @@ -0,0 +1 @@ +sink=9 \ No newline at end of file diff --git a/src/main/resources/pack/objects/colossal/oak/massive/flags.ifl b/src/main/resources/pack/objects/colossal/oak/massive/flags.ifl new file mode 100644 index 000000000..dfce70806 --- /dev/null +++ b/src/main/resources/pack/objects/colossal/oak/massive/flags.ifl @@ -0,0 +1 @@ +sink=6 \ No newline at end of file diff --git a/src/main/resources/pack/objects/colossal/oak/superlarge/flags.ifl b/src/main/resources/pack/objects/colossal/oak/superlarge/flags.ifl new file mode 100644 index 000000000..57d0909e8 --- /dev/null +++ b/src/main/resources/pack/objects/colossal/oak/superlarge/flags.ifl @@ -0,0 +1 @@ +sink=8 \ No newline at end of file diff --git a/src/main/resources/pack/objects/colossal/oak/supermassive/flags.ifl b/src/main/resources/pack/objects/colossal/oak/supermassive/flags.ifl new file mode 100644 index 000000000..5210196e6 --- /dev/null +++ b/src/main/resources/pack/objects/colossal/oak/supermassive/flags.ifl @@ -0,0 +1 @@ +sink=10 \ No newline at end of file diff --git a/src/main/resources/pack/objects/tree/palm/medium/flags.ifl b/src/main/resources/pack/objects/tree/palm/medium/flags.ifl new file mode 100644 index 000000000..ec2ad24ae --- /dev/null +++ b/src/main/resources/pack/objects/tree/palm/medium/flags.ifl @@ -0,0 +1 @@ +sink=2 \ No newline at end of file