mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-06-18 23:01:07 +00:00
dev shit
This commit is contained in:
@@ -179,10 +179,15 @@ public class CommandDeveloper implements DecreeExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Decree(description = "test")
|
@Decree(description = "test")
|
||||||
public void javafx () {
|
public void devtest () {
|
||||||
try {
|
try {
|
||||||
VMJavaFX javaFX = new VMJavaFX(sender());
|
|
||||||
javaFX.start();
|
for (File mcafile : new File("rrtrender1/region").listFiles()) {
|
||||||
|
MCAFile mca = MCAUtil.read(mcafile);
|
||||||
|
int c = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,14 +33,24 @@ import com.volmit.iris.util.mantle.Mantle;
|
|||||||
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;
|
||||||
import com.volmit.iris.util.math.RollingSequence;
|
import com.volmit.iris.util.math.RollingSequence;
|
||||||
|
import com.volmit.iris.util.misc.E;
|
||||||
|
import com.volmit.iris.util.nbt.mca.Chunk;
|
||||||
|
import com.volmit.iris.util.nbt.mca.MCAFile;
|
||||||
|
import com.volmit.iris.util.nbt.mca.MCAUtil;
|
||||||
|
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.util.parallel.MultiBurst;
|
||||||
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 com.volmit.iris.util.scheduling.Looper;
|
import com.volmit.iris.util.scheduling.Looper;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
public class IrisPregenerator {
|
public class IrisPregenerator {
|
||||||
@@ -68,9 +78,10 @@ public class IrisPregenerator {
|
|||||||
private final ChronoLatch saveLatch = new ChronoLatch(30000);
|
private final ChronoLatch saveLatch = new ChronoLatch(30000);
|
||||||
|
|
||||||
public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener) {
|
public IrisPregenerator(PregenTask task, PregeneratorMethod generator, PregenListener listener) {
|
||||||
|
Iris.info("Initializing Pregenerator");
|
||||||
|
generatedRegions = new KSet<>();
|
||||||
this.listener = listenify(listener);
|
this.listener = listenify(listener);
|
||||||
cl = new ChronoLatch(5000);
|
cl = new ChronoLatch(5000);
|
||||||
generatedRegions = new KSet<>();
|
|
||||||
this.shutdown = new AtomicBoolean(false);
|
this.shutdown = new AtomicBoolean(false);
|
||||||
this.paused = new AtomicBoolean(false);
|
this.paused = new AtomicBoolean(false);
|
||||||
this.task = task;
|
this.task = task;
|
||||||
@@ -87,7 +98,9 @@ public class IrisPregenerator {
|
|||||||
generatedLast = new AtomicInteger(0);
|
generatedLast = new AtomicInteger(0);
|
||||||
generatedLastMinute = new AtomicInteger(0);
|
generatedLastMinute = new AtomicInteger(0);
|
||||||
totalChunks = new AtomicInteger(0);
|
totalChunks = new AtomicInteger(0);
|
||||||
|
IrisToolbelt.access(generator.getWorld()).getEngine().saveEngineData();
|
||||||
task.iterateRegions((_a, _b) -> totalChunks.addAndGet(1024));
|
task.iterateRegions((_a, _b) -> totalChunks.addAndGet(1024));
|
||||||
|
Iris.info("Initialization Completed!");
|
||||||
startTime = new AtomicLong(M.ms());
|
startTime = new AtomicLong(M.ms());
|
||||||
ticker = new Looper() {
|
ticker = new Looper() {
|
||||||
@Override
|
@Override
|
||||||
@@ -173,6 +186,43 @@ public class IrisPregenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getGeneratedRegions() {
|
||||||
|
World world = generator.getWorld();
|
||||||
|
File[] region = new File(world.getWorldFolder(), "region").listFiles();
|
||||||
|
BurstExecutor b = MultiBurst.burst.burst(region.length);
|
||||||
|
b.setMulticore(true);
|
||||||
|
b.queue(() -> {
|
||||||
|
for (File file : region) {
|
||||||
|
try {
|
||||||
|
String regex = "r\\.(\\d+)\\.(-?\\d+)\\.mca";
|
||||||
|
Pattern pattern = Pattern.compile(regex);
|
||||||
|
Matcher matcher = pattern.matcher(file.getName());
|
||||||
|
if (!matcher.find()) continue;
|
||||||
|
int x = Integer.parseInt(matcher.group(1));
|
||||||
|
int z = Integer.parseInt(matcher.group(2));
|
||||||
|
Position2 pos = new Position2(x,z);
|
||||||
|
generatedRegions.add(pos);
|
||||||
|
|
||||||
|
MCAFile mca = MCAUtil.read(file, 0);
|
||||||
|
|
||||||
|
boolean notFull = false;
|
||||||
|
for (int i = 0; i < 1024; i++) {
|
||||||
|
Chunk chunk = mca.getChunk(i);
|
||||||
|
if (chunk == null) {
|
||||||
|
generatedRegions.remove(pos);
|
||||||
|
notFull = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Iris.info("Completed MCA region: " + file.getName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
b.complete();
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
+14
-8
@@ -19,9 +19,12 @@
|
|||||||
package com.volmit.iris.core.pregenerator.methods;
|
package com.volmit.iris.core.pregenerator.methods;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.nms.IHeadless;
|
||||||
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.pregenerator.PregenListener;
|
import com.volmit.iris.core.pregenerator.PregenListener;
|
||||||
import com.volmit.iris.core.pregenerator.PregeneratorMethod;
|
import com.volmit.iris.core.pregenerator.PregeneratorMethod;
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
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.mantle.Mantle;
|
import com.volmit.iris.util.mantle.Mantle;
|
||||||
@@ -42,6 +45,7 @@ import java.util.concurrent.Future;
|
|||||||
|
|
||||||
public class AsyncPregenMethod implements PregeneratorMethod {
|
public class AsyncPregenMethod implements PregeneratorMethod {
|
||||||
private final World world;
|
private final World world;
|
||||||
|
private final Engine engine;
|
||||||
private final MultiBurst burst;
|
private final MultiBurst burst;
|
||||||
private final KList<Future<?>> future;
|
private final KList<Future<?>> future;
|
||||||
private final Map<Chunk, Long> lastUse;
|
private final Map<Chunk, Long> lastUse;
|
||||||
@@ -50,8 +54,8 @@ public class AsyncPregenMethod implements PregeneratorMethod {
|
|||||||
if (!PaperLib.isPaper()) {
|
if (!PaperLib.isPaper()) {
|
||||||
throw new UnsupportedOperationException("Cannot use PaperAsync on non paper!");
|
throw new UnsupportedOperationException("Cannot use PaperAsync on non paper!");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
this.engine = IrisToolbelt.access(world).getEngine();
|
||||||
burst = MultiBurst.burst;
|
burst = MultiBurst.burst;
|
||||||
future = new KList<>(1024);
|
future = new KList<>(1024);
|
||||||
this.lastUse = new KMap<>();
|
this.lastUse = new KMap<>();
|
||||||
@@ -81,13 +85,15 @@ public class AsyncPregenMethod implements PregeneratorMethod {
|
|||||||
|
|
||||||
private void completeChunk(int x, int z, PregenListener listener) {
|
private void completeChunk(int x, int z, PregenListener listener) {
|
||||||
try {
|
try {
|
||||||
future.add(PaperLib.getChunkAtAsync(world, x, z, true).thenApply((i) -> {
|
if (!engine.exists(x,z)) {
|
||||||
if (i == null) return 0;
|
future.add(PaperLib.getChunkAtAsync(world, x, z, true).thenApply((i) -> {
|
||||||
lastUse.put(i, M.ms());
|
if (i == null) return 0;
|
||||||
listener.onChunkGenerated(x, z);
|
lastUse.put(i, M.ms());
|
||||||
listener.onChunkCleaned(x, z);
|
listener.onChunkGenerated(x, z);
|
||||||
return 0;
|
listener.onChunkCleaned(x, z);
|
||||||
}));
|
return 0;
|
||||||
|
}));
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ public class IrisEngineSVC implements IrisService {
|
|||||||
private AtomicBoolean IsTrimAlive;
|
private AtomicBoolean IsTrimAlive;
|
||||||
ChronoLatch cl;
|
ChronoLatch cl;
|
||||||
|
|
||||||
public List<World> corruptedIrisWorlds = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.cl = new ChronoLatch(5000);
|
this.cl = new ChronoLatch(5000);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import com.volmit.iris.util.mantle.MantleFlag;
|
|||||||
import com.volmit.iris.util.math.M;
|
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.matter.MatterStructurePOI;
|
import com.volmit.iris.util.matter.MatterStructurePOI;
|
||||||
|
import com.volmit.iris.util.misc.E;
|
||||||
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 com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
@@ -60,14 +61,17 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(exclude = "context")
|
@EqualsAndHashCode(exclude = "context")
|
||||||
@ToString(exclude = "context")
|
@ToString(exclude = "context")
|
||||||
public class IrisEngine implements Engine {
|
public class IrisEngine implements Engine {
|
||||||
|
private Set<String> chunks = ConcurrentHashMap.newKeySet();
|
||||||
private final AtomicInteger bud;
|
private final AtomicInteger bud;
|
||||||
private final AtomicInteger buds;
|
private final AtomicInteger buds;
|
||||||
private final AtomicInteger generated;
|
private final AtomicInteger generated;
|
||||||
@@ -100,6 +104,7 @@ public class IrisEngine implements Engine {
|
|||||||
private double maxBiomeLayerDensity;
|
private double maxBiomeLayerDensity;
|
||||||
private double maxBiomeDecoratorDensity;
|
private double maxBiomeDecoratorDensity;
|
||||||
private IrisComplex complex;
|
private IrisComplex complex;
|
||||||
|
private final ReentrantLock dataLock;
|
||||||
|
|
||||||
public IrisEngine(EngineTarget target, boolean studio) {
|
public IrisEngine(EngineTarget target, boolean studio) {
|
||||||
this.studio = studio;
|
this.studio = studio;
|
||||||
@@ -107,6 +112,7 @@ public class IrisEngine implements Engine {
|
|||||||
getEngineData();
|
getEngineData();
|
||||||
verifySeed();
|
verifySeed();
|
||||||
this.seedManager = new SeedManager(target.getWorld().getRawWorldSeed());
|
this.seedManager = new SeedManager(target.getWorld().getRawWorldSeed());
|
||||||
|
dataLock = new ReentrantLock();
|
||||||
bud = new AtomicInteger(0);
|
bud = new AtomicInteger(0);
|
||||||
buds = new AtomicInteger(0);
|
buds = new AtomicInteger(0);
|
||||||
metrics = new EngineMetrics(32);
|
metrics = new EngineMetrics(32);
|
||||||
@@ -129,6 +135,7 @@ public class IrisEngine implements Engine {
|
|||||||
failing = false;
|
failing = false;
|
||||||
closed = false;
|
closed = false;
|
||||||
art = J.ar(this::tickRandomPlayer, 0);
|
art = J.ar(this::tickRandomPlayer, 0);
|
||||||
|
chunks = getEngineData().getGeneratedChunks();
|
||||||
setupEngine();
|
setupEngine();
|
||||||
Iris.debug("Engine Initialized " + getCacheID());
|
Iris.debug("Engine Initialized " + getCacheID());
|
||||||
}
|
}
|
||||||
@@ -249,10 +256,10 @@ public class IrisEngine implements Engine {
|
|||||||
try {
|
try {
|
||||||
f.getParentFile().mkdirs();
|
f.getParentFile().mkdirs();
|
||||||
IrisEngineData data = new IrisEngineData();
|
IrisEngineData data = new IrisEngineData();
|
||||||
data.getStatistics().setVersion(Iris.instance.getIrisVersion());
|
data.getStatistics().setIrisCreationVersion(Iris.instance.getIrisVersion());
|
||||||
data.getStatistics().setMCVersion(Iris.instance.getMCVersion());
|
data.getStatistics().setMCVersion(Iris.instance.getMCVersion());
|
||||||
data.getStatistics().setUpgradedVersion(Iris.instance.getIrisVersion());
|
data.getStatistics().setIrisToUpgradedVersion(Iris.instance.getIrisVersion());
|
||||||
if (data.getStatistics().getVersion() == -1 || data.getStatistics().getMCVersion() == -1 ) {
|
if (data.getStatistics().getIrisCreationVersion() == -1 || data.getStatistics().getMCVersion() == -1 ) {
|
||||||
Iris.error("Failed to setup Engine Data!");
|
Iris.error("Failed to setup Engine Data!");
|
||||||
}
|
}
|
||||||
IO.writeAll(f, new Gson().toJson(data));
|
IO.writeAll(f, new Gson().toJson(data));
|
||||||
@@ -271,15 +278,43 @@ public class IrisEngine implements Engine {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveEngineData() {
|
||||||
|
//TODO: Method this file
|
||||||
|
if (dataLock.tryLock()) {
|
||||||
|
try {
|
||||||
|
File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + ".json");
|
||||||
|
f.getParentFile().mkdirs();
|
||||||
|
try {
|
||||||
|
getEngineData().addGeneratedChunk(chunks);
|
||||||
|
IO.writeAll(f, new Gson().toJson(getEngineData()));
|
||||||
|
Iris.debug("Saved Engine Data");
|
||||||
|
} catch (IOException e) {
|
||||||
|
Iris.error("Failed to save Engine Data");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
dataLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGenerated() {
|
public int getGenerated() {
|
||||||
return generated.get();
|
return generated.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addGenerated() {
|
public void addGenerated(int x, int z) {
|
||||||
if (generated.incrementAndGet() == 661) {
|
try {
|
||||||
J.a(() -> getData().savePrefetch(this));
|
File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + ".json");
|
||||||
|
chunks.add(x + "," + z);
|
||||||
|
if (generated.incrementAndGet() == 661) {
|
||||||
|
J.a(() -> getData().savePrefetch(this));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Iris.error("Failed to add generated chunk!");
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,7 +500,7 @@ public class IrisEngine implements Engine {
|
|||||||
|
|
||||||
getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true);
|
getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true);
|
||||||
getMetrics().getTotal().put(p.getMilliseconds());
|
getMetrics().getTotal().put(p.getMilliseconds());
|
||||||
addGenerated();
|
addGenerated(x,z);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
fail("Failed to generate " + x + ", " + z, e);
|
fail("Failed to generate " + x + ", " + z, e);
|
||||||
@@ -473,22 +508,13 @@ public class IrisEngine implements Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveEngineData() {
|
public void blockUpdatedMetric() {
|
||||||
//TODO: Method this file
|
bud.incrementAndGet();
|
||||||
File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + ".json");
|
|
||||||
f.getParentFile().mkdirs();
|
|
||||||
try {
|
|
||||||
IO.writeAll(f, new Gson().toJson(getEngineData()));
|
|
||||||
Iris.debug("Saved Engine Data");
|
|
||||||
} catch (IOException e) {
|
|
||||||
Iris.error("Failed to save Engine Data");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void blockUpdatedMetric() {
|
public boolean exists(int x, int z) {
|
||||||
bud.incrementAndGet();
|
return chunks.contains(x + "," + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -529,7 +555,7 @@ public class IrisEngine implements Engine {
|
|||||||
private boolean EngineSafe() {
|
private boolean EngineSafe() {
|
||||||
// Todo: this has potential if done right
|
// Todo: this has potential if done right
|
||||||
int EngineMCVersion = getEngineData().getStatistics().getMCVersion();
|
int EngineMCVersion = getEngineData().getStatistics().getMCVersion();
|
||||||
int EngineIrisVersion = getEngineData().getStatistics().getVersion();
|
int EngineIrisVersion = getEngineData().getStatistics().getIrisCreationVersion();
|
||||||
int MinecraftVersion = Iris.instance.getMCVersion();
|
int MinecraftVersion = Iris.instance.getMCVersion();
|
||||||
int IrisVersion = Iris.instance.getIrisVersion();
|
int IrisVersion = Iris.instance.getIrisVersion();
|
||||||
if (EngineIrisVersion != IrisVersion) {
|
if (EngineIrisVersion != IrisVersion) {
|
||||||
|
|||||||
@@ -266,6 +266,8 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
|||||||
|
|
||||||
void blockUpdatedMetric();
|
void blockUpdatedMetric();
|
||||||
|
|
||||||
|
boolean exists(int x, int z);
|
||||||
|
|
||||||
@ChunkCoordinates
|
@ChunkCoordinates
|
||||||
@Override
|
@Override
|
||||||
default void updateChunk(Chunk c) {
|
default void updateChunk(Chunk c) {
|
||||||
@@ -580,7 +582,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
|||||||
|
|
||||||
int getGenerated();
|
int getGenerated();
|
||||||
|
|
||||||
void addGenerated();
|
void addGenerated(int x, int z);
|
||||||
|
|
||||||
default <T> IrisPosition lookForStreamResult(T find, ProceduralStream<T> stream, Function2<T, T, Boolean> matcher, long timeout) {
|
default <T> IrisPosition lookForStreamResult(T find, ProceduralStream<T> stream, Function2<T, T, Boolean> matcher, long timeout) {
|
||||||
AtomicInteger checked = new AtomicInteger();
|
AtomicInteger checked = new AtomicInteger();
|
||||||
|
|||||||
@@ -23,13 +23,31 @@ import com.volmit.iris.engine.framework.Engine;
|
|||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class IrisEngineData {
|
public class IrisEngineData {
|
||||||
private IrisEngineStatistics statistics = new IrisEngineStatistics();
|
private IrisEngineStatistics statistics = new IrisEngineStatistics();
|
||||||
private KList<IrisEngineSpawnerCooldown> spawnerCooldowns = new KList<>();
|
private KList<IrisEngineSpawnerCooldown> spawnerCooldowns = new KList<>();
|
||||||
|
private Set<String> generatedChunks = ConcurrentHashMap.newKeySet();
|
||||||
private KList<IrisEngineChunkData> chunks = new KList<>();
|
private KList<IrisEngineChunkData> chunks = new KList<>();
|
||||||
private Long seed = null;
|
private Long seed = null;
|
||||||
|
|
||||||
|
public void addGeneratedChunk(int x, int z) {
|
||||||
|
getGeneratedChunks().add(x + "," + z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addGeneratedChunk(Set<String> chunks) {
|
||||||
|
chunks.forEach(getGeneratedChunks()::add);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isChunkGenerated(int x, int z) {
|
||||||
|
return getGeneratedChunks().contains(x + "," + z);
|
||||||
|
}
|
||||||
|
|
||||||
public void removeChunk(int x, int z) {
|
public void removeChunk(int x, int z) {
|
||||||
long k = Cache.key(x, z);
|
long k = Cache.key(x, z);
|
||||||
chunks.removeWhere((i) -> i.getChunk() == k);
|
chunks.removeWhere((i) -> i.getChunk() == k);
|
||||||
|
|||||||
@@ -20,41 +20,22 @@ package com.volmit.iris.engine.object;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class IrisEngineStatistics {
|
public class IrisEngineStatistics {
|
||||||
private int totalHotloads = 0;
|
private int totalHotloads = 0;
|
||||||
private int chunksGenerated = 0;
|
private int chunksGenerated = 0;
|
||||||
private int IrisToUpgradedVersion = 0;
|
private int IrisToUpgradedVersion = 0;
|
||||||
private int IrisCreationVersion = 0;
|
private int IrisCreationVersion = 0;
|
||||||
private int MinecraftVersion = 0;
|
private int MCVersion = 0;
|
||||||
|
|
||||||
public void generatedChunk() {
|
public void generatedChunk() {
|
||||||
chunksGenerated++;
|
chunksGenerated++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpgradedVersion(int i) {
|
|
||||||
IrisToUpgradedVersion = i;
|
|
||||||
}
|
|
||||||
public int getUpgradedVersion() {
|
|
||||||
return IrisToUpgradedVersion;
|
|
||||||
}
|
|
||||||
public void setVersion(int i) {
|
|
||||||
IrisCreationVersion = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getVersion() {
|
|
||||||
return IrisCreationVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMCVersion(int i) {
|
|
||||||
MinecraftVersion = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMCVersion() {
|
|
||||||
return MinecraftVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hotloaded() {
|
public void hotloaded() {
|
||||||
totalHotloads++;
|
totalHotloads++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,13 @@ public class Headless implements IHeadless, LevelHeightAccessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the mca plate is fully generated or not.
|
||||||
|
*
|
||||||
|
* @param x coord of the chunk
|
||||||
|
* @param z coord of the chunk
|
||||||
|
* @return true if the chunk exists in .mca
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean exists(int x, int z) {
|
public boolean exists(int x, int z) {
|
||||||
if (closed) return false;
|
if (closed) return false;
|
||||||
@@ -190,7 +197,7 @@ public class Headless implements IHeadless, LevelHeightAccessor {
|
|||||||
|
|
||||||
engine.getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true);
|
engine.getMantle().getMantle().flag(x >> 4, z >> 4, MantleFlag.REAL, true);
|
||||||
engine.getMetrics().getTotal().put(p.getMilliseconds());
|
engine.getMetrics().getTotal().put(p.getMilliseconds());
|
||||||
engine.addGenerated();
|
engine.addGenerated(x,z);
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
|
|||||||
@@ -757,6 +757,7 @@ public class NMSBinding implements INMSBinding {
|
|||||||
public void injectBukkit() {
|
public void injectBukkit() {
|
||||||
try {
|
try {
|
||||||
Iris.info("Injecting Bukkit");
|
Iris.info("Injecting Bukkit");
|
||||||
|
|
||||||
new ByteBuddy()
|
new ByteBuddy()
|
||||||
.redefine(CraftServer.class)
|
.redefine(CraftServer.class)
|
||||||
.visit(Advice.to(CraftServerAdvice.class).on(ElementMatchers.isMethod().and(ElementMatchers.takesArguments(WorldCreator.class))))
|
.visit(Advice.to(CraftServerAdvice.class).on(ElementMatchers.isMethod().and(ElementMatchers.takesArguments(WorldCreator.class))))
|
||||||
|
|||||||
Reference in New Issue
Block a user