mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Platform with exclusive for hotloading & closing
This commit is contained in:
parent
6343b7087d
commit
f3ece64635
@ -180,7 +180,6 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hotload() {
|
public void hotload() {
|
||||||
Iris.info("Hotload ENGINE");
|
|
||||||
getData().dump();
|
getData().dump();
|
||||||
getData().clearLists();
|
getData().clearLists();
|
||||||
getTarget().setDimension(getData().getDimensionLoader().load(getDimension().getLoadKey()));
|
getTarget().setDimension(getData().getDimensionLoader().load(getDimension().getLoadKey()));
|
||||||
|
@ -31,6 +31,7 @@ import com.volmit.iris.util.collection.KList;
|
|||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.io.ReactiveFolder;
|
import com.volmit.iris.util.io.ReactiveFolder;
|
||||||
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.Looper;
|
import com.volmit.iris.util.scheduling.Looper;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -99,8 +100,10 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
|
withExclusiveControl(() -> {
|
||||||
hotloader.interrupt();
|
hotloader.interrupt();
|
||||||
getEngine().close();
|
getEngine().close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -110,24 +113,40 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hotload() {
|
public void hotload() {
|
||||||
getEngine().hotload();
|
withExclusiveControl(() -> getEngine().hotload());
|
||||||
Iris.info("Hotload BKG");
|
}
|
||||||
|
|
||||||
|
public void withExclusiveControl(Runnable r)
|
||||||
|
{
|
||||||
|
J.a(() -> {
|
||||||
|
try {
|
||||||
|
loadLock.acquire(LOAD_LOCKS);
|
||||||
|
r.run();
|
||||||
|
loadLock.release(LOAD_LOCKS);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
|
public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random ignored, int x, int z, @NotNull BiomeGrid biome) {
|
||||||
try {
|
try {
|
||||||
Iris.debug("Generated " + x + " " + z);
|
loadLock.acquire();
|
||||||
PrecisionStopwatch ps = PrecisionStopwatch.start();
|
PrecisionStopwatch ps = PrecisionStopwatch.start();
|
||||||
TerrainChunk tc = TerrainChunk.create(world, biome);
|
TerrainChunk tc = TerrainChunk.create(world, biome);
|
||||||
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
||||||
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
||||||
this.world.bind(world);
|
this.world.bind(world);
|
||||||
getEngine().generate(x * 16, z * 16, blocks, biomes, true);
|
getEngine().generate(x * 16, z * 16, blocks, biomes, true);
|
||||||
return tc.getRaw();
|
ChunkData c = tc.getRaw();
|
||||||
|
Iris.debug("Generated " + x + " " + z);
|
||||||
|
loadLock.release();
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Throwable e) {
|
catch (Throwable e) {
|
||||||
|
loadLock.release();
|
||||||
Iris.error("======================================");
|
Iris.error("======================================");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Iris.reportErrorChunk(x, z, e, "CHUNK");
|
Iris.reportErrorChunk(x, z, e, "CHUNK");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user