better chunk saving and loading

This commit is contained in:
Leijurv 2018-08-28 11:28:36 -07:00
parent c0fb57825c
commit c761a9b127
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,4 @@
package baritone.behavior.impl;
public class MineBehavior {
}

View File

@ -117,8 +117,8 @@ public final class CachedRegion implements IBlockTypeAccess {
Files.createFile(regionFile);
try (
FileOutputStream fileOut = new FileOutputStream(regionFile.toFile());
GZIPOutputStream gzipOut = new GZIPOutputStream(fileOut);
DataOutputStream out = new DataOutputStream(gzipOut);
GZIPOutputStream gzipOut = new GZIPOutputStream(fileOut, 16384);
DataOutputStream out = new DataOutputStream(gzipOut)
) {
out.writeInt(CACHED_REGION_MAGIC);
for (int z = 0; z < 32; z++) {
@ -183,8 +183,8 @@ public final class CachedRegion implements IBlockTypeAccess {
try (
FileInputStream fileIn = new FileInputStream(regionFile.toFile());
GZIPInputStream gzipIn = new GZIPInputStream(fileIn);
DataInputStream in = new DataInputStream(gzipIn);
GZIPInputStream gzipIn = new GZIPInputStream(fileIn, 32768);
DataInputStream in = new DataInputStream(gzipIn)
) {
int magic = in.readInt();
if (magic != CACHED_REGION_MAGIC) {

View File

@ -69,6 +69,7 @@ public final class CachedWorld implements IBlockTypeAccess {
new Thread() {
public void run() {
try {
Thread.sleep(30000);
while (true) {
// since a region only saves if it's been modified since its last save
// saving every 10 minutes means that once it's time to exit
@ -141,7 +142,7 @@ public final class CachedWorld implements IBlockTypeAccess {
return;
}
long start = System.currentTimeMillis();
this.cachedRegions.values().forEach(region -> {
this.cachedRegions.values().parallelStream().forEach(region -> {
if (region != null)
region.save(this.directory);
});