mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Bugfixes & Performance Improvements
This commit is contained in:
parent
4ccfa8c3b6
commit
468c69d2dd
13
pom.xml
13
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>bytecode.ninja</groupId>
|
<groupId>bytecode.ninja</groupId>
|
||||||
<artifactId>Iris</artifactId>
|
<artifactId>Iris</artifactId>
|
||||||
<version>1.0.13</version>
|
<version>1.0.14</version>
|
||||||
<name>Iris</name>
|
<name>Iris</name>
|
||||||
<properties>
|
<properties>
|
||||||
<skip.copy>false</skip.copy>
|
<skip.copy>false</skip.copy>
|
||||||
@ -144,6 +144,10 @@
|
|||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>bcn</id>
|
<id>bcn</id>
|
||||||
<url>http://bytecode.ninja/repository/bcn/</url>
|
<url>http://bytecode.ninja/repository/bcn/</url>
|
||||||
@ -170,6 +174,13 @@
|
|||||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- Paper API -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc</groupId>
|
||||||
|
<artifactId>paperlib</artifactId>
|
||||||
|
<version>1.0.5</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<!-- NMS -->
|
<!-- NMS -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit.craftbukkit</groupId>
|
<groupId>org.bukkit.craftbukkit</groupId>
|
||||||
|
@ -22,6 +22,12 @@ public class CommandIris extends MortarCommand
|
|||||||
@Command
|
@Command
|
||||||
private CommandIrisDownload download;
|
private CommandIrisDownload download;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisUpdateProject updateProject;
|
||||||
|
|
||||||
|
@Command
|
||||||
|
private CommandIrisUpdateWorld updateWorld;
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
private CommandIrisWhat what;
|
private CommandIrisWhat what;
|
||||||
|
|
||||||
|
@ -34,6 +34,11 @@ public class CommandIrisCreate extends MortarCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(MortarSender sender, String[] args)
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
{
|
{
|
||||||
|
if(args.length == 0)
|
||||||
|
{
|
||||||
|
sender.sendMessage("/iris create <NAME> [type=overworld] [seed=1337] [pregen=5000] [-zip]");
|
||||||
|
}
|
||||||
|
|
||||||
String worldName = args[0];
|
String worldName = args[0];
|
||||||
String type = "overworld";
|
String type = "overworld";
|
||||||
long seed = 1337;
|
long seed = 1337;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.volmit.iris.command;
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.IrisSettings;
|
|
||||||
import com.volmit.iris.util.C;
|
import com.volmit.iris.util.C;
|
||||||
import com.volmit.iris.util.J;
|
import com.volmit.iris.util.J;
|
||||||
import com.volmit.iris.util.MortarCommand;
|
import com.volmit.iris.util.MortarCommand;
|
||||||
@ -20,15 +19,9 @@ public class CommandIrisDownload extends MortarCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(MortarSender sender, String[] args)
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if(!IrisSettings.get().isStudio())
|
|
||||||
{
|
|
||||||
sender.sendMessage("To use Iris Studio, please enable studio in Iris/settings.json");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.length < 1)
|
if(args.length < 1)
|
||||||
{
|
{
|
||||||
sender.sendMessage("/iris std dl " + C.BOLD + "<NAME>");
|
sender.sendMessage("/iris dl " + C.BOLD + "<NAME>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.util.C;
|
||||||
|
import com.volmit.iris.util.J;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
|
public class CommandIrisUpdateProject extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisUpdateProject()
|
||||||
|
{
|
||||||
|
super("update-project", "^project");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setDescription("Update a project from git.");
|
||||||
|
setCategory("Studio");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if(args.length < 1)
|
||||||
|
{
|
||||||
|
sender.sendMessage("/iris update-project " + C.BOLD + "<PROJECT>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
J.a(() -> Iris.proj.downloadSearch(sender, args[0], false, true));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "<project>";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.util.C;
|
||||||
|
import com.volmit.iris.util.J;
|
||||||
|
import com.volmit.iris.util.MortarCommand;
|
||||||
|
import com.volmit.iris.util.MortarSender;
|
||||||
|
|
||||||
|
public class CommandIrisUpdateWorld extends MortarCommand
|
||||||
|
{
|
||||||
|
public CommandIrisUpdateWorld()
|
||||||
|
{
|
||||||
|
super("update-world", "^world");
|
||||||
|
requiresPermission(Iris.perm.studio);
|
||||||
|
setDescription("Update a world from a project.");
|
||||||
|
setCategory("Studio");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle(MortarSender sender, String[] args)
|
||||||
|
{
|
||||||
|
if(args.length < 2)
|
||||||
|
{
|
||||||
|
sender.sendMessage("/iris update-world " + C.BOLD + "<WORLD> <PROJECT>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean fresh = false;
|
||||||
|
|
||||||
|
for(String i : args)
|
||||||
|
{
|
||||||
|
if(i.equalsIgnoreCase("--fresh-download"))
|
||||||
|
{
|
||||||
|
fresh = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean bfre = fresh;
|
||||||
|
|
||||||
|
J.a(() ->
|
||||||
|
{
|
||||||
|
File folder = new File(args[0]);
|
||||||
|
folder.mkdirs();
|
||||||
|
|
||||||
|
if(bfre)
|
||||||
|
{
|
||||||
|
Iris.proj.downloadSearch(sender, args[1], false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iris.proj.installIntoWorld(sender, args[1], folder);
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getArgsUsage()
|
||||||
|
{
|
||||||
|
return "<world> <project>";
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package com.volmit.iris.command;
|
package com.volmit.iris.command;
|
||||||
|
|
||||||
import org.bukkit.FluidCollisionMode;
|
import org.bukkit.FluidCollisionMode;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ import org.bukkit.WorldCreator;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.IrisSettings;
|
import com.volmit.iris.IrisSettings;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
|
||||||
public class NMSCreator
|
public class NMSCreator
|
||||||
{
|
{
|
||||||
public static World createWorld(WorldCreator creator)
|
public static World createWorld(WorldCreator creator)
|
||||||
@ -17,6 +19,8 @@ public class NMSCreator
|
|||||||
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
public static World createWorld(WorldCreator creator, boolean loadSpawn)
|
||||||
{
|
{
|
||||||
if(IrisSettings.get().isSkipPrepareSpawnNMS())
|
if(IrisSettings.get().isSkipPrepareSpawnNMS())
|
||||||
|
{
|
||||||
|
if(!PaperLib.isPaper())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -45,6 +49,7 @@ public class NMSCreator
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Bukkit.createWorld(creator);
|
return Bukkit.createWorld(creator);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class PregenGui extends JPanel
|
|||||||
g.drawString(i, 20, hh += h);
|
g.drawString(i, 20, hh += h);
|
||||||
}
|
}
|
||||||
|
|
||||||
J.sleep((long) 1000);
|
J.sleep((long) 1);
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,17 @@ public class ProjectManager
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage("Found " + type + " dimension in " + ProjectManager.workspaceName + " folder. Repackaging");
|
sender.sendMessage("Found " + type + " dimension in " + ProjectManager.workspaceName + " folder. Repackaging");
|
||||||
ZipUtil.unpack(Iris.proj.compilePackage(sender, type, true, true), iris);
|
File f = new IrisProject(new File(getWorkspaceFolder(), type)).getPath();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileUtils.copyDirectory(f, iris);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File dimf = new File(iris, "dimensions/" + type + ".json");
|
File dimf = new File(iris, "dimensions/" + type + ".json");
|
||||||
@ -145,6 +155,11 @@ public class ProjectManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void downloadSearch(MortarSender sender, String key, boolean trim)
|
public void downloadSearch(MortarSender sender, String key, boolean trim)
|
||||||
|
{
|
||||||
|
downloadSearch(sender, key, trim, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void downloadSearch(MortarSender sender, String key, boolean trim, boolean forceOverwrite)
|
||||||
{
|
{
|
||||||
String repo = getListing(false).get(key);
|
String repo = getListing(false).get(key);
|
||||||
|
|
||||||
@ -157,7 +172,7 @@ public class ProjectManager
|
|||||||
sender.sendMessage("Found '" + key + "' in the Iris Listing as " + repo);
|
sender.sendMessage("Found '" + key + "' in the Iris Listing as " + repo);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
download(sender, repo, trim);
|
download(sender, repo, trim, forceOverwrite);
|
||||||
}
|
}
|
||||||
catch(JsonSyntaxException | IOException e)
|
catch(JsonSyntaxException | IOException e)
|
||||||
{
|
{
|
||||||
@ -166,6 +181,11 @@ public class ProjectManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void download(MortarSender sender, String repo, boolean trim) throws JsonSyntaxException, IOException
|
public void download(MortarSender sender, String repo, boolean trim) throws JsonSyntaxException, IOException
|
||||||
|
{
|
||||||
|
download(sender, repo, trim, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void download(MortarSender sender, String repo, boolean trim, boolean forceOverwrite) throws JsonSyntaxException, IOException
|
||||||
{
|
{
|
||||||
String url = "https://codeload.github.com/" + repo + "/zip/master";
|
String url = "https://codeload.github.com/" + repo + "/zip/master";
|
||||||
sender.sendMessage("Downloading " + url);
|
sender.sendMessage("Downloading " + url);
|
||||||
@ -208,6 +228,13 @@ public class ProjectManager
|
|||||||
String key = dim.getName().split("\\Q.\\E")[0];
|
String key = dim.getName().split("\\Q.\\E")[0];
|
||||||
IrisDimension d = new Gson().fromJson(IO.readAll(dim), IrisDimension.class);
|
IrisDimension d = new Gson().fromJson(IO.readAll(dim), IrisDimension.class);
|
||||||
sender.sendMessage("Importing " + d.getName() + " (" + key + ")");
|
sender.sendMessage("Importing " + d.getName() + " (" + key + ")");
|
||||||
|
File packEntry = new File(packs, key);
|
||||||
|
|
||||||
|
if(forceOverwrite)
|
||||||
|
{
|
||||||
|
IO.delete(packEntry);
|
||||||
|
}
|
||||||
|
|
||||||
Iris.globaldata.dump();
|
Iris.globaldata.dump();
|
||||||
Iris.globaldata.preferFolder(null);
|
Iris.globaldata.preferFolder(null);
|
||||||
|
|
||||||
@ -217,8 +244,6 @@ public class ProjectManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File packEntry = new File(packs, key);
|
|
||||||
|
|
||||||
if(packEntry.exists() && packEntry.listFiles().length > 0)
|
if(packEntry.exists() && packEntry.listFiles().length > 0)
|
||||||
{
|
{
|
||||||
sender.sendMessage("Another pack is using the key " + key + ". IMPORT FAILED!");
|
sender.sendMessage("Another pack is using the key " + key + ". IMPORT FAILED!");
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.volmit.iris.util;
|
package com.volmit.iris.util;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -16,6 +17,8 @@ import com.volmit.iris.gen.IrisTerrainProvider;
|
|||||||
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||||
import com.volmit.iris.gui.PregenGui;
|
import com.volmit.iris.gui.PregenGui;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
|
||||||
public class PregenJob implements Listener
|
public class PregenJob implements Listener
|
||||||
{
|
{
|
||||||
private World world;
|
private World world;
|
||||||
@ -24,6 +27,7 @@ public class PregenJob implements Listener
|
|||||||
private int genned;
|
private int genned;
|
||||||
private boolean completed;
|
private boolean completed;
|
||||||
public static int task = -1;
|
public static int task = -1;
|
||||||
|
private Semaphore working;
|
||||||
private AtomicInteger g = new AtomicInteger();
|
private AtomicInteger g = new AtomicInteger();
|
||||||
private PrecisionStopwatch s;
|
private PrecisionStopwatch s;
|
||||||
private ChronoLatch cl;
|
private ChronoLatch cl;
|
||||||
@ -41,20 +45,22 @@ public class PregenJob implements Listener
|
|||||||
private boolean first;
|
private boolean first;
|
||||||
private Consumer2<ChunkPosition, Color> consumer;
|
private Consumer2<ChunkPosition, Color> consumer;
|
||||||
private IrisTerrainProvider tp;
|
private IrisTerrainProvider tp;
|
||||||
|
private double cps = 0;
|
||||||
|
private int lg = 0;
|
||||||
|
private long lt = M.ms();
|
||||||
private int cubeSize = IrisSettings.get().getPregenTileSize();
|
private int cubeSize = IrisSettings.get().getPregenTileSize();
|
||||||
|
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
||||||
int xc = 0;
|
int xc = 0;
|
||||||
|
|
||||||
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
||||||
{
|
{
|
||||||
g.set(0);
|
g.set(0);
|
||||||
|
working = new Semaphore(tc());
|
||||||
this.s = PrecisionStopwatch.start();
|
this.s = PrecisionStopwatch.start();
|
||||||
Iris.instance.registerListener(this);
|
Iris.instance.registerListener(this);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.onDone = onDone;
|
this.onDone = onDone;
|
||||||
world.getWorldBorder().setCenter(0, 0);
|
|
||||||
world.getWorldBorder().setWarningDistance(64);
|
|
||||||
world.getWorldBorder().setSize(size);
|
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
cl = new ChronoLatch(3000);
|
cl = new ChronoLatch(3000);
|
||||||
clx = new ChronoLatch(20000);
|
clx = new ChronoLatch(20000);
|
||||||
@ -93,6 +99,11 @@ public class PregenJob implements Listener
|
|||||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::onTick, 0, 0);
|
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::onTick, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int tc()
|
||||||
|
{
|
||||||
|
return 48;
|
||||||
|
}
|
||||||
|
|
||||||
public static void stop()
|
public static void stop()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -116,10 +127,18 @@ public class PregenJob implements Listener
|
|||||||
|
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
|
|
||||||
|
if(PaperLib.isPaper())
|
||||||
|
{
|
||||||
|
tickPaper();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
while(p.getMilliseconds() < 7000)
|
while(p.getMilliseconds() < 7000)
|
||||||
{
|
{
|
||||||
tick();
|
tick();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(cl.flip())
|
if(cl.flip())
|
||||||
{
|
{
|
||||||
@ -138,8 +157,37 @@ public class PregenJob implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void tickPaper()
|
||||||
|
{
|
||||||
|
if(working.getQueueLength() >= tc() / 2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < 128; i++)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void tick()
|
public void tick()
|
||||||
{
|
{
|
||||||
|
if((total - genned < 0 || genned > (((size + 32) / 16) * (size + 32) / 16)) && !completed)
|
||||||
|
{
|
||||||
|
completed = true;
|
||||||
|
|
||||||
|
for(Chunk i : world.getLoadedChunks())
|
||||||
|
{
|
||||||
|
i.unload(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveAll();
|
||||||
|
Iris.instance.unregisterListener(this);
|
||||||
|
completed = true;
|
||||||
|
sender.sendMessage("Pregen Completed!");
|
||||||
|
onDone.run();
|
||||||
|
}
|
||||||
|
|
||||||
if(completed)
|
if(completed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -190,18 +238,21 @@ public class PregenJob implements Listener
|
|||||||
chunkSpiraler.retarget(cubeSize, cubeSize);
|
chunkSpiraler.retarget(cubeSize, cubeSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else if(!completed)
|
||||||
{
|
{
|
||||||
for(Chunk i : world.getLoadedChunks())
|
genned += (((size + 32) / 16) * (size + 32) / 16) + 100000;
|
||||||
{
|
|
||||||
i.unload(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAll();
|
double dur = M.ms() - lt;
|
||||||
Iris.instance.unregisterListener(this);
|
|
||||||
completed = true;
|
if(dur > 1000 && genned > lg)
|
||||||
sender.sendMessage("Pregen Completed!");
|
{
|
||||||
onDone.run();
|
int gain = genned - lg;
|
||||||
|
double rat = dur / 1000D;
|
||||||
|
acps.put((double) gain / rat);
|
||||||
|
cps = acps.getAverage();
|
||||||
|
lt = M.ms();
|
||||||
|
lg = genned;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,6 +264,46 @@ public class PregenJob implements Listener
|
|||||||
private void tickSyncChunk()
|
private void tickSyncChunk()
|
||||||
{
|
{
|
||||||
if(isChunkWithin(chunkX, chunkZ))
|
if(isChunkWithin(chunkX, chunkZ))
|
||||||
|
{
|
||||||
|
if(PaperLib.isPaper())
|
||||||
|
{
|
||||||
|
if(consumer != null)
|
||||||
|
{
|
||||||
|
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.magenta.darker().darker().darker());
|
||||||
|
}
|
||||||
|
int cx = chunkX;
|
||||||
|
int cz = chunkZ;
|
||||||
|
J.a(() ->
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
working.acquire();
|
||||||
|
|
||||||
|
if(consumer != null)
|
||||||
|
{
|
||||||
|
consumer.accept(new ChunkPosition(cx, cz), Color.magenta);
|
||||||
|
}
|
||||||
|
|
||||||
|
PaperLib.getChunkAtAsync(world, cx, cz).thenAccept(chunk ->
|
||||||
|
{
|
||||||
|
working.release();
|
||||||
|
genned++;
|
||||||
|
|
||||||
|
if(consumer != null)
|
||||||
|
{
|
||||||
|
consumer.accept(new ChunkPosition(chunk.getX(), chunk.getZ()), tp != null ? tp.render(chunk.getX() * 16, chunk.getZ() * 16) : Color.blue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(InterruptedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if(consumer != null)
|
if(consumer != null)
|
||||||
{
|
{
|
||||||
@ -227,6 +318,7 @@ public class PregenJob implements Listener
|
|||||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), tp != null ? tp.render(chunkX * 16, chunkZ * 16) : Color.blue);
|
consumer.accept(new ChunkPosition(chunkX, chunkZ), tp != null ? tp.render(chunkX * 16, chunkZ * 16) : Color.blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -295,9 +387,9 @@ public class PregenJob implements Listener
|
|||||||
|
|
||||||
public String[] getProgress()
|
public String[] getProgress()
|
||||||
{
|
{
|
||||||
long eta = (long) ((total - genned) * (s.getMilliseconds() / (double) genned));
|
long eta = (long) ((total - genned) * 1000D / cps);
|
||||||
|
|
||||||
return new String[] {"Progress: " + Form.pc(Math.min((double) genned / (double) total, 1.0), 0), "Generated: " + Form.f(genned) + " Chunks", "Remaining: " + Form.f(total - genned) + " Chunks", "Elapsed: " + Form.duration((long) s.getMilliseconds(), 2), "Estimate: " + ((genned >= total - 5 ? "Any second..." : s.getMilliseconds() < 25000 ? "Calculating..." : Form.duration(eta, 2))), "ChunksMS: " + Form.duration((s.getMilliseconds() / (double) genned), 2), "Chunks/s: " + Form.f(1000D / (s.getMilliseconds() / genned), 1),
|
return new String[] {"Progress: " + Form.pc(Math.min((double) genned / (double) total, 1.0), 0), "Generated: " + Form.f(genned) + " Chunks", "Remaining: " + Form.f(total - genned) + " Chunks", "Elapsed: " + Form.duration((long) s.getMilliseconds(), 2), "Estimate: " + ((genned >= total - 5 ? "Any second..." : s.getMilliseconds() < 25000 ? "Calculating..." : Form.duration(eta, 2))), "ChunksMS: " + Form.duration(1000D / cps, 2), "Chunks/s: " + Form.f(cps, 1),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user