mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Fix world create commands & pregnes
This commit is contained in:
parent
9453b86907
commit
bd8d9cc3aa
@ -21,10 +21,12 @@ package com.volmit.iris.core.command.world;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
import com.volmit.iris.core.tools.IrisWorldCreator;
|
import com.volmit.iris.core.tools.IrisWorldCreator;
|
||||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||||
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
import com.volmit.iris.engine.platform.PlatformChunkGenerator;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.exceptions.IrisException;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.plugin.MortarCommand;
|
import com.volmit.iris.util.plugin.MortarCommand;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
@ -89,7 +91,6 @@ public class CommandIrisCreate extends MortarCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(VolmitSender sender, String[] args) {
|
public boolean handle(VolmitSender sender, String[] args) {
|
||||||
|
|
||||||
String worldName;
|
String worldName;
|
||||||
File folder;
|
File folder;
|
||||||
String dimensionName;
|
String dimensionName;
|
||||||
@ -124,21 +125,25 @@ public class CommandIrisCreate extends MortarCommand {
|
|||||||
seed = i.startsWith("seed=") ? Long.parseLong(i.split("\\Q=\\E")[1]) : seed;
|
seed = i.startsWith("seed=") ? Long.parseLong(i.split("\\Q=\\E")[1]) : seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
dimension = Iris.proj.installIntoWorld(sender, dimensionName, folder);
|
String finalDimensionName = dimensionName;
|
||||||
|
|
||||||
if (dimension == null) {
|
|
||||||
sender.sendMessage("Cannot find dimension '" + dimensionName + "'. Did you forget to /iris download " + dimensionName + "?");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dimension.getEnvironment() == null) {
|
|
||||||
dimension.setEnvironment(World.Environment.NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
File iris = new File(folder, "iris");
|
long finalSeed = seed;
|
||||||
iris.mkdirs();
|
J.a(() -> {
|
||||||
|
try {
|
||||||
onDone(sender, createWorld(sender, worldName, dimension, seed));
|
IrisToolbelt.createWorld()
|
||||||
|
.dimension(finalDimensionName)
|
||||||
|
.name(worldName)
|
||||||
|
.seed(finalSeed)
|
||||||
|
.sender(sender)
|
||||||
|
.studio(false)
|
||||||
|
.create();
|
||||||
|
} catch (IrisException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
sender.sendMessage("Creation Failed! Check Console.");
|
||||||
|
}
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,147 +151,4 @@ public class CommandIrisCreate extends MortarCommand {
|
|||||||
protected String getArgsUsage() {
|
protected String getArgsUsage() {
|
||||||
return "<name> [type=<type>] [seed=<seed>]";
|
return "<name> [type=<type>] [seed=<seed>]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ran when world is created
|
|
||||||
*
|
|
||||||
* @param sender The sender to send updates to
|
|
||||||
* @param world The created world
|
|
||||||
*/
|
|
||||||
private void onDone(VolmitSender sender, World world) {
|
|
||||||
sender.sendMessage(world.getName() + " Spawn Area generated.");
|
|
||||||
sender.sendMessage("You must remember to either have multiverse installed or use the Bukkit method to load this world with the Iris Generator on startup.");
|
|
||||||
sender.sendMessage("Wiki: https://volmitsoftware.gitbook.io/iris/getting-started");
|
|
||||||
|
|
||||||
if (sender.isPlayer()) {
|
|
||||||
try {
|
|
||||||
sender.player().teleport(world.getSpawnLocation());
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Iris.reportError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
O<Boolean> b = new O<>();
|
|
||||||
b.set(true);
|
|
||||||
|
|
||||||
J.a(() ->
|
|
||||||
{
|
|
||||||
while (!b.get()) {
|
|
||||||
J.sleep(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () ->
|
|
||||||
{
|
|
||||||
world.save();
|
|
||||||
sender.sendMessage("All Done!");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a world with either Multiverse (preferred, if supported) or NMS
|
|
||||||
*
|
|
||||||
* @param sender The sender to send updates to
|
|
||||||
* @param worldName The name of the world to create
|
|
||||||
* @param dimension The dimension to create the world with
|
|
||||||
* @param seed The seed to use to generate
|
|
||||||
* @return The created world
|
|
||||||
*/
|
|
||||||
private World createWorld(VolmitSender sender, String worldName, IrisDimension dimension, long seed) {
|
|
||||||
if (Iris.linkMultiverseCore.isSupported()) {
|
|
||||||
return createMultiverseWorld(sender, worldName, dimension, seed);
|
|
||||||
} else {
|
|
||||||
return createNMSWorld(sender, worldName, dimension, seed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a world with Multiverse
|
|
||||||
*
|
|
||||||
* @param sender The sender to send updates to
|
|
||||||
* @param worldName The name of the world to create
|
|
||||||
* @param dimension The dimension to create the world with
|
|
||||||
* @param seed The seed to use to generate
|
|
||||||
* @return The created world
|
|
||||||
*/
|
|
||||||
public World createMultiverseWorld(VolmitSender sender, String worldName, IrisDimension dimension, long seed) {
|
|
||||||
|
|
||||||
if (!Iris.linkMultiverseCore.isSupported()) {
|
|
||||||
sender.sendMessage("A world was attempted to be created with Multiverse but it is not supported!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Iris.linkMultiverseCore.assignWorldType(worldName, dimension.getName());
|
|
||||||
|
|
||||||
StringBuilder command = new StringBuilder("mv create")
|
|
||||||
.append(worldName)
|
|
||||||
.append(" ")
|
|
||||||
.append(Iris.linkMultiverseCore.envName(dimension.getEnvironment()))
|
|
||||||
.append(" -s ")
|
|
||||||
.append(seed)
|
|
||||||
.append(" -g Iris:")
|
|
||||||
.append(dimension.getLoadKey());
|
|
||||||
|
|
||||||
sender.sendMessage("Delegating " + command);
|
|
||||||
Bukkit.dispatchCommand(sender, command.toString());
|
|
||||||
return Bukkit.getWorld(worldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a world using NMS
|
|
||||||
*
|
|
||||||
* @param sender The sender to send updates to
|
|
||||||
* @param worldName The name of the world to create
|
|
||||||
* @param dimension The dimension to create the world with
|
|
||||||
* @param seed The seed to use to generate
|
|
||||||
* @return The created world
|
|
||||||
*/
|
|
||||||
public World createNMSWorld(VolmitSender sender, String worldName, IrisDimension dimension, long seed) {
|
|
||||||
|
|
||||||
WorldCreator wc = new IrisWorldCreator()
|
|
||||||
.dimension(dimension.getLoadKey())
|
|
||||||
.name(worldName)
|
|
||||||
.seed(seed)
|
|
||||||
.productionMode()
|
|
||||||
.create();
|
|
||||||
PlatformChunkGenerator gen = (PlatformChunkGenerator) wc.generator();
|
|
||||||
|
|
||||||
if (gen == null) {
|
|
||||||
sender.sendMessage("Failed to create generator! Gen is null!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomicReference<World> world = new AtomicReference<>();
|
|
||||||
|
|
||||||
J.s(() -> {
|
|
||||||
O<Boolean> done = new O<>();
|
|
||||||
done.set(false);
|
|
||||||
|
|
||||||
J.a(() ->
|
|
||||||
{
|
|
||||||
double last = 0;
|
|
||||||
int req = 800;
|
|
||||||
while (!done.get()) {
|
|
||||||
|
|
||||||
boolean shouldBeDone = false;
|
|
||||||
double v = (double) gen.getEngine().getGenerated() / req;
|
|
||||||
|
|
||||||
if (last > v || v > 1) {
|
|
||||||
shouldBeDone = true;
|
|
||||||
v = last;
|
|
||||||
} else {
|
|
||||||
last = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage("Generating " + Form.pc(v) + (shouldBeDone ? " (Waiting on Server...)" : ""));
|
|
||||||
J.sleep(3000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
world.set(INMS.get().createWorld(wc));
|
|
||||||
done.set(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
return world.get();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -169,67 +169,13 @@ public class IrisProject {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
String wfp = "iris/" + UUID.randomUUID();
|
J.a(() -> IrisToolbelt.createWorld()
|
||||||
|
|
||||||
WorldCreator c = new IrisWorldCreator().dimension(getName())
|
|
||||||
.seed(1337)
|
.seed(1337)
|
||||||
.name(wfp)
|
.sender(sender)
|
||||||
.studioMode()
|
.studio(true)
|
||||||
.create();
|
.name("iris/" + UUID.randomUUID())
|
||||||
|
.dimension(d.getLoadKey())
|
||||||
PlatformChunkGenerator gx = ((PlatformChunkGenerator) c.generator());
|
.create());
|
||||||
O<Boolean> done = new O<>();
|
|
||||||
done.set(false);
|
|
||||||
activeProvider = gx;
|
|
||||||
|
|
||||||
J.a(() ->
|
|
||||||
{
|
|
||||||
double last = 0;
|
|
||||||
int req = 400;
|
|
||||||
|
|
||||||
while (gx.getEngine().getGenerated() < req) {
|
|
||||||
assert gx != null;
|
|
||||||
double v = (double) gx.getEngine().getGenerated() / (double) req;
|
|
||||||
|
|
||||||
if (sender.isPlayer()) {
|
|
||||||
sender.sendProgress(v, "Generating");
|
|
||||||
J.sleep(16);
|
|
||||||
} else {
|
|
||||||
sender.sendProgress(v, "Generating");
|
|
||||||
J.sleep(16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sender.isPlayer()) {
|
|
||||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generation Complete"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//@builder
|
|
||||||
World world = INMS.get().createWorld(c);
|
|
||||||
if (IrisSettings.get().getStudio().isDisableTimeAndWeather()) {
|
|
||||||
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
|
||||||
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
|
|
||||||
world.setTime(6000);
|
|
||||||
}
|
|
||||||
Iris.linkMultiverseCore.removeFromConfig(world);
|
|
||||||
|
|
||||||
done.set(true);
|
|
||||||
|
|
||||||
if (sender.isPlayer()) {
|
|
||||||
assert world != null;
|
|
||||||
sender.player().teleport(world.getSpawnLocation());
|
|
||||||
} else {
|
|
||||||
sender.sendAction(C.IRIS + "Generation Complete");
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () ->
|
|
||||||
{
|
|
||||||
if (sender.isPlayer()) {
|
|
||||||
sender.player().setGameMode(GameMode.SPECTATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
onDone.run();
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
@ -18,8 +18,11 @@
|
|||||||
|
|
||||||
package com.volmit.iris.core.tools;
|
package com.volmit.iris.core.tools;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.AtomicDouble;
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.pregenerator.PregenTask;
|
import com.volmit.iris.core.pregenerator.PregenTask;
|
||||||
|
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||||
import com.volmit.iris.engine.object.common.HeadlessWorld;
|
import com.volmit.iris.engine.object.common.HeadlessWorld;
|
||||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||||
import com.volmit.iris.engine.platform.HeadlessGenerator;
|
import com.volmit.iris.engine.platform.HeadlessGenerator;
|
||||||
@ -36,9 +39,12 @@ import lombok.Data;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,13 +79,6 @@ public class IrisCreator {
|
|||||||
*/
|
*/
|
||||||
private String name = "irisworld";
|
private String name = "irisworld";
|
||||||
|
|
||||||
/**
|
|
||||||
* Headless mode allows Iris to generate / query engine information
|
|
||||||
* without needing an actual world loaded. This is normally only used
|
|
||||||
* for pregeneration purposes but it could be used for mapping.
|
|
||||||
*/
|
|
||||||
private boolean headless = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Studio mode makes the engine hotloadable and uses the dimension in
|
* Studio mode makes the engine hotloadable and uses the dimension in
|
||||||
* your Iris/packs folder instead of copying the dimension files into
|
* your Iris/packs folder instead of copying the dimension files into
|
||||||
@ -93,129 +92,121 @@ public class IrisCreator {
|
|||||||
* @return the IrisAccess
|
* @return the IrisAccess
|
||||||
* @throws IrisException shit happens
|
* @throws IrisException shit happens
|
||||||
*/
|
*/
|
||||||
public PlatformChunkGenerator create() throws IrisException {
|
public World create() throws IrisException {
|
||||||
IrisDimension d = IrisToolbelt.getDimension(dimension());
|
if(Bukkit.isPrimaryThread())
|
||||||
PlatformChunkGenerator access = null;
|
{
|
||||||
Consumer<Double> prog = (pxx) -> {
|
throw new IrisException("You cannot invoke create() on the main thread.");
|
||||||
double px = pxx;
|
|
||||||
|
|
||||||
if (pregen != null && !headless) {
|
|
||||||
px = (px / 2) + 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sender != null) {
|
|
||||||
if (sender.isPlayer()) {
|
|
||||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generating " + Form.pc(px)));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("Generating " + Form.f(px, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (d == null) {
|
|
||||||
throw new MissingDimensionException("Cannot find dimension '" + dimension() + "'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headless) {
|
IrisDimension d = IrisToolbelt.getDimension(dimension());
|
||||||
HeadlessWorld w = new HeadlessWorld(name, d, seed, studio);
|
|
||||||
access = w.generate();
|
|
||||||
} else {
|
|
||||||
O<Boolean> done = new O<>();
|
|
||||||
done.set(false);
|
|
||||||
WorldCreator wc = new IrisWorldCreator()
|
|
||||||
.dimension(dimension)
|
|
||||||
.name(name)
|
|
||||||
.seed(seed)
|
|
||||||
.studio(studio)
|
|
||||||
.create();
|
|
||||||
access = (PlatformChunkGenerator) wc.generator();
|
|
||||||
PlatformChunkGenerator finalAccess1 = access;
|
|
||||||
|
|
||||||
J.a(() ->
|
if(d == null)
|
||||||
{
|
{
|
||||||
int req = 400;
|
throw new IrisException("Dimension cannot be found null for id " + dimension());
|
||||||
|
}
|
||||||
|
|
||||||
while (finalAccess1.getEngine().getGenerated() < req && !done.get()) {
|
if(!studio())
|
||||||
double v = (double) finalAccess1.getEngine().getGenerated() / (double) req;
|
{
|
||||||
|
Iris.proj.installIntoWorld(sender, d.getLoadKey(), new File(name()));
|
||||||
|
}
|
||||||
|
|
||||||
if (pregen != null) {
|
PlatformChunkGenerator access = null;
|
||||||
v /= 2;
|
AtomicReference<World> world = new AtomicReference<>();
|
||||||
}
|
AtomicDouble pp = new AtomicDouble(0);
|
||||||
|
O<Boolean> done = new O<>();
|
||||||
|
done.set(false);
|
||||||
|
WorldCreator wc = new IrisWorldCreator()
|
||||||
|
.dimension(dimension)
|
||||||
|
.name(name)
|
||||||
|
.seed(seed)
|
||||||
|
.studio(studio)
|
||||||
|
.create();
|
||||||
|
|
||||||
if (sender.isPlayer()) {
|
access = (PlatformChunkGenerator) wc.generator();
|
||||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess1.getEngine().getGenerated()) + " Left)"))));
|
PlatformChunkGenerator finalAccess1 = access;
|
||||||
J.sleep(50);
|
|
||||||
} else {
|
J.a(() ->
|
||||||
sender.sendMessage(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess1.getEngine().getGenerated()) + " Left)")));
|
{
|
||||||
J.sleep(1000);
|
int req = 441;
|
||||||
}
|
|
||||||
|
while (finalAccess1.getEngine().getGenerated() < req) {
|
||||||
|
double v = (double) finalAccess1.getEngine().getGenerated() / (double) req;
|
||||||
|
|
||||||
|
if (sender.isPlayer()) {
|
||||||
|
sender.sendProgress(v, "Generating");
|
||||||
|
J.sleep(16);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess1.getEngine().getGenerated()) + " Left)")));
|
||||||
|
J.sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generation Complete"));
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
J.sfut(wc::createWorld).get();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
J.sfut(() -> {
|
||||||
|
world.set(wc.createWorld());
|
||||||
|
}).get();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access == null) {
|
if (access == null) {
|
||||||
throw new IrisException("Access is null. Something bad happened.");
|
throw new IrisException("Access is null. Something bad happened.");
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletableFuture<Boolean> ff = new CompletableFuture<>();
|
done.set(true);
|
||||||
|
|
||||||
|
if(sender.isPlayer())
|
||||||
|
{
|
||||||
|
J.s(() -> {
|
||||||
|
sender.player().teleport(new Location(world.get(), 0, world.get().getHighestBlockYAt(0, 0), 0));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if(studio)
|
||||||
|
{
|
||||||
|
J.s(() -> {
|
||||||
|
Iris.linkMultiverseCore.removeFromConfig(world.get());
|
||||||
|
|
||||||
|
if (IrisSettings.get().getStudio().isDisableTimeAndWeather()) {
|
||||||
|
world.get().setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
||||||
|
world.get().setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
|
||||||
|
world.get().setTime(6000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (pregen != null) {
|
if (pregen != null) {
|
||||||
|
CompletableFuture<Boolean> ff = new CompletableFuture<>();
|
||||||
|
|
||||||
IrisToolbelt.pregenerate(pregen, access)
|
IrisToolbelt.pregenerate(pregen, access)
|
||||||
.onProgress(prog)
|
.onProgress(pp::set)
|
||||||
.whenDone(() -> ff.complete(true));
|
.whenDone(() -> ff.complete(true));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
AtomicBoolean dx = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
J.a(() -> {
|
||||||
|
while(!dx.get())
|
||||||
|
{
|
||||||
|
if (sender.isPlayer()) {
|
||||||
|
sender.sendProgress(pp.get(), "Pregenerating");
|
||||||
|
J.sleep(16);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(C.WHITE + "Pregenerating " + Form.pc(pp.get()));
|
||||||
|
J.sleep(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ff.get();
|
ff.get();
|
||||||
|
dx.set(true);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
return world.get();
|
||||||
|
|
||||||
PlatformChunkGenerator finalAccess = access;
|
|
||||||
J.sfut(() -> {
|
|
||||||
if (headless) {
|
|
||||||
O<Boolean> done = new O<>();
|
|
||||||
done.set(false);
|
|
||||||
|
|
||||||
J.a(() ->
|
|
||||||
{
|
|
||||||
int req = 400;
|
|
||||||
|
|
||||||
while (finalAccess.getEngine().getGenerated() < req && !done.get()) {
|
|
||||||
double v = (double) finalAccess.getEngine().getGenerated() / (double) req;
|
|
||||||
v = (v / 2) + 0.5;
|
|
||||||
|
|
||||||
if (sender.isPlayer()) {
|
|
||||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess.getEngine().getGenerated()) + " Left)"))));
|
|
||||||
J.sleep(50);
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess.getEngine().getGenerated()) + " Left)")));
|
|
||||||
J.sleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generation Complete"));
|
|
||||||
});
|
|
||||||
|
|
||||||
((HeadlessGenerator) finalAccess).getWorld().load();
|
|
||||||
done.set(true);
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return access;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,12 @@ public class EngineProvider {
|
|||||||
engine.set(MultiBurst.burst.completeValue(() -> {
|
engine.set(MultiBurst.burst.completeValue(() -> {
|
||||||
IrisData data = new IrisData(dataLocation);
|
IrisData data = new IrisData(dataLocation);
|
||||||
IrisDimension realDimension = data.getDimensionLoader().load(dimension);
|
IrisDimension realDimension = data.getDimensionLoader().load(dimension);
|
||||||
|
|
||||||
|
if(realDimension == null)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Cannot find dimension in " + data.getDataFolder().getAbsolutePath() + " with key " + dimension);
|
||||||
|
}
|
||||||
|
|
||||||
EngineTarget target = new EngineTarget(world, realDimension, data);
|
EngineTarget target = new EngineTarget(world, realDimension, data);
|
||||||
Engine engine = new IrisEngine(target, studio);
|
Engine engine = new IrisEngine(target, studio);
|
||||||
post.accept(engine);
|
post.accept(engine);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user