mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +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>
|
||||
<groupId>bytecode.ninja</groupId>
|
||||
<artifactId>Iris</artifactId>
|
||||
<version>1.0.13</version>
|
||||
<version>1.0.14</version>
|
||||
<name>Iris</name>
|
||||
<properties>
|
||||
<skip.copy>false</skip.copy>
|
||||
@ -144,6 +144,10 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bcn</id>
|
||||
<url>http://bytecode.ninja/repository/bcn/</url>
|
||||
@ -170,6 +174,13 @@
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Paper API -->
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- NMS -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit.craftbukkit</groupId>
|
||||
|
@ -22,6 +22,12 @@ public class CommandIris extends MortarCommand
|
||||
@Command
|
||||
private CommandIrisDownload download;
|
||||
|
||||
@Command
|
||||
private CommandIrisUpdateProject updateProject;
|
||||
|
||||
@Command
|
||||
private CommandIrisUpdateWorld updateWorld;
|
||||
|
||||
@Command
|
||||
private CommandIrisWhat what;
|
||||
|
||||
|
@ -34,6 +34,11 @@ public class CommandIrisCreate extends MortarCommand
|
||||
@Override
|
||||
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 type = "overworld";
|
||||
long seed = 1337;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.volmit.iris.command;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.util.C;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
@ -20,15 +19,9 @@ public class CommandIrisDownload extends MortarCommand
|
||||
@Override
|
||||
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)
|
||||
{
|
||||
sender.sendMessage("/iris std dl " + C.BOLD + "<NAME>");
|
||||
sender.sendMessage("/iris dl " + C.BOLD + "<NAME>");
|
||||
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;
|
||||
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -7,6 +7,8 @@ import org.bukkit.WorldCreator;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
public class NMSCreator
|
||||
{
|
||||
public static World createWorld(WorldCreator creator)
|
||||
@ -18,31 +20,34 @@ public class NMSCreator
|
||||
{
|
||||
if(IrisSettings.get().isSkipPrepareSpawnNMS())
|
||||
{
|
||||
try
|
||||
if(!PaperLib.isPaper())
|
||||
{
|
||||
String code = Iris.nmsTag();
|
||||
try
|
||||
{
|
||||
String code = Iris.nmsTag();
|
||||
|
||||
if(code.equals("v1_16_R2"))
|
||||
{
|
||||
return NMSCreator162.createWorld(creator, loadSpawn);
|
||||
if(code.equals("v1_16_R2"))
|
||||
{
|
||||
return NMSCreator162.createWorld(creator, loadSpawn);
|
||||
}
|
||||
else if(code.equals("v1_16_R1"))
|
||||
{
|
||||
return NMSCreator161.createWorld(creator, loadSpawn);
|
||||
}
|
||||
else if(code.equals("v1_15_R1"))
|
||||
{
|
||||
return NMSCreator151.createWorld(creator, loadSpawn);
|
||||
}
|
||||
else if(code.equals("v1_14_R1"))
|
||||
{
|
||||
return NMSCreator141.createWorld(creator, loadSpawn);
|
||||
}
|
||||
}
|
||||
else if(code.equals("v1_16_R1"))
|
||||
{
|
||||
return NMSCreator161.createWorld(creator, loadSpawn);
|
||||
}
|
||||
else if(code.equals("v1_15_R1"))
|
||||
{
|
||||
return NMSCreator151.createWorld(creator, loadSpawn);
|
||||
}
|
||||
else if(code.equals("v1_14_R1"))
|
||||
{
|
||||
return NMSCreator141.createWorld(creator, loadSpawn);
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class PregenGui extends JPanel
|
||||
g.drawString(i, 20, hh += h);
|
||||
}
|
||||
|
||||
J.sleep((long) 1000);
|
||||
J.sleep((long) 1);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,17 @@ public class ProjectManager
|
||||
else
|
||||
{
|
||||
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");
|
||||
@ -145,6 +155,11 @@ public class ProjectManager
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -157,7 +172,7 @@ public class ProjectManager
|
||||
sender.sendMessage("Found '" + key + "' in the Iris Listing as " + repo);
|
||||
try
|
||||
{
|
||||
download(sender, repo, trim);
|
||||
download(sender, repo, trim, forceOverwrite);
|
||||
}
|
||||
catch(JsonSyntaxException | IOException e)
|
||||
{
|
||||
@ -166,6 +181,11 @@ public class ProjectManager
|
||||
}
|
||||
|
||||
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";
|
||||
sender.sendMessage("Downloading " + url);
|
||||
@ -208,6 +228,13 @@ public class ProjectManager
|
||||
String key = dim.getName().split("\\Q.\\E")[0];
|
||||
IrisDimension d = new Gson().fromJson(IO.readAll(dim), IrisDimension.class);
|
||||
sender.sendMessage("Importing " + d.getName() + " (" + key + ")");
|
||||
File packEntry = new File(packs, key);
|
||||
|
||||
if(forceOverwrite)
|
||||
{
|
||||
IO.delete(packEntry);
|
||||
}
|
||||
|
||||
Iris.globaldata.dump();
|
||||
Iris.globaldata.preferFolder(null);
|
||||
|
||||
@ -217,8 +244,6 @@ public class ProjectManager
|
||||
return;
|
||||
}
|
||||
|
||||
File packEntry = new File(packs, key);
|
||||
|
||||
if(packEntry.exists() && packEntry.listFiles().length > 0)
|
||||
{
|
||||
sender.sendMessage("Another pack is using the key " + key + ". IMPORT FAILED!");
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
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.gui.PregenGui;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
public class PregenJob implements Listener
|
||||
{
|
||||
private World world;
|
||||
@ -24,6 +27,7 @@ public class PregenJob implements Listener
|
||||
private int genned;
|
||||
private boolean completed;
|
||||
public static int task = -1;
|
||||
private Semaphore working;
|
||||
private AtomicInteger g = new AtomicInteger();
|
||||
private PrecisionStopwatch s;
|
||||
private ChronoLatch cl;
|
||||
@ -41,20 +45,22 @@ public class PregenJob implements Listener
|
||||
private boolean first;
|
||||
private Consumer2<ChunkPosition, Color> consumer;
|
||||
private IrisTerrainProvider tp;
|
||||
private double cps = 0;
|
||||
private int lg = 0;
|
||||
private long lt = M.ms();
|
||||
private int cubeSize = IrisSettings.get().getPregenTileSize();
|
||||
private RollingSequence acps = new RollingSequence(PaperLib.isPaper() ? 8 : 32);
|
||||
int xc = 0;
|
||||
|
||||
public PregenJob(World world, int size, MortarSender sender, Runnable onDone)
|
||||
{
|
||||
g.set(0);
|
||||
working = new Semaphore(tc());
|
||||
this.s = PrecisionStopwatch.start();
|
||||
Iris.instance.registerListener(this);
|
||||
this.world = world;
|
||||
this.size = size;
|
||||
this.onDone = onDone;
|
||||
world.getWorldBorder().setCenter(0, 0);
|
||||
world.getWorldBorder().setWarningDistance(64);
|
||||
world.getWorldBorder().setSize(size);
|
||||
this.sender = sender;
|
||||
cl = new ChronoLatch(3000);
|
||||
clx = new ChronoLatch(20000);
|
||||
@ -93,6 +99,11 @@ public class PregenJob implements Listener
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::onTick, 0, 0);
|
||||
}
|
||||
|
||||
public int tc()
|
||||
{
|
||||
return 48;
|
||||
}
|
||||
|
||||
public static void stop()
|
||||
{
|
||||
try
|
||||
@ -116,9 +127,17 @@ public class PregenJob implements Listener
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
|
||||
while(p.getMilliseconds() < 7000)
|
||||
if(PaperLib.isPaper())
|
||||
{
|
||||
tick();
|
||||
tickPaper();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
while(p.getMilliseconds() < 7000)
|
||||
{
|
||||
tick();
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
return;
|
||||
@ -190,18 +238,21 @@ public class PregenJob implements Listener
|
||||
chunkSpiraler.retarget(cubeSize, cubeSize);
|
||||
}
|
||||
|
||||
else
|
||||
else if(!completed)
|
||||
{
|
||||
for(Chunk i : world.getLoadedChunks())
|
||||
{
|
||||
i.unload(true);
|
||||
}
|
||||
genned += (((size + 32) / 16) * (size + 32) / 16) + 100000;
|
||||
}
|
||||
|
||||
saveAll();
|
||||
Iris.instance.unregisterListener(this);
|
||||
completed = true;
|
||||
sender.sendMessage("Pregen Completed!");
|
||||
onDone.run();
|
||||
double dur = M.ms() - lt;
|
||||
|
||||
if(dur > 1000 && genned > lg)
|
||||
{
|
||||
int gain = genned - lg;
|
||||
double rat = dur / 1000D;
|
||||
acps.put((double) gain / rat);
|
||||
cps = acps.getAverage();
|
||||
lt = M.ms();
|
||||
lg = genned;
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,17 +265,58 @@ public class PregenJob implements Listener
|
||||
{
|
||||
if(isChunkWithin(chunkX, chunkZ))
|
||||
{
|
||||
if(consumer != null)
|
||||
if(PaperLib.isPaper())
|
||||
{
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.blue.darker().darker());
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
world.loadChunk(chunkX, chunkZ);
|
||||
genned++;
|
||||
|
||||
if(consumer != null)
|
||||
else
|
||||
{
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), tp != null ? tp.render(chunkX * 16, chunkZ * 16) : Color.blue);
|
||||
if(consumer != null)
|
||||
{
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), Color.blue.darker().darker());
|
||||
}
|
||||
|
||||
world.loadChunk(chunkX, chunkZ);
|
||||
genned++;
|
||||
|
||||
if(consumer != null)
|
||||
{
|
||||
consumer.accept(new ChunkPosition(chunkX, chunkZ), tp != null ? tp.render(chunkX * 16, chunkZ * 16) : Color.blue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,9 +387,9 @@ public class PregenJob implements Listener
|
||||
|
||||
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