mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Fix regen
This commit is contained in:
parent
51832005de
commit
c1971bffa8
@ -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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -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,37 +45,47 @@ public class WorldReactor
|
|||||||
|
|
||||||
if(world.isChunkLoaded(x, z) || world.loadChunk(x, z, false))
|
if(world.isChunkLoaded(x, z) || world.loadChunk(x, z, false))
|
||||||
{
|
{
|
||||||
if(Iris.settings.performance.objectMode.equals(ObjectMode.PARALLAX) && world.getGenerator() instanceof IrisGenerator)
|
d.put(new SMCAVector(x, z), Math.sqrt(Math.pow(x - mx, 2) + Math.pow(z - mz, 2)));
|
||||||
{
|
}
|
||||||
IrisGenerator gg = ((IrisGenerator) world.getGenerator());
|
}
|
||||||
gg.getWorldData().deleteChunk(x, z);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
max.add(1);
|
GList<SMCAVector> v = d.k();
|
||||||
q.queue(() ->
|
Collections.sort(v, (a, b) -> (int) (10000 * (d.get(a) - d.get(b))));
|
||||||
{
|
|
||||||
world.regenerateChunk(x, z);
|
|
||||||
|
|
||||||
Chunk cc = world.getChunkAt(x, z);
|
for(SMCAVector i : v)
|
||||||
NMP.host.relight(cc);
|
{
|
||||||
of.add(1);
|
int x = i.getX();
|
||||||
|
int z = i.getZ();
|
||||||
|
|
||||||
if(of.get() == max.get())
|
if(Iris.settings.performance.objectMode.equals(ObjectMode.PARALLAX) && world.getGenerator() instanceof IrisGenerator)
|
||||||
{
|
{
|
||||||
progress.accept(1D);
|
IrisGenerator gg = ((IrisGenerator) world.getGenerator());
|
||||||
q.dieSlowly();
|
gg.getWorldData().deleteChunk(x, z);
|
||||||
done.run();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
else
|
max.add(1);
|
||||||
{
|
q.queue(() ->
|
||||||
progress.accept(M.clip(of.get() / max.get(), 0D, 1D));
|
{
|
||||||
}
|
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(() ->
|
J.s(() ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user