From 0483bc0afed2a41e373eeea89b32f45339959ca3 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Tue, 21 Jan 2020 17:49:20 -0500 Subject: [PATCH] "Perfection" --- .../java/ninja/bytecode/iris/CommandIris.java | 137 +++++++++- .../java/ninja/bytecode/iris/IrisMetrics.java | 3 - .../java/ninja/bytecode/iris/Settings.java | 12 +- .../iris/controller/PackController.java | 22 ++ .../iris/generator/IrisGenerator.java | 35 +-- .../bytecode/iris/generator/WorldReactor.java | 245 ++---------------- .../genobject/GenObjectDecorator.java | 117 ++++++--- .../parallax/ParallelChunkGenerator.java | 1 + .../ninja/bytecode/iris/pack/IrisBiome.java | 4 +- .../ninja/bytecode/iris/util/BiomeLayer.java | 7 +- .../ninja/bytecode/iris/util/ObjectMode.java | 2 +- .../bytecode/iris/util/PolygonGenerator.java | 6 +- 12 files changed, 284 insertions(+), 307 deletions(-) diff --git a/src/main/java/ninja/bytecode/iris/CommandIris.java b/src/main/java/ninja/bytecode/iris/CommandIris.java index bb029c309..05dccd97c 100644 --- a/src/main/java/ninja/bytecode/iris/CommandIris.java +++ b/src/main/java/ninja/bytecode/iris/CommandIris.java @@ -1,5 +1,8 @@ package ninja.bytecode.iris; +import java.util.function.Consumer; + +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; import org.bukkit.Location; @@ -10,13 +13,20 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import mortar.api.nms.NMP; +import mortar.api.sched.J; import mortar.util.text.C; -import ninja.bytecode.iris.controller.TimingsController; +import ninja.bytecode.iris.controller.PackController; import ninja.bytecode.iris.generator.IrisGenerator; +import ninja.bytecode.iris.generator.WorldReactor; import ninja.bytecode.iris.generator.genobject.PlacedObject; +import ninja.bytecode.iris.pack.CompiledDimension; import ninja.bytecode.iris.pack.IrisBiome; import ninja.bytecode.iris.util.BiomeLayer; +import ninja.bytecode.shuriken.collections.GList; +import ninja.bytecode.shuriken.collections.GMap; +import ninja.bytecode.shuriken.execution.ChronoLatch; import ninja.bytecode.shuriken.format.F; +import ninja.bytecode.shuriken.logging.L; public class CommandIris implements CommandExecutor { @@ -34,6 +44,7 @@ public class CommandIris implements CommandExecutor msg(sender, "/iris rtp [biome] - RTP to a biome"); msg(sender, "/iris otp [schematic] - RTP to a specific schematic"); msg(sender, "/iris info - Chunk info"); + msg(sender, "/iris hotload - Recompile pack & inject into worlds"); msg(sender, "/iris reload - Reload & Recompile"); msg(sender, "/iris clean - Clean Pack Install in Iris Folder"); msg(sender, "/ish - Iris Schematic Commands"); @@ -216,6 +227,130 @@ public class CommandIris implements CommandExecutor } } + if(args[0].equalsIgnoreCase("hotload")) + { + msg(sender, "=== Hotloading Pack ==="); + PackController c = Iris.getController(PackController.class); + GMap f = new GMap<>(); + + for(World i : Bukkit.getWorlds()) + { + if(i.getGenerator() instanceof IrisGenerator) + { + String n = ((IrisGenerator) i.getGenerator()).getDimension().getName(); + msg(sender, "Preparing " + n); + f.put(i.getName(), n); + } + } + + if(f.isEmpty()) + { + msg(sender, "No Worlds to inject!"); + return true; + } + + J.a(() -> + { + try + { + Consumer m = (msg) -> + { + + J.s(() -> + { + String mm = msg; + + if(msg.contains("|")) + { + GList fx = new GList<>(); + fx.add(msg.split("\\Q|\\E")); + fx.remove(0); + fx.remove(0); + mm = fx.toString(""); + } + + msg(sender, mm.replaceAll("\\Q \\E", "")); + }); + }; + L.addLogConsumer(m); + c.compile(); + L.logConsumers.remove(m); + + for(String fi : f.k()) + { + J.s(() -> + { + + World i = Bukkit.getWorld(fi); + CompiledDimension dim = c.getDimension(f.get(fi)); + + for(String k : c.getDimensions().k()) + { + if(c.getDimension(k).getName().equals(f.get(fi))) + { + dim = c.getDimension(k); + break; + } + } + + if(dim == null) + { + J.s(() -> msg(sender, "Cannot find dimnension: " + f.get(fi))); + return; + } + msg(sender, "Injecting " + i.getName()); + IrisGenerator g = ((IrisGenerator) i.getGenerator()); + g.inject(dim); + }); + } + + J.s(() -> + { + if(sender instanceof Player) + { + ChronoLatch cl = new ChronoLatch(3000); + Player p = (Player) sender; + World ww = ((Player) sender).getWorld(); + msg(p, "Regenerating View Distance"); + + WorldReactor r = new WorldReactor(ww); + r.generateRegionNormal(p, true, 45, (pct) -> + { + if(cl.flip()) + { + msg(p, "Regenerating " + F.pc(pct)); + } + }, () -> + { + msg(p, "Done!"); + + for(Chunk i : p.getWorld().getLoadedChunks()) + { + if(i.getWorld().isChunkInUse(i.getX(), i.getZ())) + { + NMP.CHUNK.refresh(p, i); + } + } + }); + } + }, 5); + } + + catch(Throwable e) + { + e.printStackTrace(); + Consumer m = (msg) -> + { + J.s(() -> msg(sender, msg.replaceAll("\\Q \\E", ""))); + }; + L.addLogConsumer(m); + L.ex(e); + L.logConsumers.remove(m); + } + }); + + } + if(args[0].equalsIgnoreCase("reload")) { msg(sender, "Reloading Iris..."); diff --git a/src/main/java/ninja/bytecode/iris/IrisMetrics.java b/src/main/java/ninja/bytecode/iris/IrisMetrics.java index 85417c11a..fe8e89e90 100644 --- a/src/main/java/ninja/bytecode/iris/IrisMetrics.java +++ b/src/main/java/ninja/bytecode/iris/IrisMetrics.java @@ -1,12 +1,9 @@ package ninja.bytecode.iris; -import java.lang.reflect.Executable; import java.util.function.Consumer; import org.bukkit.entity.Player; -import com.amazonaws.http.ExecutionContext; - import mortar.compute.math.M; import mortar.util.text.C; import ninja.bytecode.iris.controller.ExecutionController; diff --git a/src/main/java/ninja/bytecode/iris/Settings.java b/src/main/java/ninja/bytecode/iris/Settings.java index 4f548831c..1bd6459c6 100644 --- a/src/main/java/ninja/bytecode/iris/Settings.java +++ b/src/main/java/ninja/bytecode/iris/Settings.java @@ -12,14 +12,14 @@ public class Settings public static class PerformanceSettings { public PerformanceMode performanceMode = PerformanceMode.HALF_CPU; - public ObjectMode objectMode = ObjectMode.FAST_LIGHTING; + public ObjectMode objectMode = ObjectMode.NONE; public boolean fastMode = false; public int threadPriority = Thread.MAX_PRIORITY; public int threadCount = 4; public boolean debugMode = true; public int decorationAccuracy = 2; public boolean noObjectFail = false; - public boolean verbose = true; + public boolean verbose = false; public int placeHistoryLimit = 8192; } @@ -43,10 +43,10 @@ public class Settings public double caveDensity = 5; public double caveScale = 1.2; public double biomeScale = 0.65; - public boolean flatBedrock = true; - public boolean genCarving = true; - public boolean genCaverns = true; - public boolean genCaves = true; + public boolean flatBedrock = false; + public boolean genCarving = false; + public boolean genCaverns = false; + public boolean genCaves = false; public double carvingChance = 0.352; public double cavernChance = 0.321; public int minCarvingHeight = 75; diff --git a/src/main/java/ninja/bytecode/iris/controller/PackController.java b/src/main/java/ninja/bytecode/iris/controller/PackController.java index 35474bbcb..13e7841b4 100644 --- a/src/main/java/ninja/bytecode/iris/controller/PackController.java +++ b/src/main/java/ninja/bytecode/iris/controller/PackController.java @@ -5,6 +5,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import org.bukkit.command.CommandSender; + import net.md_5.bungee.api.ChatColor; import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.generator.genobject.GenObject; @@ -158,6 +160,26 @@ public class PackController implements IrisController ready = true; } + public GMap getCompiledDimensions() + { + return compiledDimensions; + } + + public GMap getDimensions() + { + return dimensions; + } + + public GMap getBiomes() + { + return biomes; + } + + public GMap getGenObjectGroups() + { + return genObjectGroups; + } + public CompiledDimension getDimension(String name) { return compiledDimensions.get(name); diff --git a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java index 649694e12..b34136409 100644 --- a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java @@ -64,7 +64,6 @@ public class IrisGenerator extends ParallaxWorldGenerator //@done private boolean disposed; - private double[][][] scatterCache; private CNG scatter; private MB ICE = new MB(Material.ICE); private MB PACKED_ICE = new MB(Material.PACKED_ICE); @@ -110,7 +109,7 @@ public class IrisGenerator extends ParallaxWorldGenerator public double scatter(int x, int y, int z) { - return scatterCache[Math.abs(x) % 16][Math.abs(y) % 16][Math.abs(z) % 16]; + return scatter.noise(x, y, z); } public boolean scatterChance(int x, int y, int z, double chance) @@ -125,8 +124,7 @@ public class IrisGenerator extends ParallaxWorldGenerator { return; } - - //@builder + random = new Random(world.getSeed()); rTerrain = new RNG(world.getSeed()); glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2)); glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes()); @@ -135,28 +133,12 @@ public class IrisGenerator extends ParallaxWorldGenerator glCaverns = new GenLayerCaverns(this, world, random, rTerrain.nextParallelRNG(-3)); glSnow = new GenLayerSnow(this, world, random, rTerrain.nextParallelRNG(5)); glCliffs = new GenLayerCliffs(this, world, random, rTerrain.nextParallelRNG(9)); - scatterCache = new double[16][][]; scatter = new CNG(rTerrain.nextParallelRNG(52), 1, 1).scale(10); - + if(Iris.settings.performance.objectMode.equals(ObjectMode.PARALLAX)) { god = new GenObjectDecorator(this); } - //@done - for(int i = 0; i < 16; i++) - { - scatterCache[i] = new double[16][]; - - for(int j = 0; j < 16; j++) - { - scatterCache[i][j] = new double[16]; - - for(int k = 0; k < 16; k++) - { - scatterCache[i][j][k] = scatter.noise(i, j, k); - } - } - } } @Override @@ -185,6 +167,7 @@ public class IrisGenerator extends ParallaxWorldGenerator public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) { + random = new Random(world.getSeed()); PrecisionStopwatch s = getMetrics().start(); ChunkData d = super.generateChunkData(world, random, x, z, biome); getMetrics().stop("chunk:ms", s); @@ -312,7 +295,7 @@ public class IrisGenerator extends ParallaxWorldGenerator { GList p = new GList<>(); - if(Iris.settings.performance.objectMode.equals(ObjectMode.FAST_LIGHTING) || Iris.settings.performance.objectMode.equals(ObjectMode.LIGHTING)) + if(Iris.settings.performance.objectMode.equals(ObjectMode.QUICK_N_DIRTY) || Iris.settings.performance.objectMode.equals(ObjectMode.LIGHTING)) { p.add(god = new GenObjectDecorator(this)); } @@ -406,7 +389,7 @@ public class IrisGenerator extends ParallaxWorldGenerator else { - MB mbx = biome.getScatterChanceSingle(); + MB mbx = biome.getScatterChanceSingle(scatter(wxx, i, wzx)); if(!mbx.material.equals(Material.AIR)) { @@ -549,4 +532,10 @@ public class IrisGenerator extends ParallaxWorldGenerator { dispose(); } + + public void inject(CompiledDimension dimension) + { + this.dim = dimension; + onInit(getWorld(), rTerrain); + } } \ No newline at end of file diff --git a/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java b/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java index ef5652615..4f3c64dbe 100644 --- a/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java +++ b/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java @@ -1,6 +1,5 @@ package ninja.bytecode.iris.generator; -import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; import org.bukkit.Chunk; @@ -11,204 +10,45 @@ import mortar.api.nms.NMP; import mortar.api.sched.J; import mortar.compute.math.M; import mortar.lang.collection.FinalDouble; -import ninja.bytecode.iris.generator.atomics.AtomicChunkData; import ninja.bytecode.iris.util.ChronoQueue; -import ninja.bytecode.iris.util.ChunkPlan; -import ninja.bytecode.iris.util.SMCAVector; -import ninja.bytecode.shuriken.bench.PrecisionStopwatch; -import ninja.bytecode.shuriken.collections.GList; -import ninja.bytecode.shuriken.collections.GMap; -import ninja.bytecode.shuriken.execution.ChronoLatch; -import ninja.bytecode.shuriken.execution.NastyRunnable; -import ninja.bytecode.shuriken.execution.TaskExecutor; -import ninja.bytecode.shuriken.math.RNG; public class WorldReactor { private final World world; - private IrisGenerator gen; public WorldReactor(World world) { this.world = world; - - if(!(world.getGenerator() instanceof IrisGenerator)) - { - throw new IllegalArgumentException(world.getName() + " is not an iris world."); - } - - this.gen = ((IrisGenerator) world.getGenerator()); } - public void generateMultipleRegions(GMap g, boolean force, double mst, Consumer progress, Runnable done) + public void generateRegionNormal(Player p, boolean force, double mst, Consumer progress, Runnable done) { - ChronoLatch cl = new ChronoLatch(50); - GMap p = new GMap<>(); - ReentrantLock r = new ReentrantLock(); - for(SMCAVector i : g.k()) + ChronoQueue q = new ChronoQueue(mst, 10240); + FinalDouble of = new FinalDouble(0D); + FinalDouble max = new FinalDouble(0D); + + for(int xx = p.getLocation().getChunk().getX() - 32; xx < p.getLocation().getChunk().getX() + 32; xx++) { - generateRegion(i.getX(), i.getZ(), g.get(i), force, mst / (double) g.size(), (xp) -> + int x = xx; + + for(int zz = p.getLocation().getChunk().getZ() - 32; zz < p.getLocation().getChunk().getZ() + 32; zz++) { - r.lock(); - p.put(i, xp); - double m = 0; + int z = zz; - for(double j : p.v()) + if(world.isChunkLoaded(x, z) || world.loadChunk(x, z, false)) { - m += j; - } - r.unlock(); - - double h = m / (double) p.size(); - - if(h == 1D || cl.flip()) - { - progress.accept(h); - } - }, () -> - { - p.remove(i); - - if(p.isEmpty()) - { - done.run(); - } - }); - } - } - - public void generateRegion(int mx, int mz, TaskExecutor executor, boolean force, double mst, Consumer progress, Runnable done) - { - J.a(() -> - { - FinalDouble of = new FinalDouble(0D); - FinalDouble max = new FinalDouble(0D); - PrecisionStopwatch t = PrecisionStopwatch.start(); - GMap data = new GMap<>(); - GMap plan = new GMap<>(); - GList parallax = new GList<>(); - GList noise = new GList<>(); - GList chunk = new GList<>(); - ReentrantLock lock = new ReentrantLock(); - - for(int xx = mx << 5; xx < (mx << 5) + 32; xx++) - { - int x = xx; - - for(int zz = mz << 5; zz < (mz << 5) + 32; zz++) - { - int z = zz; - SMCAVector w = new SMCAVector(x, z); - - if(!force && world.loadChunk(x, z, false)) - { - // continue; - } - max.add(1); - parallax.add(() -> + q.queue(() -> { - gen.doGenParallax(x, z); - of.add(1); - progress.accept(of.get() / max.get()); - }); - - max.add(0.1); - noise.add(() -> - { - AtomicChunkData tydata = new AtomicChunkData(world); - ChunkPlan typlan = new ChunkPlan(); - - for(int i = 0; i < 16; i++) - { - for(int j = 0; j < 16; j++) - { - gen.onGenColumn((x << 4) + i, (z << 4) + j, i, j, typlan, tydata, true); - } - } - - gen.getWorldData().getChunk(x, z).inject(tydata); - gen.onPostChunk(world, x, z, new RNG(world.getSeed()), tydata, typlan); - - lock.lock(); - data.put(w, tydata); - plan.put(w, typlan); - lock.unlock(); - of.add(1); - progress.accept(of.get() / max.get()); - }); - - max.add(4); - chunk.add(() -> - { - if(world.loadChunk(x, z, false)) - { - world.regenerateChunk(x, z); - } - - else - { - world.loadChunk(x, z, true); - } + world.regenerateChunk(x, z); Chunk cc = world.getChunkAt(x, z); NMP.host.relight(cc); - cc.unload(true); - }); - } - } + of.add(1); - executor.startWork().queue(parallax).execute(); - executor.startWork().queue(noise).execute(); - - gen.setSplicer((world, random, x, z, biome) -> - { - SMCAVector w = new SMCAVector(x, z); - - for(int i = 0; i < 16; i++) - { - for(int j = 0; j < 16; j++) - { - try - { - biome.setBiome((x << 4) + i, (z << 4) + j, plan.get(w).getBiome(i, j).getRealBiome()); - } - - catch(Throwable e) - { - - } - } - } - - AtomicChunkData f = data.get(w); - - if(f != null) - { - - } - - return f; - }); - - t.end(); - J.s(() -> - { - PrecisionStopwatch s = PrecisionStopwatch.start(); - ChronoQueue q = new ChronoQueue(mst, 1096); - int m = 0; - for(Runnable i : chunk) - { - int gg = m; - - q.queue(() -> - { - i.run(); - of.add(4); - if(gg == chunk.size() - 1) + if(of.get() == max.get()) { progress.accept(1D); - s.end(); q.dieSlowly(); done.run(); } @@ -217,61 +57,16 @@ public class WorldReactor { progress.accept(M.clip(of.get() / max.get(), 0D, 1D)); } + }); - - m++; } - }); - }); - } - public void generateRegionNormal(Player p, boolean force, double mst, Consumer progress, Runnable done) - { - ChronoQueue q = new ChronoQueue(mst, 1024); - FinalDouble of = new FinalDouble(0D); - FinalDouble max = new FinalDouble(0D); - - for(int xx = p.getLocation().getChunk().getX() - 32; xx < p.getLocation().getChunk().getX() + 32; xx++) - { - int x = xx; - - for(int zz = p.getLocation().getChunk().getX() - 32; zz < p.getLocation().getChunk().getX() + 32; zz++) - { - int z = zz; - - max.add(1); - - q.queue(() -> - { - if(world.loadChunk(x, z, false)) - { - world.regenerateChunk(x, z); - } - - else - { - world.loadChunk(x, z, true); - } - - Chunk cc = world.getChunkAt(x, z); - NMP.host.relight(cc); - of.add(1); - - if(of.get() == max.get()) - { - progress.accept(1D); - q.dieSlowly(); - done.run(); - } - - else - { - progress.accept(M.clip(of.get() / max.get(), 0D, 1D)); - } - }); } } - q.dieSlowly(); + J.s(() -> + { + q.dieSlowly(); + }, 20); } } diff --git a/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java b/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java index 2b64def58..b7b4c2d8e 100644 --- a/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java +++ b/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java @@ -9,6 +9,7 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.generator.BlockPopulator; +import mortar.api.sched.S; import mortar.logic.format.F; import mortar.util.text.C; import net.md_5.bungee.api.ChatColor; @@ -27,6 +28,7 @@ import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.collections.GSet; import ninja.bytecode.shuriken.execution.ChronoLatch; +import ninja.bytecode.shuriken.execution.J; import ninja.bytecode.shuriken.logging.L; import ninja.bytecode.shuriken.math.M; import ninja.bytecode.shuriken.math.RNG; @@ -102,44 +104,57 @@ public class GenObjectDecorator extends BlockPopulator @Override public void populate(World world, Random random, Chunk source) { - try + Runnable m = () -> { - if(g.isDisposed()) + try { - placeHistory.clear(); - return; - } - - GSet hits = new GSet<>(); - int cx = source.getX(); - int cz = source.getZ(); - - for(int i = 0; i < Iris.settings.performance.decorationAccuracy; i++) - { - int x = (cx << 4) + random.nextInt(16); - int z = (cz << 4) + random.nextInt(16); - IrisBiome biome = g.getBiome((int) g.getOffsetX(x), (int) g.getOffsetZ(z)); - - if(hits.contains(biome)) + if(g.isDisposed()) { - continue; + placeHistory.clear(); + return; } - GMap objects = populationCache.get(biome); + GSet hits = new GSet<>(); + int cx = source.getX(); + int cz = source.getZ(); - if(objects == null) + for(int i = 0; i < Iris.settings.performance.decorationAccuracy; i++) { - continue; - } + int x = (cx << 4) + random.nextInt(16); + int z = (cz << 4) + random.nextInt(16); + IrisBiome biome = g.getBiome((int) g.getOffsetX(x), (int) g.getOffsetZ(z)); - hits.add(biome); - populate(world, cx, cz, random, biome); + if(hits.contains(biome)) + { + continue; + } + + GMap objects = populationCache.get(biome); + + if(objects == null) + { + continue; + } + + hits.add(biome); + populate(world, cx, cz, random, biome); + } } + + catch(Throwable e) + { + e.printStackTrace(); + } + }; + + if(Iris.settings.performance.objectMode.equals(ObjectMode.QUICK_N_DIRTY)) + { + J.a(m); } - catch(Throwable e) + else { - e.printStackTrace(); + m.run(); } } @@ -195,7 +210,7 @@ public class GenObjectDecorator extends BlockPopulator } } - if(Iris.settings.performance.objectMode.equals(ObjectMode.FAST_LIGHTING)) + if(Iris.settings.performance.objectMode.equals(ObjectMode.QUICK_N_DIRTY)) { placer = new NMSPlacer(world); } @@ -210,28 +225,48 @@ public class GenObjectDecorator extends BlockPopulator placer = new BukkitPlacer(world, false); } - Location start = go.place(x, by, z, placer); - - if(start != null) + Runnable rx = () -> { - g.hitObject(); - if(Iris.settings.performance.verbose) - { - L.v(C.GRAY + "Placed " + C.DARK_GREEN + i.getName() + C.WHITE + "/" + C.DARK_GREEN + go.getName() + C.GRAY + " at " + C.DARK_GREEN + F.f(start.getBlockX()) + " " + F.f(start.getBlockY()) + " " + F.f(start.getBlockZ())); - } + Location start = go.place(x, by, z, placer); - if(Iris.settings.performance.debugMode) + if(start != null) { - placeHistory.add(new PlacedObject(start.getBlockX(), start.getBlockY(), start.getBlockZ(), i.getName() + ":" + go.getName())); - - if(placeHistory.size() > Iris.settings.performance.placeHistoryLimit) + g.hitObject(); + if(Iris.settings.performance.verbose) { - while(placeHistory.size() > Iris.settings.performance.placeHistoryLimit) + L.v(C.GRAY + "Placed " + C.DARK_GREEN + i.getName() + C.WHITE + "/" + C.DARK_GREEN + go.getName() + C.GRAY + " at " + C.DARK_GREEN + F.f(start.getBlockX()) + " " + F.f(start.getBlockY()) + " " + F.f(start.getBlockZ())); + } + + if(Iris.settings.performance.debugMode) + { + placeHistory.add(new PlacedObject(start.getBlockX(), start.getBlockY(), start.getBlockZ(), i.getName() + ":" + go.getName())); + + if(placeHistory.size() > Iris.settings.performance.placeHistoryLimit) { - placeHistory.remove(0); + while(placeHistory.size() > Iris.settings.performance.placeHistoryLimit) + { + placeHistory.remove(0); + } } } } + }; + + if(Iris.settings.performance.objectMode.equals(ObjectMode.QUICK_N_DIRTY)) + { + new S(20) + { + @Override + public void run() + { + rx.run(); + } + }; + } + + else + { + rx.run(); } } } diff --git a/src/main/java/ninja/bytecode/iris/generator/parallax/ParallelChunkGenerator.java b/src/main/java/ninja/bytecode/iris/generator/parallax/ParallelChunkGenerator.java index bdc25fe99..442dc6266 100644 --- a/src/main/java/ninja/bytecode/iris/generator/parallax/ParallelChunkGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/parallax/ParallelChunkGenerator.java @@ -73,6 +73,7 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) { + random = new Random(world.getSeed()); if(splicer != null) { AtomicChunkData d = splicer.onSpliceAvailable(world, random, x, z, biome); diff --git a/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java b/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java index 2c182f8a4..497ba1c6d 100644 --- a/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java +++ b/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java @@ -589,11 +589,11 @@ public class IrisBiome return scatterChance; } - public MB getScatterChanceSingle() + public MB getScatterChanceSingle(double d) { for(MB i : getScatterChance().keySet()) { - if(M.r(getScatterChance().get(i))) + if(d < getScatterChance().get(i)) { return i; } diff --git a/src/main/java/ninja/bytecode/iris/util/BiomeLayer.java b/src/main/java/ninja/bytecode/iris/util/BiomeLayer.java index 3a52c027c..d3921a203 100644 --- a/src/main/java/ninja/bytecode/iris/util/BiomeLayer.java +++ b/src/main/java/ninja/bytecode/iris/util/BiomeLayer.java @@ -20,7 +20,7 @@ import ninja.bytecode.shuriken.math.RNG; public class BiomeLayer { - private static final IrisBiome VOID = new IrisBiome("Master", Biome.VOID).height(-1).dirt(MB.of(Material.END_BRICKS)).seal(RNG.r); + public static final IrisBiome VOID = new IrisBiome("Master", Biome.VOID).height(-1).dirt(MB.of(Material.END_BRICKS)).seal(RNG.r); private GList children; private EnumPolygonGenerator gen; private IrisBiome biome; @@ -46,18 +46,21 @@ public class BiomeLayer return; } + GList b = new GList<>(); GMap rarities = new GMap<>(); for(BiomeLayer i : getChildren()) { + b.add(i); rarities.put(i, i.getBiome().getRarity()); } if(!getBiome().equals(VOID)) { + b.add(this); rarities.put(this, getBiome().getRarity()); } - gen = new EnumPolygonGenerator<>(iris.getRTerrain().nextParallelRNG(1022 + getBiome().getRealBiome().ordinal() + getBiome().hashCode()), scale, octaves, rarities, factory).useRarity(); + gen = new EnumPolygonGenerator<>(iris.getRTerrain().nextParallelRNG(1022 + getBiome().getRealBiome().ordinal()), scale, octaves, b, rarities, factory).useRarity(); for(BiomeLayer i : getChildren()) { diff --git a/src/main/java/ninja/bytecode/iris/util/ObjectMode.java b/src/main/java/ninja/bytecode/iris/util/ObjectMode.java index 133d6a311..1162711ba 100644 --- a/src/main/java/ninja/bytecode/iris/util/ObjectMode.java +++ b/src/main/java/ninja/bytecode/iris/util/ObjectMode.java @@ -12,7 +12,7 @@ public enum ObjectMode * * Lighting is applied later with packets */ - FAST_LIGHTING, + QUICK_N_DIRTY, /** * Somewhat slow but produces near-perfect results. Updates lighting. diff --git a/src/main/java/ninja/bytecode/iris/util/PolygonGenerator.java b/src/main/java/ninja/bytecode/iris/util/PolygonGenerator.java index 628583bd9..26fbb4bf1 100644 --- a/src/main/java/ninja/bytecode/iris/util/PolygonGenerator.java +++ b/src/main/java/ninja/bytecode/iris/util/PolygonGenerator.java @@ -1,5 +1,6 @@ package ninja.bytecode.iris.util; +import java.util.Collections; import java.util.function.Function; import mortar.lang.collection.GList; @@ -155,10 +156,9 @@ public class PolygonGenerator } @SuppressWarnings("unchecked") - public EnumPolygonGenerator(RNG rng, double scale, int octaves, GMap choiceRarities, Function factory) + public EnumPolygonGenerator(RNG rng, double scale, int octaves, GList c, GMap choiceRarities, Function factory) { super(rng, choiceRarities.size(), scale / (double) choiceRarities.size(), octaves, factory); - GList c = choiceRarities.k(); this.choices = (T[]) c.toArray(); int m = 0; @@ -182,7 +182,7 @@ public class PolygonGenerator public T getChoice(double... dim) { - return choices[super.getIndex(dim)]; + return choices[getIndex(dim)]; } } }