mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
Cleanup Code
This commit is contained in:
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
For 1.16 and below, see the 1.14-1.16 branch. The master branch is for the latest version of minecraft.
|
For 1.16 and below, see the 1.14-1.16 branch. The master branch is for the latest version of minecraft.
|
||||||
|
|
||||||
# [Support](https://discord.gg/3xxPTpT) **|** [Documentation](https://docs.volmit.com/iris/) **|** [Git](https://github.com/IrisDimensions)
|
# [Support](https://discord.gg/3xxPTpT) **|** [Documentation](https://docs.volmit.com/iris/) **
|
||||||
|
|** [Git](https://github.com/IrisDimensions)
|
||||||
|
|
||||||
## Iris Toolbelt
|
## Iris Toolbelt
|
||||||
Everyone needs a toolbelt.
|
|
||||||
|
Everyone needs a toolbelt.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
package com.volmit.iris.core.tools
|
package com.volmit.iris.core.tools
|
||||||
|
|||||||
@@ -56,10 +56,8 @@ public class IrisSettings {
|
|||||||
return getParallax().getParallaxRegionEvictionMS();
|
return getParallax().getParallaxRegionEvictionMS();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getThreadCount(int c)
|
public static int getThreadCount(int c) {
|
||||||
{
|
if (c < 2 && c >= 0) {
|
||||||
if(c < 2 && c >= 0)
|
|
||||||
{
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class CommandIrisPregen extends MortarCommand {
|
|||||||
IrisToolbelt.pregenerate(PregenTask
|
IrisToolbelt.pregenerate(PregenTask
|
||||||
.builder()
|
.builder()
|
||||||
.center(new Position2(0, 0))
|
.center(new Position2(0, 0))
|
||||||
.radius(((getVal(args[0])>>4)>>5) + 1)
|
.radius(((getVal(args[0]) >> 4) >> 5) + 1)
|
||||||
.build(), world);
|
.build(), world);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
@@ -142,7 +142,7 @@ public class CommandIrisPregen extends MortarCommand {
|
|||||||
new PregeneratorJob(PregenTask
|
new PregeneratorJob(PregenTask
|
||||||
.builder()
|
.builder()
|
||||||
.center(new Position2(0, 0))
|
.center(new Position2(0, 0))
|
||||||
.radius(((getVal(args[0])>>4)>>5) + 1)
|
.radius(((getVal(args[0]) >> 4) >> 5) + 1)
|
||||||
.build(),
|
.build(),
|
||||||
new HybridPregenMethod(world, Runtime.getRuntime().availableProcessors()));
|
new HybridPregenMethod(world, Runtime.getRuntime().availableProcessors()));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
private Position2 min;
|
private Position2 min;
|
||||||
private Position2 max;
|
private Position2 max;
|
||||||
|
|
||||||
public PregeneratorJob(PregenTask task, PregeneratorMethod method)
|
public PregeneratorJob(PregenTask task, PregeneratorMethod method) {
|
||||||
{
|
|
||||||
instance = this;
|
instance = this;
|
||||||
saving = false;
|
saving = false;
|
||||||
info = new String[]{"Initializing..."};
|
info = new String[]{"Initializing..."};
|
||||||
@@ -67,36 +66,32 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
max = new Position2(0, 0);
|
max = new Position2(0, 0);
|
||||||
min = new Position2(0, 0);
|
min = new Position2(0, 0);
|
||||||
KList<Runnable> draw = new KList<>();
|
KList<Runnable> draw = new KList<>();
|
||||||
task.iterateRegions((xx,zz) -> {
|
task.iterateRegions((xx, zz) -> {
|
||||||
min.setX(Math.min(xx << 5, min.getX()));
|
min.setX(Math.min(xx << 5, min.getX()));
|
||||||
min.setZ(Math.min(zz << 5, min.getZ()));
|
min.setZ(Math.min(zz << 5, min.getZ()));
|
||||||
max.setX(Math.max((xx << 5) + 31, max.getX()));
|
max.setX(Math.max((xx << 5) + 31, max.getX()));
|
||||||
max.setZ(Math.max((zz << 5) + 31, max.getZ()));
|
max.setZ(Math.max((zz << 5) + 31, max.getZ()));
|
||||||
});
|
});
|
||||||
|
|
||||||
if(IrisSettings.get().getGui().isUseServerLaunchedGuis())
|
if (IrisSettings.get().getGui().isUseServerLaunchedGuis()) {
|
||||||
{
|
|
||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
|
|
||||||
J.a(this.pregenerator::start, 20);
|
J.a(this.pregenerator::start, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PregeneratorJob onProgress(Consumer<Double> c)
|
public PregeneratorJob onProgress(Consumer<Double> c) {
|
||||||
{
|
|
||||||
onProgress.add(c);
|
onProgress.add(c);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PregeneratorJob whenDone(Runnable r)
|
public PregeneratorJob whenDone(Runnable r) {
|
||||||
{
|
|
||||||
whenDone.add(r);
|
whenDone.add(r);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shutdownInstance() {
|
public static boolean shutdownInstance() {
|
||||||
if(instance == null)
|
if (instance == null) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,59 +104,45 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void pauseResume() {
|
public static void pauseResume() {
|
||||||
if(instance == null)
|
if (instance == null) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isPaused())
|
if (isPaused()) {
|
||||||
{
|
|
||||||
instance.pregenerator.resume();
|
instance.pregenerator.resume();
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
instance.pregenerator.pause();
|
instance.pregenerator.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPaused() {
|
public static boolean isPaused() {
|
||||||
if(instance == null)
|
if (instance == null) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance.paused();
|
return instance.paused();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawRegion(int x, int z, Color color)
|
public void drawRegion(int x, int z, Color color) {
|
||||||
{
|
|
||||||
J.a(() -> {
|
J.a(() -> {
|
||||||
PregenTask.iterateRegion(x, z, (xx,zz)->{
|
PregenTask.iterateRegion(x, z, (xx, zz) -> {
|
||||||
draw(xx,zz,color);
|
draw(xx, zz, color);
|
||||||
J.sleep(3);
|
J.sleep(3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(int x, int z, Color color)
|
public void draw(int x, int z, Color color) {
|
||||||
{
|
try {
|
||||||
try
|
if (renderer != null && frame != null && frame.isVisible()) {
|
||||||
{
|
|
||||||
if(renderer != null && frame != null && frame.isVisible())
|
|
||||||
{
|
|
||||||
renderer.func.accept(new Position2(x, z), color);
|
renderer.func.accept(new Position2(x, z), color);
|
||||||
}
|
}
|
||||||
}
|
} catch (Throwable ignored) {
|
||||||
|
|
||||||
catch(Throwable ignored)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop()
|
public void stop() {
|
||||||
{
|
|
||||||
J.a(() -> {
|
J.a(() -> {
|
||||||
pregenerator.close();
|
pregenerator.close();
|
||||||
close();
|
close();
|
||||||
@@ -169,27 +150,20 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close()
|
public void close() {
|
||||||
{
|
|
||||||
J.a(() -> {
|
J.a(() -> {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
J.sleep(3000);
|
J.sleep(3000);
|
||||||
frame.setVisible(false);
|
frame.setVisible(false);
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void open()
|
public void open() {
|
||||||
{
|
|
||||||
J.a(() -> {
|
J.a(() -> {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
frame = new JFrame("Pregen View");
|
frame = new JFrame("Pregen View");
|
||||||
renderer = new PregenRenderer();
|
renderer = new PregenRenderer();
|
||||||
frame.addKeyListener(renderer);
|
frame.addKeyListener(renderer);
|
||||||
@@ -205,10 +179,7 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
frame.add(renderer);
|
frame.add(renderer);
|
||||||
frame.setSize(1000, 1000);
|
frame.setSize(1000, 1000);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -216,15 +187,14 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick(double chunksPerSecond, double chunksPerMinute, double regionsPerMinute, double percent, int generated, int totalChunks, int chunksRemaining, long eta, long elapsed, String method) {
|
public void onTick(double chunksPerSecond, double chunksPerMinute, double regionsPerMinute, double percent, int generated, int totalChunks, int chunksRemaining, long eta, long elapsed, String method) {
|
||||||
info = new String[] {
|
info = new String[]{
|
||||||
(paused() ? "PAUSED" : (saving ? "Saving... " : "Generating")) + " " + Form.f(generated) + " of " + Form.f(totalChunks) + " (" + Form.pc(percent, 0) + " Complete)",
|
(paused() ? "PAUSED" : (saving ? "Saving... " : "Generating")) + " " + Form.f(generated) + " of " + Form.f(totalChunks) + " (" + Form.pc(percent, 0) + " Complete)",
|
||||||
"Speed: " + Form.f(chunksPerSecond, 0) + " Chunks/s, " + Form.f(regionsPerMinute, 1) + " Regions/m, " + Form.f(chunksPerMinute, 0) + " Chunks/m",
|
"Speed: " + Form.f(chunksPerSecond, 0) + " Chunks/s, " + Form.f(regionsPerMinute, 1) + " Regions/m, " + Form.f(chunksPerMinute, 0) + " Chunks/m",
|
||||||
Form.duration(eta, 2) + " Remaining " + " (" + Form.duration(elapsed, 2) + " Elapsed)",
|
Form.duration(eta, 2) + " Remaining " + " (" + Form.duration(elapsed, 2) + " Elapsed)",
|
||||||
"Generation Method: " + method,
|
"Generation Method: " + method,
|
||||||
};
|
};
|
||||||
|
|
||||||
for(Consumer<Double> i : onProgress)
|
for (Consumer<Double> i : onProgress) {
|
||||||
{
|
|
||||||
i.accept(percent);
|
i.accept(percent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,7 +275,7 @@ public class PregeneratorJob implements PregenListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean paused() {
|
private boolean paused() {
|
||||||
return pregenerator.paused();
|
return pregenerator.paused();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getProgress() {
|
private String[] getProgress() {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.core.gui.components;
|
package com.volmit.iris.core.gui.components;
|
||||||
|
|
||||||
import com.volmit.iris.core.gui.components.RenderType;
|
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.core.pregenerator;
|
package com.volmit.iris.core.pregenerator;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
@@ -54,8 +52,7 @@ public class IrisPregenerator {
|
|||||||
private final KSet<Position2> retry;
|
private final KSet<Position2> retry;
|
||||||
private final KSet<Position2> net;
|
private final KSet<Position2> net;
|
||||||
|
|
||||||
public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener)
|
public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener) {
|
||||||
{
|
|
||||||
this.listener = listenify(listener);
|
this.listener = listenify(listener);
|
||||||
generatedRegions = new KSet<>();
|
generatedRegions = new KSet<>();
|
||||||
this.shutdown = new AtomicBoolean(false);
|
this.shutdown = new AtomicBoolean(false);
|
||||||
@@ -83,17 +80,16 @@ public class IrisPregenerator {
|
|||||||
generatedLast.set(generated.get());
|
generatedLast.set(generated.get());
|
||||||
chunksPerSecond.put(secondGenerated);
|
chunksPerSecond.put(secondGenerated);
|
||||||
|
|
||||||
if(minuteLatch.flip())
|
if (minuteLatch.flip()) {
|
||||||
{
|
|
||||||
int minuteGenerated = generated.get() - generatedLastMinute.get();
|
int minuteGenerated = generated.get() - generatedLastMinute.get();
|
||||||
generatedLastMinute.set(generated.get());
|
generatedLastMinute.set(generated.get());
|
||||||
chunksPerMinute.put(minuteGenerated);
|
chunksPerMinute.put(minuteGenerated);
|
||||||
regionsPerMinute.put((double)minuteGenerated / 1024D);
|
regionsPerMinute.put((double) minuteGenerated / 1024D);
|
||||||
}
|
}
|
||||||
|
|
||||||
listener.onTick(chunksPerSecond.getAverage(), chunksPerMinute.getAverage(),
|
listener.onTick(chunksPerSecond.getAverage(), chunksPerMinute.getAverage(),
|
||||||
regionsPerMinute.getAverage(),
|
regionsPerMinute.getAverage(),
|
||||||
(double)generated.get() / (double)totalChunks.get(),
|
(double) generated.get() / (double) totalChunks.get(),
|
||||||
generated.get(), totalChunks.get(),
|
generated.get(), totalChunks.get(),
|
||||||
totalChunks.get() - generated.get(),
|
totalChunks.get() - generated.get(),
|
||||||
eta, M.ms() - startTime.get(), currentGeneratorMethod.get());
|
eta, M.ms() - startTime.get(), currentGeneratorMethod.get());
|
||||||
@@ -108,18 +104,16 @@ public class IrisPregenerator {
|
|||||||
((double) (M.ms() - startTime.get()) / (double) generated.get()));
|
((double) (M.ms() - startTime.get()) / (double) generated.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close()
|
public void close() {
|
||||||
{
|
|
||||||
shutdown.set(true);
|
shutdown.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start()
|
public void start() {
|
||||||
{
|
|
||||||
init();
|
init();
|
||||||
ticker.start();
|
ticker.start();
|
||||||
checkRegions();
|
checkRegions();
|
||||||
task.iterateRegions((x,z) -> visitRegion(x, z, true));
|
task.iterateRegions((x, z) -> visitRegion(x, z, true));
|
||||||
task.iterateRegions((x,z) -> visitRegion(x, z, false));
|
task.iterateRegions((x, z) -> visitRegion(x, z, false));
|
||||||
shutdown();
|
shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,42 +134,34 @@ public class IrisPregenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void visitRegion(int x, int z, boolean regions) {
|
private void visitRegion(int x, int z, boolean regions) {
|
||||||
while(paused.get() && !shutdown.get())
|
while (paused.get() && !shutdown.get()) {
|
||||||
{
|
|
||||||
J.sleep(50);
|
J.sleep(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(shutdown.get())
|
if (shutdown.get()) {
|
||||||
{
|
|
||||||
listener.onRegionSkipped(x, z);
|
listener.onRegionSkipped(x, z);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position2 pos = new Position2(x, z);
|
Position2 pos = new Position2(x, z);
|
||||||
|
|
||||||
if(generatedRegions.contains(pos))
|
if (generatedRegions.contains(pos)) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentGeneratorMethod.set(generator.getMethod(x, z));
|
currentGeneratorMethod.set(generator.getMethod(x, z));
|
||||||
boolean hit = false;
|
boolean hit = false;
|
||||||
if(generator.supportsRegions(x, z, listener) && regions)
|
if (generator.supportsRegions(x, z, listener) && regions) {
|
||||||
{
|
|
||||||
hit = true;
|
hit = true;
|
||||||
listener.onRegionGenerating(x, z);
|
listener.onRegionGenerating(x, z);
|
||||||
generator.generateRegion(x, z, listener);
|
generator.generateRegion(x, z, listener);
|
||||||
}
|
} else if (!regions) {
|
||||||
|
|
||||||
else if(!regions)
|
|
||||||
{
|
|
||||||
hit = true;
|
hit = true;
|
||||||
listener.onRegionGenerating(x, z);
|
listener.onRegionGenerating(x, z);
|
||||||
PregenTask.iterateRegion(x, z, (xx, zz) -> generator.generateChunk(xx, zz, listener));
|
PregenTask.iterateRegion(x, z, (xx, zz) -> generator.generateChunk(xx, zz, listener));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hit)
|
if (hit) {
|
||||||
{
|
|
||||||
listener.onRegionGenerated(x, z);
|
listener.onRegionGenerated(x, z);
|
||||||
listener.onSaving();
|
listener.onSaving();
|
||||||
generator.save();
|
generator.save();
|
||||||
@@ -185,21 +171,18 @@ public class IrisPregenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkRegion(int x, int z) {
|
private void checkRegion(int x, int z) {
|
||||||
if(generatedRegions.contains(new Position2(x, z)))
|
if (generatedRegions.contains(new Position2(x, z))) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
generator.supportsRegions(x, z, listener);
|
generator.supportsRegions(x, z, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause()
|
public void pause() {
|
||||||
{
|
|
||||||
paused.set(true);
|
paused.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resume()
|
public void resume() {
|
||||||
{
|
|
||||||
paused.set(false);
|
paused.set(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +190,7 @@ public class IrisPregenerator {
|
|||||||
return new PregenListener() {
|
return new PregenListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(double chunksPerSecond, double chunksPerMinute, double regionsPerMinute, double percent, int generated, int totalChunks, int chunksRemaining, long eta, long elapsed, String method) {
|
public void onTick(double chunksPerSecond, double chunksPerMinute, double regionsPerMinute, double percent, int generated, int totalChunks, int chunksRemaining, long eta, long elapsed, String method) {
|
||||||
listener.onTick( chunksPerSecond, chunksPerMinute, regionsPerMinute, percent, generated, totalChunks, chunksRemaining, eta, elapsed, method);
|
listener.onTick(chunksPerSecond, chunksPerMinute, regionsPerMinute, percent, generated, totalChunks, chunksRemaining, eta, elapsed, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -31,29 +31,25 @@ import java.util.Comparator;
|
|||||||
@Data
|
@Data
|
||||||
public class PregenTask {
|
public class PregenTask {
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private Position2 center = new Position2(0,0);
|
private Position2 center = new Position2(0, 0);
|
||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private int radius = 1;
|
private int radius = 1;
|
||||||
|
|
||||||
private static final KList<Position2> order = computeChunkOrder();
|
private static final KList<Position2> order = computeChunkOrder();
|
||||||
|
|
||||||
public void iterateRegions(Spiraled s)
|
public void iterateRegions(Spiraled s) {
|
||||||
{
|
|
||||||
new Spiraler(radius * 2, radius * 2, s)
|
new Spiraler(radius * 2, radius * 2, s)
|
||||||
.setOffset(center.getX(), center.getZ()).drain();
|
.setOffset(center.getX(), center.getZ()).drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void iterateRegion(int xr, int zr, Spiraled s)
|
public static void iterateRegion(int xr, int zr, Spiraled s) {
|
||||||
{
|
for (Position2 i : order) {
|
||||||
for(Position2 i : order)
|
|
||||||
{
|
|
||||||
s.on(i.getX() + (xr << 5), i.getZ() + (zr << 5));
|
s.on(i.getX() + (xr << 5), i.getZ() + (zr << 5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void iterateAllChunks(Spiraled s)
|
public void iterateAllChunks(Spiraled s) {
|
||||||
{
|
|
||||||
new Spiraler(radius * 2, radius * 2, (x, z) -> iterateRegion(x, z, s))
|
new Spiraler(radius * 2, radius * 2, (x, z) -> iterateRegion(x, z, s))
|
||||||
.setOffset(center.getX(), center.getZ()).drain();
|
.setOffset(center.getX(), center.getZ()).drain();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,33 +40,37 @@ public interface PregeneratorMethod {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if regions can be generated
|
* Return true if regions can be generated
|
||||||
* @return true if they can be
|
*
|
||||||
* @param x the x region
|
* @param x the x region
|
||||||
* @param z the z region
|
* @param z the z region
|
||||||
|
* @return true if they can be
|
||||||
*/
|
*/
|
||||||
boolean supportsRegions(int x, int z, PregenListener listener);
|
boolean supportsRegions(int x, int z, PregenListener listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the method being used
|
* Return the name of the method being used
|
||||||
* @return the name
|
*
|
||||||
* @param x the x region
|
* @param x the x region
|
||||||
* @param z the z region
|
* @param z the z region
|
||||||
|
* @return the name
|
||||||
*/
|
*/
|
||||||
String getMethod(int x, int z);
|
String getMethod(int x, int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to generate a region. Execute sync, if multicore internally, wait
|
* Called to generate a region. Execute sync, if multicore internally, wait
|
||||||
* for the task to complete
|
* for the task to complete
|
||||||
* @param x the x
|
*
|
||||||
* @param z the z
|
* @param x the x
|
||||||
|
* @param z the z
|
||||||
* @param listener signal chunks generating & generated. Parallel capable.
|
* @param listener signal chunks generating & generated. Parallel capable.
|
||||||
*/
|
*/
|
||||||
void generateRegion(int x, int z, PregenListener listener);
|
void generateRegion(int x, int z, PregenListener listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to generate a chunk. You can go async so long as save will wait on the threads to finish
|
* Called to generate a chunk. You can go async so long as save will wait on the threads to finish
|
||||||
* @param x the x
|
*
|
||||||
* @param z the z
|
* @param x the x
|
||||||
|
* @param z the z
|
||||||
* @param listener
|
* @param listener
|
||||||
*/
|
*/
|
||||||
void generateChunk(int x, int z, PregenListener listener);
|
void generateChunk(int x, int z, PregenListener listener);
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ import org.bukkit.World;
|
|||||||
public class AsyncOrMedievalPregenMethod implements PregeneratorMethod {
|
public class AsyncOrMedievalPregenMethod implements PregeneratorMethod {
|
||||||
private final PregeneratorMethod method;
|
private final PregeneratorMethod method;
|
||||||
|
|
||||||
public AsyncOrMedievalPregenMethod(World world, int threads)
|
public AsyncOrMedievalPregenMethod(World world, int threads) {
|
||||||
{
|
|
||||||
method = PaperLib.isPaper() ? new AsyncPregenMethod(world, threads) : new MedievalPregenMethod(world);
|
method = PaperLib.isPaper() ? new AsyncPregenMethod(world, threads) : new MedievalPregenMethod(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,17 +29,14 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
public class AsyncPregenMethod implements PregeneratorMethod {
|
public class AsyncPregenMethod implements PregeneratorMethod {
|
||||||
private final World world;
|
private final World world;
|
||||||
private final MultiBurst burst;
|
private final MultiBurst burst;
|
||||||
private final KList<CompletableFuture<?>> future;
|
private final KList<CompletableFuture<?>> future;
|
||||||
|
|
||||||
public AsyncPregenMethod(World world, int threads)
|
public AsyncPregenMethod(World world, int threads) {
|
||||||
{
|
if (!PaperLib.isPaper()) {
|
||||||
if(!PaperLib.isPaper())
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Cannot use PaperAsync on non paper!");
|
throw new UnsupportedOperationException("Cannot use PaperAsync on non paper!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,8 +48,7 @@ public class AsyncPregenMethod implements PregeneratorMethod {
|
|||||||
private void unloadAndSaveAllChunks() {
|
private void unloadAndSaveAllChunks() {
|
||||||
try {
|
try {
|
||||||
J.sfut(() -> {
|
J.sfut(() -> {
|
||||||
for(Chunk i : world.getLoadedChunks())
|
for (Chunk i : world.getLoadedChunks()) {
|
||||||
{
|
|
||||||
i.unload(true);
|
i.unload(true);
|
||||||
}
|
}
|
||||||
world.save();
|
world.save();
|
||||||
@@ -71,10 +67,8 @@ public class AsyncPregenMethod implements PregeneratorMethod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForChunks()
|
private void waitForChunks() {
|
||||||
{
|
for (CompletableFuture<?> i : future) {
|
||||||
for(CompletableFuture<?> i : future)
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
i.get();
|
i.get();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@@ -120,8 +114,7 @@ public class AsyncPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateChunk(int x, int z, PregenListener listener) {
|
public void generateChunk(int x, int z, PregenListener listener) {
|
||||||
if(future.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getPregenThreadCount()))
|
if (future.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getPregenThreadCount())) {
|
||||||
{
|
|
||||||
waitForChunks();
|
waitForChunks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,13 +30,11 @@ public class HeadlessPregenMethod implements PregeneratorMethod {
|
|||||||
@Getter
|
@Getter
|
||||||
private final HeadlessGenerator generator;
|
private final HeadlessGenerator generator;
|
||||||
|
|
||||||
public HeadlessPregenMethod(HeadlessWorld world)
|
public HeadlessPregenMethod(HeadlessWorld world) {
|
||||||
{
|
|
||||||
this(world, world.generate());
|
this(world, world.generate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeadlessPregenMethod(HeadlessWorld world, HeadlessGenerator generator)
|
public HeadlessPregenMethod(HeadlessWorld world, HeadlessGenerator generator) {
|
||||||
{
|
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ public class HybridPregenMethod implements PregeneratorMethod {
|
|||||||
private final PregeneratorMethod inWorld;
|
private final PregeneratorMethod inWorld;
|
||||||
private final World world;
|
private final World world;
|
||||||
|
|
||||||
public HybridPregenMethod(World world, int threads)
|
public HybridPregenMethod(World world, int threads) {
|
||||||
{
|
|
||||||
this.world = world;
|
this.world = world;
|
||||||
headless = supportsHeadless(world)
|
headless = supportsHeadless(world)
|
||||||
? new HeadlessPregenMethod(HeadlessWorld.from(world)) : new DummyPregenMethod();
|
? new HeadlessPregenMethod(HeadlessWorld.from(world)) : new DummyPregenMethod();
|
||||||
@@ -76,18 +75,12 @@ public class HybridPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
boolean r = !new File(world.getWorldFolder(), "region/r." + x + "." + z + ".mca").exists();
|
boolean r = !new File(world.getWorldFolder(), "region/r." + x + "." + z + ".mca").exists();
|
||||||
|
|
||||||
if(!r && listener != null)
|
if (!r && listener != null) {
|
||||||
{
|
try {
|
||||||
try
|
for (Position2 i : ((HeadlessPregenMethod) headless).getGenerator().getChunksInRegion(x, z)) {
|
||||||
{
|
|
||||||
for(Position2 i : ((HeadlessPregenMethod) headless).getGenerator().getChunksInRegion(x, z))
|
|
||||||
{
|
|
||||||
listener.onChunkExistsInRegionGen((x << 5) + i.getX(), (z << 5) + i.getZ());
|
listener.onChunkExistsInRegionGen((x << 5) + i.getX(), (z << 5) + i.getZ());
|
||||||
}
|
}
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,16 +32,13 @@ public class MedievalPregenMethod implements PregeneratorMethod {
|
|||||||
private final World world;
|
private final World world;
|
||||||
private final KList<CompletableFuture<?>> futures;
|
private final KList<CompletableFuture<?>> futures;
|
||||||
|
|
||||||
public MedievalPregenMethod(World world)
|
public MedievalPregenMethod(World world) {
|
||||||
{
|
|
||||||
this.world = world;
|
this.world = world;
|
||||||
futures = new KList<>();
|
futures = new KList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForChunks()
|
private void waitForChunks() {
|
||||||
{
|
for (CompletableFuture<?> i : futures) {
|
||||||
for(CompletableFuture<?> i : futures)
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
i.get();
|
i.get();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@@ -56,8 +53,7 @@ public class MedievalPregenMethod implements PregeneratorMethod {
|
|||||||
waitForChunks();
|
waitForChunks();
|
||||||
try {
|
try {
|
||||||
J.sfut(() -> {
|
J.sfut(() -> {
|
||||||
for(Chunk i : world.getLoadedChunks())
|
for (Chunk i : world.getLoadedChunks()) {
|
||||||
{
|
|
||||||
i.unload(true);
|
i.unload(true);
|
||||||
}
|
}
|
||||||
world.save();
|
world.save();
|
||||||
@@ -99,8 +95,7 @@ public class MedievalPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateChunk(int x, int z, PregenListener listener) {
|
public void generateChunk(int x, int z, PregenListener listener) {
|
||||||
if(futures.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getPregenThreadCount()))
|
if (futures.size() > IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getPregenThreadCount())) {
|
||||||
{
|
|
||||||
waitForChunks();
|
waitForChunks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ import java.io.IOException;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class SyndicatePregenMethod implements PregeneratorMethod
|
public class SyndicatePregenMethod implements PregeneratorMethod {
|
||||||
{
|
|
||||||
@Getter
|
@Getter
|
||||||
private String address;
|
private String address;
|
||||||
private String nickname;
|
private String nickname;
|
||||||
@@ -49,8 +48,7 @@ public class SyndicatePregenMethod implements PregeneratorMethod
|
|||||||
private UUID pack = UUID.randomUUID();
|
private UUID pack = UUID.randomUUID();
|
||||||
private long seed;
|
private long seed;
|
||||||
|
|
||||||
public SyndicatePregenMethod(String nickname, File worldFolder, String address, int port, String password, IrisDimension dimension, long seed)
|
public SyndicatePregenMethod(String nickname, File worldFolder, String address, int port, String password, IrisDimension dimension, long seed) {
|
||||||
{
|
|
||||||
this.seed = seed;
|
this.seed = seed;
|
||||||
this.worldFolder = worldFolder;
|
this.worldFolder = worldFolder;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
@@ -59,50 +57,45 @@ public class SyndicatePregenMethod implements PregeneratorMethod
|
|||||||
this.dimension = dimension;
|
this.dimension = dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SyndicateClient.SyndicateClientBuilder connect()
|
private SyndicateClient.SyndicateClientBuilder connect() {
|
||||||
{
|
|
||||||
return SyndicateClient.builder().address(address).port(port);
|
return SyndicateClient.builder().address(address).port(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setup()
|
public synchronized void setup() {
|
||||||
{
|
if (ready) {
|
||||||
if(ready)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ready = false;
|
ready = false;
|
||||||
try {
|
try {
|
||||||
connect().command(SyndicateInstallPack
|
connect().command(SyndicateInstallPack
|
||||||
.builder()
|
.builder()
|
||||||
.dimension(dimension)
|
.dimension(dimension)
|
||||||
.pack(pack)
|
.pack(pack)
|
||||||
.seed(seed)
|
.seed(seed)
|
||||||
.build())
|
.build())
|
||||||
.output((o) -> {
|
.output((o) -> {
|
||||||
File to = new File(Iris.getTemp(), "send-" + pack.toString() + ".zip");
|
File to = new File(Iris.getTemp(), "send-" + pack.toString() + ".zip");
|
||||||
ZipUtil.pack(dimension.getLoader().getDataFolder(), to);
|
ZipUtil.pack(dimension.getLoader().getDataFolder(), to);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IO.writeAll(to, o);
|
IO.writeAll(to, o);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
to.deleteOnExit();
|
to.deleteOnExit();
|
||||||
})
|
})
|
||||||
.build().go((response, data) -> {
|
.build().go((response, data) -> {
|
||||||
if(response instanceof SyndicateBusy)
|
if (response instanceof SyndicateBusy) {
|
||||||
{
|
throw new RuntimeException("Service is busy, will try later");
|
||||||
throw new RuntimeException("Service is busy, will try later");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ready = true;
|
ready = true;
|
||||||
});
|
});
|
||||||
ready = true;
|
ready = true;
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if(throwable instanceof RuntimeException)
|
if (throwable instanceof RuntimeException) {
|
||||||
{
|
|
||||||
ready = false;
|
ready = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -111,10 +104,8 @@ public class SyndicatePregenMethod implements PregeneratorMethod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canGenerate()
|
public boolean canGenerate() {
|
||||||
{
|
if (!ready) {
|
||||||
if(!ready)
|
|
||||||
{
|
|
||||||
J.a(this::setup);
|
J.a(this::setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,16 +119,16 @@ public class SyndicatePregenMethod implements PregeneratorMethod
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
if(ready)
|
if (ready) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
connect()
|
connect()
|
||||||
.command(SyndicateClose
|
.command(SyndicateClose
|
||||||
.builder()
|
.builder()
|
||||||
.pack(pack)
|
.pack(pack)
|
||||||
.build())
|
.build())
|
||||||
.build()
|
.build()
|
||||||
.go((__, __b) -> {});
|
.go((__, __b) -> {
|
||||||
|
});
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -159,29 +150,26 @@ public class SyndicatePregenMethod implements PregeneratorMethod
|
|||||||
return "Syndicate<" + nickname + ">";
|
return "Syndicate<" + nickname + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
private double checkProgress(int x, int z)
|
private double checkProgress(int x, int z) {
|
||||||
{
|
|
||||||
AtomicDouble progress = new AtomicDouble(-1);
|
AtomicDouble progress = new AtomicDouble(-1);
|
||||||
try {
|
try {
|
||||||
connect()
|
connect()
|
||||||
.command(SyndicateGetProgress.builder()
|
.command(SyndicateGetProgress.builder()
|
||||||
.pack(pack).build()).output((i) -> {
|
.pack(pack).build()).output((i) -> {
|
||||||
}).build().go((response, o) -> {
|
}).build().go((response, o) -> {
|
||||||
if(response instanceof SyndicateSendProgress)
|
if (response instanceof SyndicateSendProgress) {
|
||||||
{
|
if (((SyndicateSendProgress) response).isAvailable()) {
|
||||||
if(((SyndicateSendProgress) response).isAvailable())
|
progress.set(((SyndicateSendProgress) response).getProgress());
|
||||||
{
|
File f = new File(worldFolder, "region/r." + x + "." + z + ".mca");
|
||||||
progress.set(((SyndicateSendProgress) response).getProgress());
|
try {
|
||||||
File f = new File(worldFolder, "region/r." + x + "." + z + ".mca");
|
f.getParentFile().mkdirs();
|
||||||
try {
|
IO.writeAll(f, o);
|
||||||
f.getParentFile().mkdirs();
|
progress.set(1000);
|
||||||
IO.writeAll(f, o);
|
} catch (Throwable e) {
|
||||||
progress.set(1000);
|
e.printStackTrace();
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
@@ -192,94 +180,73 @@ public class SyndicatePregenMethod implements PregeneratorMethod
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateRegion(int x, int z, PregenListener listener) {
|
public void generateRegion(int x, int z, PregenListener listener) {
|
||||||
if(!ready)
|
if (!ready) {
|
||||||
{
|
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
connect().command(SyndicateGenerate
|
connect().command(SyndicateGenerate
|
||||||
.builder()
|
.builder()
|
||||||
.x(x).z(z).pack(pack)
|
.x(x).z(z).pack(pack)
|
||||||
.build())
|
.build())
|
||||||
.build().go((response, data) -> {
|
.build().go((response, data) -> {
|
||||||
if(response instanceof SyndicateOK)
|
if (response instanceof SyndicateOK) {
|
||||||
{
|
listener.onNetworkStarted(x, z);
|
||||||
listener.onNetworkStarted(x, z);
|
J.a(() -> {
|
||||||
J.a(() -> {
|
double lastp = 0;
|
||||||
double lastp = 0;
|
int calls = 0;
|
||||||
int calls = 0;
|
boolean installed = false;
|
||||||
boolean installed = false;
|
while (true) {
|
||||||
while(true)
|
J.sleep(100);
|
||||||
{
|
double progress = checkProgress(x, z);
|
||||||
J.sleep(100);
|
|
||||||
double progress = checkProgress(x, z);
|
|
||||||
|
|
||||||
if(progress == 1000)
|
|
||||||
{
|
|
||||||
installed = true;
|
|
||||||
AtomicInteger a = new AtomicInteger(calls);
|
|
||||||
PregenTask.iterateRegion(x, z, (xx, zz) -> {
|
|
||||||
if(a.decrementAndGet() < 0)
|
|
||||||
{
|
|
||||||
listener.onNetworkGeneratedChunk(xx, zz);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
calls = 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if(progress < 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int change = (int) Math.floor((progress - lastp) * 1024D);
|
|
||||||
change = change == 0 ? 1 : change;
|
|
||||||
|
|
||||||
|
if (progress == 1000) {
|
||||||
|
installed = true;
|
||||||
AtomicInteger a = new AtomicInteger(calls);
|
AtomicInteger a = new AtomicInteger(calls);
|
||||||
AtomicInteger b = new AtomicInteger(change);
|
|
||||||
PregenTask.iterateRegion(x, z, (xx, zz) -> {
|
PregenTask.iterateRegion(x, z, (xx, zz) -> {
|
||||||
if(a.decrementAndGet() < 0)
|
if (a.decrementAndGet() < 0) {
|
||||||
{
|
listener.onNetworkGeneratedChunk(xx, zz);
|
||||||
if(b.decrementAndGet() >= 0)
|
|
||||||
{
|
|
||||||
listener.onNetworkGeneratedChunk(xx, zz);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
calls += change;
|
calls = 1024;
|
||||||
|
} else if (progress < 0) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!installed)
|
int change = (int) Math.floor((progress - lastp) * 1024D);
|
||||||
{
|
change = change == 0 ? 1 : change;
|
||||||
// TODO RETRY REGION
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
listener.onNetworkDownloaded(x, z);
|
AtomicInteger a = new AtomicInteger(calls);
|
||||||
});
|
AtomicInteger b = new AtomicInteger(change);
|
||||||
}
|
PregenTask.iterateRegion(x, z, (xx, zz) -> {
|
||||||
|
if (a.decrementAndGet() < 0) {
|
||||||
|
if (b.decrementAndGet() >= 0) {
|
||||||
|
listener.onNetworkGeneratedChunk(xx, zz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
calls += change;
|
||||||
|
}
|
||||||
|
|
||||||
else if(response instanceof SyndicateInstallFirst)
|
if (!installed) {
|
||||||
{
|
// TODO RETRY REGION
|
||||||
ready = false;
|
return;
|
||||||
throw new RuntimeException();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
else if(response instanceof SyndicateBusy)
|
listener.onNetworkDownloaded(x, z);
|
||||||
{
|
});
|
||||||
throw new RuntimeException();
|
} else if (response instanceof SyndicateInstallFirst) {
|
||||||
}
|
ready = false;
|
||||||
|
throw new RuntimeException();
|
||||||
else
|
} else if (response instanceof SyndicateBusy) {
|
||||||
{
|
throw new RuntimeException();
|
||||||
throw new RuntimeException();
|
} else {
|
||||||
}
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
|
|
||||||
if(throwable instanceof RuntimeException)
|
if (throwable instanceof RuntimeException) {
|
||||||
{
|
|
||||||
throw (RuntimeException) throwable;
|
throw (RuntimeException) throwable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ public class SyndicateClient {
|
|||||||
DataOutputStream o = new DataOutputStream(socket.getOutputStream());
|
DataOutputStream o = new DataOutputStream(socket.getOutputStream());
|
||||||
SyndicateCommandIO.write(command, o);
|
SyndicateCommandIO.write(command, o);
|
||||||
|
|
||||||
if(output != null)
|
if (output != null) {
|
||||||
{
|
|
||||||
output.accept(o);
|
output.accept(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,10 +56,8 @@ public class SyndicateServer extends Thread implements PregenListener {
|
|||||||
server.setSoTimeout(1000);
|
server.setSoTimeout(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
while (!interrupted()) {
|
||||||
while(!interrupted())
|
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
Socket client = server.accept();
|
Socket client = server.accept();
|
||||||
DataInputStream i = new DataInputStream(client.getInputStream());
|
DataInputStream i = new DataInputStream(client.getInputStream());
|
||||||
@@ -79,40 +77,34 @@ public class SyndicateServer extends Thread implements PregenListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handle(Socket client, DataInputStream i, DataOutputStream o) throws Throwable
|
private void handle(Socket client, DataInputStream i, DataOutputStream o) throws Throwable {
|
||||||
{
|
|
||||||
SyndicateCommand cmd = handle(SyndicateCommandIO.read(i), i, o);
|
SyndicateCommand cmd = handle(SyndicateCommandIO.read(i), i, o);
|
||||||
|
|
||||||
if(cmd != null)
|
if (cmd != null) {
|
||||||
{
|
|
||||||
SyndicateCommandIO.write(cmd, o);
|
SyndicateCommandIO.write(cmd, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
o.flush();
|
o.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getCachedDim(UUID id)
|
private File getCachedDim(UUID id) {
|
||||||
{
|
return new File(cache, id.toString().charAt(2) + "/" + id.toString().substring(0, 4) + "/" + id);
|
||||||
return new File(cache, id.toString().charAt(2) +"/" + id.toString().substring(0, 4)+ "/" + id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SyndicateCommand handle(SyndicateCommand command, DataInputStream i, DataOutputStream o) throws Throwable {
|
private SyndicateCommand handle(SyndicateCommand command, DataInputStream i, DataOutputStream o) throws Throwable {
|
||||||
if(command instanceof SyndicateInstallPack)
|
if (command instanceof SyndicateInstallPack) {
|
||||||
{
|
if (busy) {
|
||||||
if(busy)
|
|
||||||
{
|
|
||||||
return new SyndicateBusy();
|
return new SyndicateBusy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(generator != null)
|
if (generator != null) {
|
||||||
{
|
|
||||||
generator.close();
|
generator.close();
|
||||||
IO.delete(generator.getWorld().getWorld().worldFolder());
|
IO.delete(generator.getWorld().getWorld().worldFolder());
|
||||||
generator = null;
|
generator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID id = ((SyndicateInstallPack) command).getPack();
|
UUID id = ((SyndicateInstallPack) command).getPack();
|
||||||
File cacheload = new File(cache, id.toString().charAt(2) +"/" + id.toString().substring(0, 4)+ "/" + id + ".zip");
|
File cacheload = new File(cache, id.toString().charAt(2) + "/" + id.toString().substring(0, 4) + "/" + id + ".zip");
|
||||||
File cachestore = getCachedDim(id);
|
File cachestore = getCachedDim(id);
|
||||||
IO.delete(cachestore);
|
IO.delete(cachestore);
|
||||||
int len = i.readInt();
|
int len = i.readInt();
|
||||||
@@ -129,14 +121,12 @@ public class SyndicateServer extends Thread implements PregenListener {
|
|||||||
return new SyndicateOK();
|
return new SyndicateOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(command instanceof SyndicateGenerate)
|
if (command instanceof SyndicateGenerate) {
|
||||||
{
|
if (busy) {
|
||||||
if(busy)
|
|
||||||
{
|
|
||||||
return new SyndicateBusy();
|
return new SyndicateBusy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(generator == null || !Objects.equals(currentId, ((SyndicateGenerate) command).getPack())) {
|
if (generator == null || !Objects.equals(currentId, ((SyndicateGenerate) command).getPack())) {
|
||||||
return new SyndicateInstallFirst();
|
return new SyndicateInstallFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,10 +139,8 @@ public class SyndicateServer extends Thread implements PregenListener {
|
|||||||
return new SyndicateOK();
|
return new SyndicateOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(command instanceof SyndicateClose)
|
if (command instanceof SyndicateClose) {
|
||||||
{
|
if (generator != null && Objects.equals(currentId, ((SyndicateClose) command).getPack()) && !busy) {
|
||||||
if(generator != null && Objects.equals(currentId, ((SyndicateClose) command).getPack()) && !busy)
|
|
||||||
{
|
|
||||||
generator.close();
|
generator.close();
|
||||||
IO.delete(generator.getWorld().getWorld().worldFolder());
|
IO.delete(generator.getWorld().getWorld().worldFolder());
|
||||||
generator = null;
|
generator = null;
|
||||||
@@ -160,31 +148,20 @@ public class SyndicateServer extends Thread implements PregenListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(command instanceof SyndicateGetProgress)
|
if (command instanceof SyndicateGetProgress) {
|
||||||
{
|
if (generator != null && busy && Objects.equals(currentId, ((SyndicateGetProgress) command).getPack())) {
|
||||||
if(generator != null && busy && Objects.equals(currentId, ((SyndicateGetProgress) command).getPack()))
|
return SyndicateSendProgress.builder().progress((double) g.get() / 1024D).build();
|
||||||
{
|
} else if (generator != null && !busy && Objects.equals(currentId, ((SyndicateGetProgress) command).getPack()) && lastGeneratedRegion != null && lastGeneratedRegion.exists()) {
|
||||||
return SyndicateSendProgress.builder().progress((double)g.get() / 1024D).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if(generator != null && !busy && Objects.equals(currentId, ((SyndicateGetProgress) command).getPack()) && lastGeneratedRegion != null && lastGeneratedRegion.exists())
|
|
||||||
{
|
|
||||||
SyndicateCommandIO.write(SyndicateSendProgress
|
SyndicateCommandIO.write(SyndicateSendProgress
|
||||||
.builder()
|
.builder()
|
||||||
.progress(1).available(true)
|
.progress(1).available(true)
|
||||||
.build(), o);
|
.build(), o);
|
||||||
o.writeLong(lastGeneratedRegion.length());
|
o.writeLong(lastGeneratedRegion.length());
|
||||||
IO.writeAll(lastGeneratedRegion, o);
|
IO.writeAll(lastGeneratedRegion, o);
|
||||||
return null;
|
return null;
|
||||||
}
|
} else if (generator == null) {
|
||||||
|
|
||||||
else if(generator == null)
|
|
||||||
{
|
|
||||||
return new SyndicateInstallFirst();
|
return new SyndicateInstallFirst();
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new SyndicateBusy();
|
return new SyndicateBusy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.volmit.iris.core.pregenerator.syndicate.command;
|
package com.volmit.iris.core.pregenerator.syndicate.command;
|
||||||
|
|
||||||
public interface SyndicateCommand
|
public interface SyndicateCommand {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public class IrisCreator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the IrisAccess (contains the world)
|
* Create the IrisAccess (contains the world)
|
||||||
|
*
|
||||||
* @return the IrisAccess
|
* @return the IrisAccess
|
||||||
* @throws IrisException shit happens
|
* @throws IrisException shit happens
|
||||||
*/
|
*/
|
||||||
@@ -94,40 +95,29 @@ public class IrisCreator {
|
|||||||
IrisDimension d = IrisToolbelt.getDimension(dimension());
|
IrisDimension d = IrisToolbelt.getDimension(dimension());
|
||||||
IrisAccess access = null;
|
IrisAccess access = null;
|
||||||
Consumer<Double> prog = (pxx) -> {
|
Consumer<Double> prog = (pxx) -> {
|
||||||
double px = (headless && pregen!=null) ? pxx/2 : pxx;
|
double px = (headless && pregen != null) ? pxx / 2 : pxx;
|
||||||
|
|
||||||
if(pregen != null && !headless)
|
if (pregen != null && !headless) {
|
||||||
{
|
|
||||||
px = (px / 2) + 0.5;
|
px = (px / 2) + 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sender != null)
|
if (sender != null) {
|
||||||
{
|
if (sender.isPlayer()) {
|
||||||
if(sender.isPlayer())
|
|
||||||
{
|
|
||||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generating " + Form.pc(px)));
|
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generating " + Form.pc(px)));
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sender.sendMessage("Generating " + Form.f(px, 0));
|
sender.sendMessage("Generating " + Form.f(px, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(d == null)
|
if (d == null) {
|
||||||
{
|
|
||||||
throw new MissingDimensionException("Cannot find dimension '" + dimension() + "'");
|
throw new MissingDimensionException("Cannot find dimension '" + dimension() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headless)
|
if (headless) {
|
||||||
{
|
|
||||||
HeadlessWorld w = new HeadlessWorld(name, d, seed, studio);
|
HeadlessWorld w = new HeadlessWorld(name, d, seed, studio);
|
||||||
access = w.generate().getGenerator();
|
access = w.generate().getGenerator();
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
O<Boolean> done = new O<>();
|
O<Boolean> done = new O<>();
|
||||||
done.set(false);
|
done.set(false);
|
||||||
WorldCreator wc = new IrisWorldCreator()
|
WorldCreator wc = new IrisWorldCreator()
|
||||||
@@ -146,9 +136,8 @@ public class IrisCreator {
|
|||||||
while (finalAccess1.getGenerated() < req && !done.get()) {
|
while (finalAccess1.getGenerated() < req && !done.get()) {
|
||||||
double v = (double) finalAccess1.getGenerated() / (double) req;
|
double v = (double) finalAccess1.getGenerated() / (double) req;
|
||||||
|
|
||||||
if(pregen != null)
|
if (pregen != null) {
|
||||||
{
|
v /= 2;
|
||||||
v /=2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.isPlayer()) {
|
if (sender.isPlayer()) {
|
||||||
@@ -173,8 +162,7 @@ public class IrisCreator {
|
|||||||
done.set(true);
|
done.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(access == null)
|
if (access == null) {
|
||||||
{
|
|
||||||
throw new IrisException("Access is null. Something bad happened.");
|
throw new IrisException("Access is null. Something bad happened.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,8 +170,7 @@ public class IrisCreator {
|
|||||||
Runnable loadup = () -> {
|
Runnable loadup = () -> {
|
||||||
try {
|
try {
|
||||||
J.sfut(() -> {
|
J.sfut(() -> {
|
||||||
if(headless)
|
if (headless) {
|
||||||
{
|
|
||||||
O<Boolean> done = new O<>();
|
O<Boolean> done = new O<>();
|
||||||
done.set(false);
|
done.set(false);
|
||||||
|
|
||||||
@@ -193,7 +180,7 @@ public class IrisCreator {
|
|||||||
|
|
||||||
while (finalAccess.getGenerated() < req && !done.get()) {
|
while (finalAccess.getGenerated() < req && !done.get()) {
|
||||||
double v = (double) finalAccess.getGenerated() / (double) req;
|
double v = (double) finalAccess.getGenerated() / (double) req;
|
||||||
v = (v/2) + 0.5;
|
v = (v / 2) + 0.5;
|
||||||
|
|
||||||
if (sender.isPlayer()) {
|
if (sender.isPlayer()) {
|
||||||
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess.getGenerated()) + " Left)"))));
|
sender.player().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(C.WHITE + "Generating " + Form.pc(v) + ((C.GRAY + " (" + (req - finalAccess.getGenerated()) + " Left)"))));
|
||||||
@@ -222,13 +209,9 @@ public class IrisCreator {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(pregen != null)
|
if (pregen != null) {
|
||||||
{
|
|
||||||
IrisToolbelt.pregenerate(pregen, access).onProgress(prog).whenDone(loadup);
|
IrisToolbelt.pregenerate(pregen, access).onProgress(prog).whenDone(loadup);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
loadup.run();
|
loadup.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import com.volmit.iris.core.pregenerator.methods.HeadlessPregenMethod;
|
|||||||
import com.volmit.iris.core.pregenerator.methods.HybridPregenMethod;
|
import com.volmit.iris.core.pregenerator.methods.HybridPregenMethod;
|
||||||
import com.volmit.iris.engine.framework.IrisAccess;
|
import com.volmit.iris.engine.framework.IrisAccess;
|
||||||
import com.volmit.iris.engine.object.IrisDimension;
|
import com.volmit.iris.engine.object.IrisDimension;
|
||||||
import com.volmit.iris.util.math.Position2;
|
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -42,83 +41,79 @@ import java.io.File;
|
|||||||
public class IrisToolbelt {
|
public class IrisToolbelt {
|
||||||
/**
|
/**
|
||||||
* Will find / download / search for the dimension or return null
|
* Will find / download / search for the dimension or return null
|
||||||
*
|
* <p>
|
||||||
* - You can provide a dimenson in the packs folder by the folder name
|
* - You can provide a dimenson in the packs folder by the folder name
|
||||||
* - You can provide a github repo by using (assumes branch is master unless specified)
|
* - You can provide a github repo by using (assumes branch is master unless specified)
|
||||||
* - GithubUsername/repository
|
* - GithubUsername/repository
|
||||||
* - GithubUsername/repository/branch
|
* - GithubUsername/repository/branch
|
||||||
*
|
*
|
||||||
* @param dimension the dimension id such as overworld or flat
|
* @param dimension the dimension id such as overworld or flat
|
||||||
* @return the IrisDimension or null
|
* @return the IrisDimension or null
|
||||||
*/
|
*/
|
||||||
public static IrisDimension getDimension(String dimension)
|
public static IrisDimension getDimension(String dimension) {
|
||||||
{
|
|
||||||
File pack = Iris.instance.getDataFolder("packs", dimension);
|
File pack = Iris.instance.getDataFolder("packs", dimension);
|
||||||
|
|
||||||
if(!pack.exists())
|
if (!pack.exists()) {
|
||||||
{
|
|
||||||
Iris.proj.downloadSearch(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag()), dimension, false, false);
|
Iris.proj.downloadSearch(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag()), dimension, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!pack.exists())
|
if (!pack.exists()) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new IrisDataManager(pack).getDimensionLoader().load(dimension);
|
return new IrisDataManager(pack).getDimensionLoader().load(dimension);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a world with plenty of options
|
* Create a world with plenty of options
|
||||||
|
*
|
||||||
* @return the creator builder
|
* @return the creator builder
|
||||||
*/
|
*/
|
||||||
public static IrisCreator createWorld()
|
public static IrisCreator createWorld() {
|
||||||
{
|
|
||||||
return new IrisCreator();
|
return new IrisCreator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given world is an Iris World (same as access(world) != null)
|
* Checks if the given world is an Iris World (same as access(world) != null)
|
||||||
|
*
|
||||||
* @param world the world
|
* @param world the world
|
||||||
* @return true if it is an Iris Access world
|
* @return true if it is an Iris Access world
|
||||||
*/
|
*/
|
||||||
public static boolean isIrisWorld(World world)
|
public static boolean isIrisWorld(World world) {
|
||||||
{
|
|
||||||
return access(world) != null;
|
return access(world) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Iris generator for the given world
|
* Get the Iris generator for the given world
|
||||||
|
*
|
||||||
* @param world the given world
|
* @param world the given world
|
||||||
* @return the IrisAccess or null if it's not an Iris World
|
* @return the IrisAccess or null if it's not an Iris World
|
||||||
*/
|
*/
|
||||||
public static IrisAccess access(World world)
|
public static IrisAccess access(World world) {
|
||||||
{
|
|
||||||
return IrisWorlds.access(world);
|
return IrisWorlds.access(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a pregenerator task
|
* Start a pregenerator task
|
||||||
* @param task the scheduled task
|
*
|
||||||
|
* @param task the scheduled task
|
||||||
* @param method the method to execute the task
|
* @param method the method to execute the task
|
||||||
* @return the pregenerator job (already started)
|
* @return the pregenerator job (already started)
|
||||||
*/
|
*/
|
||||||
public static PregeneratorJob pregenerate(PregenTask task, PregeneratorMethod method)
|
public static PregeneratorJob pregenerate(PregenTask task, PregeneratorMethod method) {
|
||||||
{
|
|
||||||
return new PregeneratorJob(task, method);
|
return new PregeneratorJob(task, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a pregenerator task. If the supplied generator is headless, headless mode is used,
|
* Start a pregenerator task. If the supplied generator is headless, headless mode is used,
|
||||||
* otherwise Hybrid mode is used.
|
* otherwise Hybrid mode is used.
|
||||||
* @param task the scheduled task
|
*
|
||||||
|
* @param task the scheduled task
|
||||||
* @param access the Iris Generator
|
* @param access the Iris Generator
|
||||||
* @return the pregenerator job (already started)
|
* @return the pregenerator job (already started)
|
||||||
*/
|
*/
|
||||||
public static PregeneratorJob pregenerate(PregenTask task, IrisAccess access)
|
public static PregeneratorJob pregenerate(PregenTask task, IrisAccess access) {
|
||||||
{
|
if (access.isHeadless()) {
|
||||||
if(access.isHeadless())
|
|
||||||
{
|
|
||||||
return pregenerate(task, new HeadlessPregenMethod(access.getHeadlessGenerator().getWorld(), access.getHeadlessGenerator()));
|
return pregenerate(task, new HeadlessPregenMethod(access.getHeadlessGenerator().getWorld(), access.getHeadlessGenerator()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,14 +123,13 @@ public class IrisToolbelt {
|
|||||||
/**
|
/**
|
||||||
* Start a pregenerator task. If the supplied generator is headless, headless mode is used,
|
* Start a pregenerator task. If the supplied generator is headless, headless mode is used,
|
||||||
* otherwise Hybrid mode is used.
|
* otherwise Hybrid mode is used.
|
||||||
* @param task the scheduled task
|
*
|
||||||
|
* @param task the scheduled task
|
||||||
* @param world the World
|
* @param world the World
|
||||||
* @return the pregenerator job (already started)
|
* @return the pregenerator job (already started)
|
||||||
*/
|
*/
|
||||||
public static PregeneratorJob pregenerate(PregenTask task, World world)
|
public static PregeneratorJob pregenerate(PregenTask task, World world) {
|
||||||
{
|
if (isIrisWorld(world)) {
|
||||||
if(isIrisWorld(world))
|
|
||||||
{
|
|
||||||
return pregenerate(task, access(world));
|
return pregenerate(task, access(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,10 +139,10 @@ public class IrisToolbelt {
|
|||||||
/**
|
/**
|
||||||
* Evacuate all players from the world into literally any other world.
|
* Evacuate all players from the world into literally any other world.
|
||||||
* If there are no other worlds, kick them! Not the best but what's mine is mine sometimes...
|
* If there are no other worlds, kick them! Not the best but what's mine is mine sometimes...
|
||||||
|
*
|
||||||
* @param world the world to evac
|
* @param world the world to evac
|
||||||
*/
|
*/
|
||||||
public static void evacuate(World world)
|
public static void evacuate(World world) {
|
||||||
{
|
|
||||||
IrisWorlds.evacuate(world);
|
IrisWorlds.evacuate(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,8 +198,7 @@ public class IrisComplex implements DataProvider {
|
|||||||
}, Interpolated.DOUBLE).cache2D(cacheSize);
|
}, Interpolated.DOUBLE).cache2D(cacheSize);
|
||||||
slopeStream = heightStream.slope(3).interpolate().bilinear(3, 3).cache2D(cacheSize);
|
slopeStream = heightStream.slope(3).interpolate().bilinear(3, 3).cache2D(cacheSize);
|
||||||
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
objectChanceStream = ProceduralStream.ofDouble((x, z) -> {
|
||||||
if(engine.getDimension().hasFeatures(engine))
|
if (engine.getDimension().hasFeatures(engine)) {
|
||||||
{
|
|
||||||
AtomicDouble str = new AtomicDouble(1D);
|
AtomicDouble str = new AtomicDouble(1D);
|
||||||
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i)
|
engine.getFramework().getEngineParallax().forEachFeature(x, z, (i)
|
||||||
-> str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z))));
|
-> str.set(Math.min(str.get(), i.getObjectChanceModifier(x, z))));
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import com.volmit.iris.util.format.Form;
|
|||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -99,7 +98,7 @@ public class IrisEngineCompound implements EngineCompound {
|
|||||||
} else {
|
} else {
|
||||||
double totalWeight = 0D;
|
double totalWeight = 0D;
|
||||||
engines = new Engine[rootDimension.getDimensionalComposite().size()];
|
engines = new Engine[rootDimension.getDimensionalComposite().size()];
|
||||||
burster = engines.length > 1 ? new MultiBurst("Iris Compound " + rootDimension.getName(), IrisSettings.get().getConcurrency().getEngineThreadPriority(), engines.length) : null;
|
burster = engines.length > 1 ? new MultiBurst("Iris Compound " + rootDimension.getName(), IrisSettings.get().getConcurrency().getEngineThreadPriority(), engines.length) : null;
|
||||||
int threadDist = (Math.max(2, maximumThreads - engines.length)) / engines.length;
|
int threadDist = (Math.max(2, maximumThreads - engines.length)) / engines.length;
|
||||||
|
|
||||||
if ((threadDist * engines.length) + engines.length > maximumThreads) {
|
if ((threadDist * engines.length) + engines.length > maximumThreads) {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import com.volmit.iris.engine.hunk.view.BiomeGridHunkView;
|
|||||||
import com.volmit.iris.engine.object.IrisBiome;
|
import com.volmit.iris.engine.object.IrisBiome;
|
||||||
import com.volmit.iris.engine.object.IrisBiomeCustom;
|
import com.volmit.iris.engine.object.IrisBiomeCustom;
|
||||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.volmit.iris.util.collection.KSet;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.type.Farmland;
|
|
||||||
|
|
||||||
public class B {
|
public class B {
|
||||||
private static final Material AIR_MATERIAL = Material.AIR;
|
private static final Material AIR_MATERIAL = Material.AIR;
|
||||||
|
|||||||
@@ -18,11 +18,9 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.data.chunk;
|
package com.volmit.iris.engine.data.chunk;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.core.nms.BiomeBaseInjector;
|
import com.volmit.iris.core.nms.BiomeBaseInjector;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.util.data.IrisBiomeStorage;
|
import com.volmit.iris.util.data.IrisBiomeStorage;
|
||||||
import net.minecraft.world.level.chunk.BiomeStorage;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -39,13 +37,11 @@ public class LinkedTerrainChunk implements TerrainChunk {
|
|||||||
private ChunkData rawChunkData;
|
private ChunkData rawChunkData;
|
||||||
private final BiomeGrid storage;
|
private final BiomeGrid storage;
|
||||||
|
|
||||||
public LinkedTerrainChunk(World world)
|
public LinkedTerrainChunk(World world) {
|
||||||
{
|
|
||||||
this(null, Bukkit.createChunkData(world));
|
this(null, Bukkit.createChunkData(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedTerrainChunk(World world, BiomeGrid storage)
|
public LinkedTerrainChunk(World world, BiomeGrid storage) {
|
||||||
{
|
|
||||||
this(storage, Bukkit.createChunkData(world));
|
this(storage, Bukkit.createChunkData(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package com.volmit.iris.engine.data.mca;
|
package com.volmit.iris.engine.data.mca;
|
||||||
|
|
||||||
import com.volmit.iris.engine.data.nbt.tag.CompoundTag;
|
import com.volmit.iris.engine.data.nbt.tag.CompoundTag;
|
||||||
import com.volmit.iris.engine.hunk.storage.ArrayHunk;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
|
|
||||||
@@ -242,8 +241,7 @@ public class MCAFile {
|
|||||||
return getChunk(getChunkIndex(chunkX, chunkZ));
|
return getChunk(getChunkIndex(chunkX, chunkZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChunk(int chunkX, int chunkZ)
|
public boolean hasChunk(int chunkX, int chunkZ) {
|
||||||
{
|
|
||||||
return getChunk(chunkX, chunkZ) != null;
|
return getChunk(chunkX, chunkZ) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,21 +24,20 @@ import com.volmit.iris.engine.cache.Cache;
|
|||||||
import com.volmit.iris.engine.data.B;
|
import com.volmit.iris.engine.data.B;
|
||||||
import com.volmit.iris.engine.data.nbt.tag.CompoundTag;
|
import com.volmit.iris.engine.data.nbt.tag.CompoundTag;
|
||||||
import com.volmit.iris.engine.data.nbt.tag.StringTag;
|
import com.volmit.iris.engine.data.nbt.tag.StringTag;
|
||||||
import com.volmit.iris.util.collection.KList;
|
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.scheduling.IrisLock;
|
import com.volmit.iris.util.scheduling.IrisLock;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class NBTWorld {
|
public class NBTWorld {
|
||||||
private static final BlockData AIR = B.get("AIR");
|
private static final BlockData AIR = B.get("AIR");
|
||||||
@@ -50,8 +49,7 @@ public class NBTWorld {
|
|||||||
private final File worldFolder;
|
private final File worldFolder;
|
||||||
private final ExecutorService saveQueue;
|
private final ExecutorService saveQueue;
|
||||||
|
|
||||||
public NBTWorld(File worldFolder)
|
public NBTWorld(File worldFolder) {
|
||||||
{
|
|
||||||
this.worldFolder = worldFolder;
|
this.worldFolder = worldFolder;
|
||||||
this.loadedRegions = new KMap<>();
|
this.loadedRegions = new KMap<>();
|
||||||
this.lastUse = new KMap<>();
|
this.lastUse = new KMap<>();
|
||||||
@@ -63,20 +61,17 @@ public class NBTWorld {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close()
|
public void close() {
|
||||||
{
|
|
||||||
regionLock.lock();
|
regionLock.lock();
|
||||||
|
|
||||||
for(Long i : loadedRegions.k())
|
for (Long i : loadedRegions.k()) {
|
||||||
{
|
|
||||||
queueSaveUnload(Cache.keyX(i), Cache.keyZ(i));
|
queueSaveUnload(Cache.keyX(i), Cache.keyZ(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
regionLock.unlock();
|
regionLock.unlock();
|
||||||
saveQueue.shutdown();
|
saveQueue.shutdown();
|
||||||
try {
|
try {
|
||||||
while(!saveQueue.awaitTermination(3, TimeUnit.SECONDS))
|
while (!saveQueue.awaitTermination(3, TimeUnit.SECONDS)) {
|
||||||
{
|
|
||||||
Iris.info("Still Waiting to save MCA Files...");
|
Iris.info("Still Waiting to save MCA Files...");
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@@ -84,52 +79,43 @@ public class NBTWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flushNow()
|
public void flushNow() {
|
||||||
{
|
|
||||||
regionLock.lock();
|
regionLock.lock();
|
||||||
|
|
||||||
for(Long i : loadedRegions.k())
|
for (Long i : loadedRegions.k()) {
|
||||||
{
|
|
||||||
doSaveUnload(Cache.keyX(i), Cache.keyZ(i));
|
doSaveUnload(Cache.keyX(i), Cache.keyZ(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
regionLock.unlock();
|
regionLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queueSaveUnload(int x, int z)
|
public void queueSaveUnload(int x, int z) {
|
||||||
{
|
|
||||||
saveQueue.submit(() -> doSaveUnload(x, z));
|
saveQueue.submit(() -> doSaveUnload(x, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doSaveUnload(int x, int z)
|
public void doSaveUnload(int x, int z) {
|
||||||
{
|
|
||||||
MCAFile f = getMCAOrNull(x, z);
|
MCAFile f = getMCAOrNull(x, z);
|
||||||
if(f != null)
|
if (f != null) {
|
||||||
{
|
|
||||||
unloadRegion(x, z);
|
unloadRegion(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveRegion(x, z, f);
|
saveRegion(x, z, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
public void save() {
|
||||||
{
|
|
||||||
regionLock.lock();
|
regionLock.lock();
|
||||||
|
|
||||||
boolean saving = true;
|
boolean saving = true;
|
||||||
|
|
||||||
for(Long i : loadedRegions.k())
|
for (Long i : loadedRegions.k()) {
|
||||||
{
|
|
||||||
int x = Cache.keyX(i);
|
int x = Cache.keyX(i);
|
||||||
int z = Cache.keyZ(i);
|
int z = Cache.keyZ(i);
|
||||||
|
|
||||||
if(!lastUse.containsKey(i))
|
if (!lastUse.containsKey(i)) {
|
||||||
{
|
|
||||||
lastUse.put(i, M.ms());
|
lastUse.put(i, M.ms());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(shouldUnload(x, z))
|
if (shouldUnload(x, z)) {
|
||||||
{
|
|
||||||
queueSaveUnload(x, z);
|
queueSaveUnload(x, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,13 +125,11 @@ public class NBTWorld {
|
|||||||
regionLock.unlock();
|
regionLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queueSave()
|
public void queueSave() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void unloadRegion(int x, int z)
|
public synchronized void unloadRegion(int x, int z) {
|
||||||
{
|
|
||||||
long key = Cache.key(x, z);
|
long key = Cache.key(x, z);
|
||||||
regionLock.lock();
|
regionLock.lock();
|
||||||
loadedRegions.remove(key);
|
loadedRegions.remove(key);
|
||||||
@@ -154,8 +138,7 @@ public class NBTWorld {
|
|||||||
Iris.debug("Unloaded Region " + C.GOLD + x + " " + z);
|
Iris.debug("Unloaded Region " + C.GOLD + x + " " + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveRegion(int x, int z)
|
public void saveRegion(int x, int z) {
|
||||||
{
|
|
||||||
long k = Cache.key(x, z);
|
long k = Cache.key(x, z);
|
||||||
MCAFile mca = getMCAOrNull(x, z);
|
MCAFile mca = getMCAOrNull(x, z);
|
||||||
try {
|
try {
|
||||||
@@ -167,8 +150,7 @@ public class NBTWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveRegion(int x, int z, MCAFile mca)
|
public void saveRegion(int x, int z, MCAFile mca) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
MCAUtil.write(mca, getRegionFile(x, z), true);
|
MCAUtil.write(mca, getRegionFile(x, z), true);
|
||||||
Iris.debug("Saved Region " + C.GOLD + x + " " + z);
|
Iris.debug("Saved Region " + C.GOLD + x + " " + z);
|
||||||
@@ -178,8 +160,7 @@ public class NBTWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldUnload(int x, int z)
|
public boolean shouldUnload(int x, int z) {
|
||||||
{
|
|
||||||
return getIdleDuration(x, z) > 60000;
|
return getIdleDuration(x, z) > 60000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,8 +277,7 @@ public class NBTWorld {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getIdleDuration(int x, int z)
|
public long getIdleDuration(int x, int z) {
|
||||||
{
|
|
||||||
Long l = lastUse.get(Cache.key(x, z));
|
Long l = lastUse.get(Cache.key(x, z));
|
||||||
|
|
||||||
return l == null ? 0 : (M.ms() - l);
|
return l == null ? 0 : (M.ms() - l);
|
||||||
@@ -311,8 +291,7 @@ public class NBTWorld {
|
|||||||
MCAFile mcaf = loadedRegions.get(key);
|
MCAFile mcaf = loadedRegions.get(key);
|
||||||
regionLock.unlock();
|
regionLock.unlock();
|
||||||
|
|
||||||
if(mcaf == null)
|
if (mcaf == null) {
|
||||||
{
|
|
||||||
mcaf = new MCAFile(x, z);
|
mcaf = new MCAFile(x, z);
|
||||||
regionLock.lock();
|
regionLock.lock();
|
||||||
loadedRegions.put(key, mcaf);
|
loadedRegions.put(key, mcaf);
|
||||||
@@ -327,8 +306,7 @@ public class NBTWorld {
|
|||||||
MCAFile ff = null;
|
MCAFile ff = null;
|
||||||
regionLock.lock();
|
regionLock.lock();
|
||||||
|
|
||||||
if(loadedRegions.containsKey(key))
|
if (loadedRegions.containsKey(key)) {
|
||||||
{
|
|
||||||
lastUse.put(key, M.ms());
|
lastUse.put(key, M.ms());
|
||||||
ff = loadedRegions.get(key);
|
ff = loadedRegions.get(key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -357,8 +357,7 @@ public interface Engine extends DataProvider, Fallible, GeneratorAccess, LootPro
|
|||||||
return getCompound().isStudio();
|
return getCompound().isStudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
default MultiBurst burst()
|
default MultiBurst burst() {
|
||||||
{
|
|
||||||
return getTarget().getBurster();
|
return getTarget().getBurster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -447,8 +447,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
IrisWorld ww = (getComposite() == null || getComposite().getWorld() == null) ? IrisWorld.fromWorld(world) : getComposite().getWorld();
|
IrisWorld ww = (getComposite() == null || getComposite().getWorld() == null) ? IrisWorld.fromWorld(world) : getComposite().getWorld();
|
||||||
generateChunkRawData(ww, x, z, tc).run();
|
generateChunkRawData(ww, x, z, tc).run();
|
||||||
|
|
||||||
if(!getComposite().getWorld().hasRealWorld())
|
if (!getComposite().getWorld().hasRealWorld()) {
|
||||||
{
|
|
||||||
getComposite().getWorld().bind(world);
|
getComposite().getWorld().bind(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,8 +461,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
return tc.getRaw();
|
return tc.getRaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assignHeadlessGenerator(HeadlessGenerator headlessGenerator)
|
public void assignHeadlessGenerator(HeadlessGenerator headlessGenerator) {
|
||||||
{
|
|
||||||
this.headlessGenerator = headlessGenerator;
|
this.headlessGenerator = headlessGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,8 +470,7 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
return headlessGenerator;
|
return headlessGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void assignHeadlessNBTWriter(NBTWorld writer)
|
public void assignHeadlessNBTWriter(NBTWorld writer) {
|
||||||
{
|
|
||||||
this.nbtWorld = writer;
|
this.nbtWorld = writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,13 +489,11 @@ public class EngineCompositeGenerator extends ChunkGenerator implements IrisAcce
|
|||||||
BurstExecutor e = burst.burst(1024);
|
BurstExecutor e = burst.burst(1024);
|
||||||
|
|
||||||
PregenTask.iterateRegion(x, z, (ii, jj) -> e.queue(() -> {
|
PregenTask.iterateRegion(x, z, (ii, jj) -> e.queue(() -> {
|
||||||
if(l != null)
|
if (l != null) {
|
||||||
{
|
|
||||||
l.onChunkGenerating(ii, jj);
|
l.onChunkGenerating(ii, jj);
|
||||||
}
|
}
|
||||||
directWriteChunk(w, ii, jj, writer);
|
directWriteChunk(w, ii, jj, writer);
|
||||||
if(l != null)
|
if (l != null) {
|
||||||
{
|
|
||||||
l.onChunkGenerated(ii, jj);
|
l.onChunkGenerated(ii, jj);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import com.volmit.iris.engine.object.common.IrisWorld;
|
|||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import com.volmit.iris.engine.object.tile.TileData;
|
|||||||
import com.volmit.iris.engine.parallax.ParallaxAccess;
|
import com.volmit.iris.engine.parallax.ParallaxAccess;
|
||||||
import com.volmit.iris.engine.parallax.ParallaxChunkMeta;
|
import com.volmit.iris.engine.parallax.ParallaxChunkMeta;
|
||||||
import com.volmit.iris.engine.parallel.BurstExecutor;
|
import com.volmit.iris.engine.parallel.BurstExecutor;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.collection.KMap;
|
import com.volmit.iris.util.collection.KMap;
|
||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
@@ -205,8 +204,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
IrisLock getFeatureLock();
|
IrisLock getFeatureLock();
|
||||||
|
|
||||||
default void forEachFeature(double x, double z, Consumer<IrisFeaturePositional> f) {
|
default void forEachFeature(double x, double z, Consumer<IrisFeaturePositional> f) {
|
||||||
if(!getEngine().getDimension().hasFeatures(getEngine()))
|
if (!getEngine().getDimension().hasFeatures(getEngine())) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,8 +233,7 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
|
|||||||
for (j = -s; j <= s; j++) {
|
for (j = -s; j <= s; j++) {
|
||||||
ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz);
|
ParallaxChunkMeta m = getParallaxAccess().getMetaR(i + cx, j + cz);
|
||||||
|
|
||||||
synchronized (m)
|
synchronized (m) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
for (IrisFeaturePositional k : m.getFeatures()) {
|
for (IrisFeaturePositional k : m.getFeatures()) {
|
||||||
if (k.shouldFilter(x, z)) {
|
if (k.shouldFilter(x, z)) {
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ import com.volmit.iris.util.math.M;
|
|||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.ChronoLatch;
|
import com.volmit.iris.util.scheduling.ChronoLatch;
|
||||||
import com.volmit.iris.util.scheduling.J;
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
@@ -49,7 +47,7 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
|
|
||||||
HeadlessGenerator getHeadlessGenerator();
|
HeadlessGenerator getHeadlessGenerator();
|
||||||
|
|
||||||
default boolean isHeadless(){
|
default boolean isHeadless() {
|
||||||
return getHeadlessGenerator() != null;
|
return getHeadlessGenerator() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,8 +96,7 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
boolean isStudio();
|
boolean isStudio();
|
||||||
|
|
||||||
default Location lookForBiome(IrisBiome biome, long timeout, Consumer<Integer> triesc) {
|
default Location lookForBiome(IrisBiome biome, long timeout, Consumer<Integer> triesc) {
|
||||||
if(!getCompound().getWorld().hasRealWorld())
|
if (!getCompound().getWorld().hasRealWorld()) {
|
||||||
{
|
|
||||||
Iris.error("Cannot GOTO without a bound world (headless mode)");
|
Iris.error("Cannot GOTO without a bound world (headless mode)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -184,8 +181,7 @@ public interface IrisAccess extends Hotloadable, DataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default Location lookForRegion(IrisRegion reg, long timeout, Consumer<Integer> triesc) {
|
default Location lookForRegion(IrisRegion reg, long timeout, Consumer<Integer> triesc) {
|
||||||
if(!getCompound().getWorld().hasRealWorld())
|
if (!getCompound().getWorld().hasRealWorld()) {
|
||||||
{
|
|
||||||
Iris.error("Cannot GOTO without a bound world (headless mode)");
|
Iris.error("Cannot GOTO without a bound world (headless mode)");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ package com.volmit.iris.engine.headless;
|
|||||||
|
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.pregenerator.PregenListener;
|
import com.volmit.iris.core.pregenerator.PregenListener;
|
||||||
import com.volmit.iris.engine.data.mca.LoadFlags;
|
|
||||||
import com.volmit.iris.engine.data.mca.MCAFile;
|
|
||||||
import com.volmit.iris.engine.data.mca.MCAUtil;
|
import com.volmit.iris.engine.data.mca.MCAUtil;
|
||||||
import com.volmit.iris.engine.data.mca.NBTWorld;
|
import com.volmit.iris.engine.data.mca.NBTWorld;
|
||||||
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
|
||||||
@@ -35,14 +33,13 @@ import java.io.IOException;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class HeadlessGenerator {
|
public class HeadlessGenerator {
|
||||||
private static KList<Position2> EMPTYPOINTS = new KList<>();
|
private static KList<Position2> EMPTYPOINTS = new KList<>();
|
||||||
private final HeadlessWorld world;
|
private final HeadlessWorld world;
|
||||||
private final EngineCompositeGenerator generator;
|
private final EngineCompositeGenerator generator;
|
||||||
private final NBTWorld writer;
|
private final NBTWorld writer;
|
||||||
private final MultiBurst burst;
|
private final MultiBurst burst;
|
||||||
|
|
||||||
public HeadlessGenerator(HeadlessWorld world)
|
public HeadlessGenerator(HeadlessWorld world) {
|
||||||
{
|
|
||||||
this.world = world;
|
this.world = world;
|
||||||
burst = new MultiBurst("Iris Headless Generator", 9, IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getPregenThreadCount()));
|
burst = new MultiBurst("Iris Headless Generator", 9, IrisSettings.getThreadCount(IrisSettings.get().getConcurrency().getPregenThreadCount()));
|
||||||
writer = new NBTWorld(world.getWorld().worldFolder());
|
writer = new NBTWorld(world.getWorld().worldFolder());
|
||||||
@@ -52,40 +49,33 @@ public class HeadlessGenerator {
|
|||||||
generator.initialize(world.getWorld());
|
generator.initialize(world.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateChunk(int x, int z)
|
public void generateChunk(int x, int z) {
|
||||||
{
|
|
||||||
generator.directWriteChunk(world.getWorld(), x, z, writer);
|
generator.directWriteChunk(world.getWorld(), x, z, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateRegion(int x, int z)
|
public void generateRegion(int x, int z) {
|
||||||
{
|
|
||||||
generator.directWriteMCA(world.getWorld(), x, z, writer, burst);
|
generator.directWriteMCA(world.getWorld(), x, z, writer, burst);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateRegion(int x, int z, PregenListener listener)
|
public void generateRegion(int x, int z, PregenListener listener) {
|
||||||
{
|
|
||||||
generator.directWriteMCA(world.getWorld(), x, z, writer, burst, listener);
|
generator.directWriteMCA(world.getWorld(), x, z, writer, burst, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File generateRegionToFile(int x, int z, PregenListener listener)
|
public File generateRegionToFile(int x, int z, PregenListener listener) {
|
||||||
{
|
|
||||||
generateRegionToFile(x, z, listener);
|
generateRegionToFile(x, z, listener);
|
||||||
flush();
|
flush();
|
||||||
return writer.getRegionFile(x, z);
|
return writer.getRegionFile(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush()
|
public void flush() {
|
||||||
{
|
|
||||||
writer.flushNow();
|
writer.flushNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
public void save() {
|
||||||
{
|
|
||||||
writer.save();
|
writer.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close()
|
public void close() {
|
||||||
{
|
|
||||||
burst.shutdownAndAwait();
|
burst.shutdownAndAwait();
|
||||||
generator.close();
|
generator.close();
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|||||||
@@ -40,13 +40,11 @@ public class HeadlessWorld {
|
|||||||
private final IrisWorld world;
|
private final IrisWorld world;
|
||||||
private boolean studio = false;
|
private boolean studio = false;
|
||||||
|
|
||||||
public HeadlessWorld(String worldName, IrisDimension dimension, long seed)
|
public HeadlessWorld(String worldName, IrisDimension dimension, long seed) {
|
||||||
{
|
|
||||||
this(worldName, dimension, seed, false);
|
this(worldName, dimension, seed, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeadlessWorld(String worldName, IrisDimension dimension, long seed, boolean studio)
|
public HeadlessWorld(String worldName, IrisDimension dimension, long seed, boolean studio) {
|
||||||
{
|
|
||||||
this.worldName = worldName;
|
this.worldName = worldName;
|
||||||
this.dimension = dimension;
|
this.dimension = dimension;
|
||||||
this.studio = studio;
|
this.studio = studio;
|
||||||
@@ -61,19 +59,16 @@ public class HeadlessWorld {
|
|||||||
world.worldFolder().mkdirs();
|
world.worldFolder().mkdirs();
|
||||||
new File(world.worldFolder(), "region").mkdirs();
|
new File(world.worldFolder(), "region").mkdirs();
|
||||||
|
|
||||||
if(!studio && !new File(world.worldFolder(), "iris").exists())
|
if (!studio && !new File(world.worldFolder(), "iris").exists()) {
|
||||||
{
|
|
||||||
Iris.proj.installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag("Headless")), dimension.getLoadKey(), world.worldFolder());
|
Iris.proj.installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag("Headless")), dimension.getLoadKey(), world.worldFolder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeadlessGenerator generate()
|
public HeadlessGenerator generate() {
|
||||||
{
|
|
||||||
return new HeadlessGenerator(this);
|
return new HeadlessGenerator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public World load()
|
public World load() {
|
||||||
{
|
|
||||||
return new WorldCreator(worldName)
|
return new WorldCreator(worldName)
|
||||||
.environment(dimension.getEnvironment())
|
.environment(dimension.getEnvironment())
|
||||||
.seed(world.seed())
|
.seed(world.seed())
|
||||||
@@ -85,8 +80,7 @@ public class HeadlessWorld {
|
|||||||
return new HeadlessWorld(world.getName(), IrisWorlds.access(world).getTarget().getDimension(), world.getSeed());
|
return new HeadlessWorld(world.getName(), IrisWorlds.access(world).getTarget().getDimension(), world.getSeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HeadlessWorld from(String name, String dimension, long seed)
|
public static HeadlessWorld from(String name, String dimension, long seed) {
|
||||||
{
|
|
||||||
return new HeadlessWorld(name, IrisDataManager.loadAnyDimension(dimension), seed);
|
return new HeadlessWorld(name, IrisDataManager.loadAnyDimension(dimension), seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import com.volmit.iris.util.collection.KMap;
|
|||||||
import com.volmit.iris.util.collection.KSet;
|
import com.volmit.iris.util.collection.KSet;
|
||||||
import com.volmit.iris.util.function.Function2;
|
import com.volmit.iris.util.function.Function2;
|
||||||
import com.volmit.iris.util.function.Function3;
|
import com.volmit.iris.util.function.Function3;
|
||||||
import com.volmit.iris.util.math.Position2;
|
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
|
import com.volmit.iris.util.math.Position2;
|
||||||
import com.volmit.iris.util.oldnbt.ByteArrayTag;
|
import com.volmit.iris.util.oldnbt.ByteArrayTag;
|
||||||
import com.volmit.iris.util.oldnbt.CompoundTag;
|
import com.volmit.iris.util.oldnbt.CompoundTag;
|
||||||
import com.volmit.iris.util.oldnbt.Tag;
|
import com.volmit.iris.util.oldnbt.Tag;
|
||||||
@@ -101,8 +101,7 @@ public class HunkRegionSlice<T> {
|
|||||||
public synchronized void save(MultiBurst burst) {
|
public synchronized void save(MultiBurst burst) {
|
||||||
BurstExecutor e = burst.burst();
|
BurstExecutor e = burst.burst();
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
for (Position2 i : save.copy()) {
|
for (Position2 i : save.copy()) {
|
||||||
if (i == null) {
|
if (i == null) {
|
||||||
continue;
|
continue;
|
||||||
@@ -118,10 +117,7 @@ public class HunkRegionSlice<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
e.complete();
|
e.complete();
|
||||||
}
|
} catch (Throwable ee) {
|
||||||
|
|
||||||
catch(Throwable ee)
|
|
||||||
{
|
|
||||||
Iris.reportError(ee);
|
Iris.reportError(ee);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import com.volmit.iris.engine.hunk.Hunk;
|
|||||||
import com.volmit.iris.engine.noise.CNG;
|
import com.volmit.iris.engine.noise.CNG;
|
||||||
import com.volmit.iris.engine.object.NoiseStyle;
|
import com.volmit.iris.engine.object.NoiseStyle;
|
||||||
import com.volmit.iris.util.math.BlockPosition;
|
import com.volmit.iris.util.math.BlockPosition;
|
||||||
import com.volmit.iris.util.math.Position2;
|
|
||||||
import com.volmit.iris.util.math.MathHelper;
|
import com.volmit.iris.util.math.MathHelper;
|
||||||
|
import com.volmit.iris.util.math.Position2;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|||||||
@@ -515,37 +515,28 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
|
|
||||||
public boolean hasFeatures(DataProvider data) {
|
public boolean hasFeatures(DataProvider data) {
|
||||||
return featuresUsed.aquire(() -> {
|
return featuresUsed.aquire(() -> {
|
||||||
if(getFeatures().isNotEmpty() || getSpecificFeatures().isNotEmpty())
|
if (getFeatures().isNotEmpty() || getSpecificFeatures().isNotEmpty()) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IrisRegion i : getAllRegions(data))
|
for (IrisRegion i : getAllRegions(data)) {
|
||||||
{
|
if (i.getFeatures().isNotEmpty()) {
|
||||||
if(i.getFeatures().isNotEmpty())
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IrisObjectPlacement j : i.getObjects())
|
for (IrisObjectPlacement j : i.getObjects()) {
|
||||||
{
|
if (j.isVacuum()) {
|
||||||
if(j.isVacuum())
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IrisBiome j : i.getAllBiomes(data))
|
for (IrisBiome j : i.getAllBiomes(data)) {
|
||||||
{
|
if (j.getFeatures().isNotEmpty()) {
|
||||||
if(j.getFeatures().isNotEmpty())
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IrisObjectPlacement k : i.getObjects())
|
for (IrisObjectPlacement k : i.getObjects()) {
|
||||||
{
|
if (k.isVacuum()) {
|
||||||
if(k.isVacuum())
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,13 +142,9 @@ public class IrisLoot {
|
|||||||
i.apply(rng, m);
|
i.apply(rng, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
m.setCustomModelData(getCustomModel());
|
m.setCustomModelData(getCustomModel());
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
}
|
}
|
||||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||||
@@ -231,13 +227,9 @@ public class IrisLoot {
|
|||||||
i.apply(rng, m);
|
i.apply(rng, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
m.setCustomModelData(getCustomModel());
|
m.setCustomModelData(getCustomModel());
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,31 +47,27 @@ public class IrisWorld {
|
|||||||
private int minHeight;
|
private int minHeight;
|
||||||
private int maxHeight;
|
private int maxHeight;
|
||||||
|
|
||||||
public static IrisWorld fromWorld(World world)
|
public static IrisWorld fromWorld(World world) {
|
||||||
{
|
|
||||||
return bindWorld(IrisWorld.builder().build(), world);
|
return bindWorld(IrisWorld.builder().build(), world);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IrisWorld bindWorld(IrisWorld iw, World world)
|
private static IrisWorld bindWorld(IrisWorld iw, World world) {
|
||||||
{
|
|
||||||
return iw.name(world.getName())
|
return iw.name(world.getName())
|
||||||
.worldFolder(world.getWorldFolder())
|
.worldFolder(world.getWorldFolder())
|
||||||
.seed(world.getSeed())
|
.seed(world.getSeed())
|
||||||
.minHeight(world.getMinHeight())
|
.minHeight(world.getMinHeight())
|
||||||
.maxHeight(world.getMaxHeight())
|
.maxHeight(world.getMaxHeight())
|
||||||
.realWorld(world)
|
.realWorld(world)
|
||||||
.environment(world.getEnvironment());
|
.environment(world.getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRealWorld()
|
public boolean hasRealWorld() {
|
||||||
{
|
|
||||||
return realWorld != null;
|
return realWorld != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Player> getPlayers() {
|
public List<Player> getPlayers() {
|
||||||
|
|
||||||
if(hasRealWorld())
|
if (hasRealWorld()) {
|
||||||
{
|
|
||||||
return realWorld().getPlayers();
|
return realWorld().getPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,8 +75,7 @@ public class IrisWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void evacuate() {
|
public void evacuate() {
|
||||||
if(hasRealWorld())
|
if (hasRealWorld()) {
|
||||||
{
|
|
||||||
IrisWorlds.evacuate(realWorld());
|
IrisWorlds.evacuate(realWorld());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,8 +85,7 @@ public class IrisWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Location spawnLocation() {
|
public Location spawnLocation() {
|
||||||
if(hasRealWorld())
|
if (hasRealWorld()) {
|
||||||
{
|
|
||||||
return realWorld().getSpawnLocation();
|
return realWorld().getSpawnLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,8 +94,7 @@ public class IrisWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Entity> Collection<? extends T> getEntitiesByClass(Class<T> t) {
|
public <T extends Entity> Collection<? extends T> getEntitiesByClass(Class<T> t) {
|
||||||
if(hasRealWorld())
|
if (hasRealWorld()) {
|
||||||
{
|
|
||||||
return realWorld().getEntitiesByClass(t);
|
return realWorld().getEntitiesByClass(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import com.google.gson.Gson;
|
|||||||
import com.volmit.iris.engine.hunk.io.HunkIOAdapter;
|
import com.volmit.iris.engine.hunk.io.HunkIOAdapter;
|
||||||
import com.volmit.iris.engine.hunk.io.PaletteHunkIOAdapter;
|
import com.volmit.iris.engine.hunk.io.PaletteHunkIOAdapter;
|
||||||
import com.volmit.iris.engine.object.IrisFeaturePositional;
|
import com.volmit.iris.engine.object.IrisFeaturePositional;
|
||||||
import com.volmit.iris.util.collection.KList;
|
|
||||||
import com.volmit.iris.util.oldnbt.CompoundTag;
|
import com.volmit.iris.util.oldnbt.CompoundTag;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|||||||
@@ -27,12 +27,10 @@ import com.volmit.iris.engine.object.tile.TileData;
|
|||||||
import com.volmit.iris.engine.parallel.GridLock;
|
import com.volmit.iris.engine.parallel.GridLock;
|
||||||
import com.volmit.iris.engine.parallel.MultiBurst;
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.oldnbt.ByteArrayTag;
|
import com.volmit.iris.util.oldnbt.ByteArrayTag;
|
||||||
import com.volmit.iris.util.oldnbt.CompoundTag;
|
import com.volmit.iris.util.oldnbt.CompoundTag;
|
||||||
import com.volmit.iris.util.oldnbt.Tag;
|
import com.volmit.iris.util.oldnbt.Tag;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
|
||||||
import org.bukkit.block.TileState;
|
import org.bukkit.block.TileState;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
@@ -167,7 +165,7 @@ public class ParallaxRegion extends HunkRegion {
|
|||||||
tileSlice.save(burst);
|
tileSlice.save(burst);
|
||||||
updateSlice.save(burst);
|
updateSlice.save(burst);
|
||||||
saveMetaHunk();
|
saveMetaHunk();
|
||||||
Iris.debug("Saved Parallax Region "+ C.GOLD + getX() + " " + getZ());
|
Iris.debug("Saved Parallax Region " + C.GOLD + getX() + " " + getZ());
|
||||||
super.save();
|
super.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,16 +99,11 @@ public class MultiBurst {
|
|||||||
public void shutdownAndAwait() {
|
public void shutdownAndAwait() {
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
while (!service.awaitTermination(10, TimeUnit.SECONDS)) {
|
||||||
while(!service.awaitTermination(10, TimeUnit.SECONDS))
|
|
||||||
{
|
|
||||||
Iris.info("Still waiting to shutdown burster...");
|
Iris.info("Still waiting to shutdown burster...");
|
||||||
}
|
}
|
||||||
}
|
} catch (Throwable e) {
|
||||||
|
|
||||||
catch(Throwable e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.exceptions;
|
package com.volmit.iris.util.exceptions;
|
||||||
|
|
||||||
public class IrisException extends Exception
|
public class IrisException extends Exception {
|
||||||
{
|
|
||||||
public IrisException() {
|
public IrisException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.util.exceptions;
|
package com.volmit.iris.util.exceptions;
|
||||||
|
|
||||||
public class MissingDimensionException extends IrisException
|
public class MissingDimensionException extends IrisException {
|
||||||
{
|
|
||||||
public MissingDimensionException() {
|
public MissingDimensionException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ public class Position2 {
|
|||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString() {
|
||||||
{
|
|
||||||
return "[" + x + "," + z + "]";
|
return "[" + x + "," + z + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,8 +56,7 @@ public class Position2 {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position2 regionToChunk()
|
public Position2 regionToChunk() {
|
||||||
{
|
|
||||||
return new Position2(x << 5, z << 5);
|
return new Position2(x << 5, z << 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ import com.volmit.iris.util.function.NastyRunnable;
|
|||||||
import com.volmit.iris.util.math.FinalInteger;
|
import com.volmit.iris.util.math.FinalInteger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|||||||
Reference in New Issue
Block a user