Auto stash before revert of "Drop it "

This commit is contained in:
cyberpwn
2021-09-22 12:54:06 -04:00
parent 3ba7c18288
commit f9e934fa1a
19 changed files with 376 additions and 125 deletions

View File

@@ -18,12 +18,15 @@
package com.volmit.iris.util.nbt.mca;
import com.volmit.iris.core.pregenerator.syndicate.SyndicateServer;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.scheduling.J;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicReferenceArray;
@SuppressWarnings("ALL")
@@ -37,6 +40,7 @@ public class MCAFile {
private final int regionX;
private final int regionZ;
private AtomicReferenceArray<Chunk> chunks;
private ConcurrentLinkedQueue<Runnable> afterSave;
/**
* MCAFile represents a world save file used by Minecraft to store world
@@ -50,6 +54,7 @@ public class MCAFile {
public MCAFile(int regionX, int regionZ) {
this.regionX = regionX;
this.regionZ = regionZ;
afterSave = new ConcurrentLinkedQueue<>();
}
/**
@@ -198,6 +203,11 @@ public class MCAFile {
raf.seek(globalOffset * 4096L - 1);
raf.write(0);
}
J.a(() -> {
afterSave.forEach(i -> i.run());
}, 20);
return chunksWritten;
}
@@ -326,4 +336,8 @@ public class MCAFile {
}
return chunk.getBlockStateAt(blockX, blockY, blockZ);
}
public void afterSave(Runnable o) {
afterSave.add(o);
}
}

View File

@@ -329,4 +329,8 @@ public class NBTWorld {
public int size() {
return loadedRegions.size();
}
public boolean isLoaded(int x, int z) {
return loadedRegions.containsKey(Cache.key(x, z));
}
}