diff --git a/src/main/java/ninja/bytecode/iris/CommandIris.java b/src/main/java/ninja/bytecode/iris/CommandIris.java index 9b7326a10..c6409bc2b 100644 --- a/src/main/java/ninja/bytecode/iris/CommandIris.java +++ b/src/main/java/ninja/bytecode/iris/CommandIris.java @@ -7,6 +7,7 @@ import org.bukkit.ChatColor; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.block.Biome; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; diff --git a/src/main/java/ninja/bytecode/iris/Settings.java b/src/main/java/ninja/bytecode/iris/Settings.java index 9e2a6980b..269d6c90d 100644 --- a/src/main/java/ninja/bytecode/iris/Settings.java +++ b/src/main/java/ninja/bytecode/iris/Settings.java @@ -12,7 +12,7 @@ public class Settings public static class PerformanceSettings { public PerformanceMode performanceMode = PerformanceMode.DOUBLE_CPU; - public ObjectMode objectMode = ObjectMode.NONE; + public ObjectMode objectMode = ObjectMode.PARALLAX; public boolean fastMode = false; public int threadPriority = Thread.MAX_PRIORITY; public int threadCount = 4; diff --git a/src/main/java/ninja/bytecode/iris/controller/PackController.java b/src/main/java/ninja/bytecode/iris/controller/PackController.java index c64fa6efb..62610f1e0 100644 --- a/src/main/java/ninja/bytecode/iris/controller/PackController.java +++ b/src/main/java/ninja/bytecode/iris/controller/PackController.java @@ -126,11 +126,19 @@ public class PackController implements IrisController if(j.isSnowy()) { - GenObjectGroup ggx = genObjectGroups.get(k).copy("-snowy-" + j.getSnow()); - ggx.applySnowFilter((int) (j.getSnow() * 4)); - d.registerObject(ggx); - j.getSchematicGroups().put(ggx.getName(), j.getSchematicGroups().get(k)); - j.getSchematicGroups().remove(k); + try + { + GenObjectGroup ggx = genObjectGroups.get(k).copy("-snowy-" + j.getSnow()); + ggx.applySnowFilter((int) (j.getSnow() * 4)); + d.registerObject(ggx); + j.getSchematicGroups().put(ggx.getName(), j.getSchematicGroups().get(k)); + j.getSchematicGroups().remove(k); + } + + catch(Throwable e) + { + e.printStackTrace(); + } } } } diff --git a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java index 53c1fdd36..3f604f85d 100644 --- a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java @@ -31,7 +31,6 @@ import ninja.bytecode.iris.util.InterpolationMode; import ninja.bytecode.iris.util.IrisInterpolation; import ninja.bytecode.iris.util.MB; import ninja.bytecode.iris.util.ObjectMode; -import ninja.bytecode.iris.util.PolygonGenerator; import ninja.bytecode.iris.util.SChunkVector; import ninja.bytecode.shuriken.bench.PrecisionStopwatch; import ninja.bytecode.shuriken.collections.GList; @@ -122,8 +121,8 @@ public class IrisGenerator extends ParallaxWorldGenerator } random = new Random(world.getSeed()); rTerrain = new RNG(world.getSeed()); - swirl = new CNG(rTerrain.nextParallelRNG(0), 40, 1).scale(0.012); - beach = new CNG(rTerrain.nextParallelRNG(0), 6, 1).scale(0.15); + swirl = new CNG(rTerrain.nextParallelRNG(0), 40, 1).scale(0.007); + beach = new CNG(rTerrain.nextParallelRNG(0), 3, 1).scale(0.15); glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2)); glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes()); glSnow = new GenLayerSnow(this, world, random, rTerrain.nextParallelRNG(5)); @@ -282,7 +281,46 @@ public class IrisGenerator extends ParallaxWorldGenerator return hits; } - PolygonGenerator pg = new PolygonGenerator(RNG.r, 2, 0.013, 1, (g) -> g); + public IrisBiome getBiome(int x, int z) + { + IrisBiome biome = glBiome.getBiome(x, z); + int height = computeHeight((int) x, (int) z, new ChunkPlan(), biome); + biome = getBiome((int) x, height, (int) z); + + return biome; + } + + private IrisBiome getBiome(int x, int y, int z) + { + int seaLevel = Iris.settings.gen.seaLevel; + boolean land = y >= seaLevel; + int beachHeight = land ? 1 + (int) Math.round(seaLevel + beach.noise(x, z)) : seaLevel; + boolean beach = y <= beachHeight && land; + IrisBiome biome = glBiome.getBiome(x, z); + IrisBiome realBiome = glBiome.getBiome(x, z, true); + boolean nearAquatic = glBiome.isNearAquatic(x, z); + IrisRegion region = getRegion(realBiome); + + // Remove Oceans from biomes above sea level + if(land && biome.getType().equals(BiomeType.FLUID)) + { + biome = realBiome; + } + + // Add Beaches & Shores + if(beach && biome.getType().equals(BiomeType.LAND)) + { + biome = nearAquatic ? region.getBeach() : region.getShore(); + } + + // // Replace biomes under sea level with lakes + if(!land && biome.getType().equals(BiomeType.LAND)) + { + biome = region.getLake(); + } + + return biome; + } @Override public Biome onGenColumn(int wxxf, int wzxf, int x, int z, ChunkPlan plan, AtomicChunkData data, boolean surfaceOnly) @@ -301,19 +339,10 @@ public class IrisGenerator extends ParallaxWorldGenerator int highest = 0; int seaLevel = Iris.settings.gen.seaLevel; IrisBiome biome = glBiome.getBiome(wxx, wzx); - IrisBiome realBiome = glBiome.getBiome(wxx, wzx, true); - IrisRegion region = getRegion(realBiome); - MB FLUID = biome.getFluid(); int height = computeHeight(wxx, wzx, plan, biome); int max = Math.max(height, seaLevel); - boolean land = height >= seaLevel; - int beachHeight = land ? (int) Math.round(seaLevel + beach.noise(wx, wz)) : seaLevel; - boolean beach = height <= beachHeight + 2 && land; - biome = land && biome.getType().equals(BiomeType.FLUID) ? region.getBeach() : biome; - biome = !land && biome.getType().equals(BiomeType.LAND) ? region.getLake() : biome; - biome = beach && !land && biome.getType().equals(BiomeType.FLUID) ? region.getShore() : biome; - // biome = !beach && land && biome.getType().equals(BiomeType.FRONT) ? realBiome - // : biome; + biome = getBiome(wxx, height, wzx); + MB FLUID = biome.getFluid(); for(int i = surfaceOnly ? max > seaLevel ? max - 2 : height - 2 : 0; i < max; i++) { diff --git a/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java b/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java index f69ef79c4..1fe1e9728 100644 --- a/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java +++ b/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java @@ -20,6 +20,7 @@ import ninja.bytecode.shuriken.collections.GMap; public class WorldReactor { + private static GList q = new GList<>(); private final World world; public WorldReactor(World world) @@ -29,7 +30,15 @@ public class WorldReactor public void generateRegionNormal(Player p, boolean force, double mst, Consumer progress, Runnable done) { + for(ChronoQueue i : WorldReactor.q) + { + i.close(); + } + + WorldReactor.q.clear(); + ChronoQueue q = new ChronoQueue(mst, 10240); + WorldReactor.q.add(q); FinalDouble of = new FinalDouble(0D); FinalDouble max = new FinalDouble(0D); GMap d = new GMap<>(); diff --git a/src/main/java/ninja/bytecode/iris/generator/genobject/GenObject.java b/src/main/java/ninja/bytecode/iris/generator/genobject/GenObject.java index fd5051971..f2eabfb76 100644 --- a/src/main/java/ninja/bytecode/iris/generator/genobject/GenObject.java +++ b/src/main/java/ninja/bytecode/iris/generator/genobject/GenObject.java @@ -584,7 +584,7 @@ public class GenObject { BlockVector mbv = highest.toBlockVector().add(new Vector(0, 1, 0)).toBlockVector(); added = true; - getSchematic().put(new SBlockVector(mbv), MB.of(Material.SNOW, RNG.r.nextInt((int) M.clip(factor, 0, 8)))); + getSchematic().put(new SBlockVector(mbv), MB.of(Material.SNOW, RNG.r.nextInt((int) M.clip(factor, 1, 8)))); } } } 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 4d75be1aa..3db63cef8 100644 --- a/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java +++ b/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java @@ -37,7 +37,7 @@ public class GenLayerBiome extends GenLayer .scale(0.01), 30)); ocean = new PolygonGenerator(rng.nextParallelRNG(-11), 6, 0.005, 1, (g)->g.fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2) .scale(0.01), 150)); - fuzz = new CNG(rng.nextParallelRNG(9112), 1D * 8 * Iris.settings.gen.biomeEdgeFuzzScale, 1).scale(6.5); + fuzz = new CNG(rng.nextParallelRNG(9112), 1D * 12 * Iris.settings.gen.biomeEdgeFuzzScale, 1).scale(6.5); fracture = new CNG(rng.nextParallelRNG(28), 1D, 4).scale(0.0021 * Iris.settings.gen.biomeEdgeScrambleScale) .fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2) .scale(0.01), 12250); @@ -89,6 +89,48 @@ public class GenLayerBiome extends GenLayer return getBiome(wxx, wzx, false); } + public boolean isNearAquatic(int wxx, int wzx) + { + double wx = Math.round((double) wxx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale; + double wz = Math.round((double) wzx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale; + double xf = wx + ((fracture.noise(wx, wz) / 2D) * 200D * Iris.settings.gen.biomeEdgeScrambleRange); + double zf = wz - ((fracture.noise(wz, wx) / 2D) * 200D * Iris.settings.gen.biomeEdgeScrambleRange); + double x = xf - fuzz.noise(wx, wz); + double z = zf + fuzz.noise(wz, wx); + + if(ocean.getIndex(x, z) == 0) + { + return true; + } + + if(channel.hasBorder(3, 44, xf, zf)) + { + return true; + } + + if(ocean.getClosestNeighbor(x, z) > 0.2) + { + return true; + } + + if(channel.getClosestNeighbor(x, z) > 0.2) + { + return true; + } + + if(ocean.hasBorder(3, 7, x, z) || ocean.hasBorder(3, 3, x, z)) + { + return true; + } + + if(channel.hasBorder(3, 7, xf, zf) || channel.hasBorder(3, 3, xf, zf)) + { + return true; + } + + return false; + } + public IrisBiome getBiome(double wxx, double wzx, boolean real) { double wx = Math.round((double) wxx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale; diff --git a/src/main/java/ninja/bytecode/iris/pack/IrisRegion.java b/src/main/java/ninja/bytecode/iris/pack/IrisRegion.java index 03fbf7b47..48e310622 100644 --- a/src/main/java/ninja/bytecode/iris/pack/IrisRegion.java +++ b/src/main/java/ninja/bytecode/iris/pack/IrisRegion.java @@ -38,7 +38,7 @@ public class IrisRegion J.attempt(() -> ocean = Iris.getController(PackController.class).getBiomeById(o.getString("ocean"))); J.attempt(() -> beach = Iris.getController(PackController.class).getBiomeById(o.getString("beach"))); J.attempt(() -> lake = Iris.getController(PackController.class).getBiomeById(o.getString("lake"))); - J.attempt(() -> lakeBeach = Iris.getController(PackController.class).getBiomeById(o.getString("lakeBeach"))); + J.attempt(() -> lakeBeach = Iris.getController(PackController.class).getBiomeById(o.getString("shore"))); J.attempt(() -> channel = Iris.getController(PackController.class).getBiomeById(o.getString("channel"))); }); } diff --git a/src/main/java/ninja/bytecode/iris/util/ChronoQueue.java b/src/main/java/ninja/bytecode/iris/util/ChronoQueue.java index b991259e7..4f07b3025 100644 --- a/src/main/java/ninja/bytecode/iris/util/ChronoQueue.java +++ b/src/main/java/ninja/bytecode/iris/util/ChronoQueue.java @@ -4,6 +4,7 @@ import org.bukkit.Bukkit; import ninja.bytecode.iris.Iris; import ninja.bytecode.shuriken.bench.PrecisionStopwatch; +import ninja.bytecode.shuriken.execution.J; import ninja.bytecode.shuriken.execution.Queue; import ninja.bytecode.shuriken.execution.ShurikenQueue; import ninja.bytecode.shuriken.logging.L; @@ -29,7 +30,7 @@ public class ChronoQueue public void close() { - Bukkit.getScheduler().cancelTask(j); + J.attempt(() -> Bukkit.getScheduler().cancelTask(j)); } public void dieSlowly()