Fix regen

This commit is contained in:
Daniel Mills 2020-01-22 11:30:10 -05:00
parent 51832005de
commit c1971bffa8
3 changed files with 67 additions and 66 deletions

View File

@ -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")) if(args[0].equalsIgnoreCase("hotload"))
{ {
msg(sender, "=== Hotloading Pack ==="); msg(sender, "=== Hotloading Pack ===");
@ -297,55 +321,16 @@ public class CommandIris implements CommandExecutor
J.s(() -> msg(sender, "Cannot find dimnension: " + f.get(fi))); J.s(() -> msg(sender, "Cannot find dimnension: " + f.get(fi)));
return; return;
} }
msg(sender, "Injecting " + i.getName()); msg(sender, "Hotloaded " + i.getName());
IrisGenerator g = ((IrisGenerator) i.getGenerator()); IrisGenerator g = ((IrisGenerator) i.getGenerator());
g.inject(dim); 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) catch(Throwable e)
{ {
e.printStackTrace(); e.printStackTrace();
Consumer<String> m = (msg) ->
{
J.s(() -> msg(sender, msg.replaceAll("\\Q \\E", "")));
};
L.addLogConsumer(m);
L.ex(e);
L.logConsumers.remove(m);
} }
}); });

View File

@ -12,7 +12,7 @@ public class Settings
public static class PerformanceSettings public static class PerformanceSettings
{ {
public PerformanceMode performanceMode = PerformanceMode.DOUBLE_CPU; public PerformanceMode performanceMode = PerformanceMode.DOUBLE_CPU;
public ObjectMode objectMode = ObjectMode.PARALLAX; public ObjectMode objectMode = ObjectMode.NONE;
public boolean fastMode = false; public boolean fastMode = false;
public int threadPriority = Thread.MAX_PRIORITY; public int threadPriority = Thread.MAX_PRIORITY;
public int threadCount = 4; public int threadCount = 4;

View File

@ -1,5 +1,6 @@
package ninja.bytecode.iris.generator; package ninja.bytecode.iris.generator;
import java.util.Collections;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -13,6 +14,9 @@ import mortar.lang.collection.FinalDouble;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.util.ChronoQueue; import ninja.bytecode.iris.util.ChronoQueue;
import ninja.bytecode.iris.util.ObjectMode; 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 public class WorldReactor
{ {
@ -28,7 +32,9 @@ public class WorldReactor
ChronoQueue q = new ChronoQueue(mst, 10240); ChronoQueue q = new ChronoQueue(mst, 10240);
FinalDouble of = new FinalDouble(0D); FinalDouble of = new FinalDouble(0D);
FinalDouble max = new FinalDouble(0D); FinalDouble max = new FinalDouble(0D);
GMap<SMCAVector, Double> 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++) for(int xx = p.getLocation().getChunk().getX() - 32; xx < p.getLocation().getChunk().getX() + 32; xx++)
{ {
int x = xx; int x = xx;
@ -39,6 +45,19 @@ public class WorldReactor
if(world.isChunkLoaded(x, z) || world.loadChunk(x, z, false)) if(world.isChunkLoaded(x, z) || world.loadChunk(x, z, false))
{ {
d.put(new SMCAVector(x, z), Math.sqrt(Math.pow(x - mx, 2) + Math.pow(z - mz, 2)));
}
}
}
GList<SMCAVector> v = d.k();
Collections.sort(v, (a, b) -> (int) (10000 * (d.get(a) - d.get(b))));
for(SMCAVector i : v)
{
int x = i.getX();
int z = i.getZ();
if(Iris.settings.performance.objectMode.equals(ObjectMode.PARALLAX) && world.getGenerator() instanceof IrisGenerator) if(Iris.settings.performance.objectMode.equals(ObjectMode.PARALLAX) && world.getGenerator() instanceof IrisGenerator)
{ {
IrisGenerator gg = ((IrisGenerator) world.getGenerator()); IrisGenerator gg = ((IrisGenerator) world.getGenerator());
@ -69,9 +88,6 @@ public class WorldReactor
}); });
} }
}
}
J.s(() -> J.s(() ->
{ {
q.dieSlowly(); q.dieSlowly();