diff --git a/src/main/java/ninja/bytecode/iris/CommandIris.java b/src/main/java/ninja/bytecode/iris/CommandIris.java index 5bfe6ec3a..c5cd81c6c 100644 --- a/src/main/java/ninja/bytecode/iris/CommandIris.java +++ b/src/main/java/ninja/bytecode/iris/CommandIris.java @@ -228,6 +228,30 @@ public class CommandIris implements CommandExecutor } } + if(args[0].equalsIgnoreCase("regen")) + { + 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, 200, (pct) -> + { + if(cl.flip()) + { + msg(p, "Regenerating " + F.pc(pct)); + } + }, () -> + { + msg(p, "Done! Use F3 + A"); + }); + } + } + if(args[0].equalsIgnoreCase("hotload")) { msg(sender, "=== Hotloading Pack ==="); @@ -297,55 +321,16 @@ public class CommandIris implements CommandExecutor J.s(() -> msg(sender, "Cannot find dimnension: " + f.get(fi))); return; } - msg(sender, "Injecting " + i.getName()); + msg(sender, "Hotloaded " + 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); } }); diff --git a/src/main/java/ninja/bytecode/iris/Settings.java b/src/main/java/ninja/bytecode/iris/Settings.java index 7ae0ffe37..9b1a041ea 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.PARALLAX; + public ObjectMode objectMode = ObjectMode.NONE; public boolean fastMode = false; public int threadPriority = Thread.MAX_PRIORITY; public int threadCount = 4; diff --git a/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java b/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java index 391ae0473..f69ef79c4 100644 --- a/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java +++ b/src/main/java/ninja/bytecode/iris/generator/WorldReactor.java @@ -1,5 +1,6 @@ package ninja.bytecode.iris.generator; +import java.util.Collections; import java.util.function.Consumer; import org.bukkit.Chunk; @@ -13,6 +14,9 @@ import mortar.lang.collection.FinalDouble; import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.util.ChronoQueue; import ninja.bytecode.iris.util.ObjectMode; +import ninja.bytecode.iris.util.SMCAVector; +import ninja.bytecode.shuriken.collections.GList; +import ninja.bytecode.shuriken.collections.GMap; public class WorldReactor { @@ -28,7 +32,9 @@ public class WorldReactor ChronoQueue q = new ChronoQueue(mst, 10240); FinalDouble of = new FinalDouble(0D); FinalDouble max = new FinalDouble(0D); - + GMap d = new GMap<>(); + int mx = p.getLocation().getChunk().getX(); + int mz = p.getLocation().getChunk().getZ(); for(int xx = p.getLocation().getChunk().getX() - 32; xx < p.getLocation().getChunk().getX() + 32; xx++) { int x = xx; @@ -39,37 +45,47 @@ public class WorldReactor if(world.isChunkLoaded(x, z) || world.loadChunk(x, z, false)) { - if(Iris.settings.performance.objectMode.equals(ObjectMode.PARALLAX) && world.getGenerator() instanceof IrisGenerator) - { - IrisGenerator gg = ((IrisGenerator) world.getGenerator()); - gg.getWorldData().deleteChunk(x, z); - } + d.put(new SMCAVector(x, z), Math.sqrt(Math.pow(x - mx, 2) + Math.pow(z - mz, 2))); + } + } + } - max.add(1); - q.queue(() -> - { - world.regenerateChunk(x, z); + GList v = d.k(); + Collections.sort(v, (a, b) -> (int) (10000 * (d.get(a) - d.get(b)))); - Chunk cc = world.getChunkAt(x, z); - NMP.host.relight(cc); - of.add(1); + for(SMCAVector i : v) + { + int x = i.getX(); + int z = i.getZ(); - if(of.get() == max.get()) - { - progress.accept(1D); - q.dieSlowly(); - done.run(); - } + if(Iris.settings.performance.objectMode.equals(ObjectMode.PARALLAX) && world.getGenerator() instanceof IrisGenerator) + { + IrisGenerator gg = ((IrisGenerator) world.getGenerator()); + gg.getWorldData().deleteChunk(x, z); + } - else - { - progress.accept(M.clip(of.get() / max.get(), 0D, 1D)); - } + max.add(1); + q.queue(() -> + { + world.regenerateChunk(x, z); - }); + 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)); + } + + }); } J.s(() ->