mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 18:55:18 +00:00
Allow reading region chunks without loading mca
This commit is contained in:
parent
ec4330aea7
commit
60c113b0e8
@ -19,6 +19,9 @@
|
|||||||
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.math.Position2;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
@ -88,6 +91,27 @@ public class MCAFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KList<Position2> samplePositions(RandomAccessFile raf) throws IOException {
|
||||||
|
KList<Position2> p2 = new KList<>();
|
||||||
|
chunks = new AtomicReferenceArray<>(1024);
|
||||||
|
int x = 0;
|
||||||
|
int z = 0;
|
||||||
|
for (int i = 0; i < 1024; i++) {
|
||||||
|
x++;
|
||||||
|
z++;
|
||||||
|
|
||||||
|
raf.seek(i * 4);
|
||||||
|
int offset = raf.read() << 16;
|
||||||
|
offset |= (raf.read() & 0xFF) << 8;
|
||||||
|
offset |= raf.read() & 0xFF;
|
||||||
|
if (raf.readByte() == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
p2.add(new Position2(x & 31, (z / 32) & 31));
|
||||||
|
}
|
||||||
|
return p2;
|
||||||
|
}
|
||||||
|
|
||||||
public AtomicReferenceArray<Chunk> getChunks() {
|
public AtomicReferenceArray<Chunk> getChunks() {
|
||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.data.mca;
|
package com.volmit.iris.engine.data.mca;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.collection.KList;
|
||||||
|
import com.volmit.iris.util.math.Position2;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
@ -83,6 +86,13 @@ public final class MCAUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static KList<Position2> sampleChunkPositions(File file) throws IOException {
|
||||||
|
MCAFile mcaFile = newMCAFile(file);
|
||||||
|
try (RandomAccessFile raf = new RandomAccessFile(file, "r")) {
|
||||||
|
return mcaFile.samplePositions(raf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls {@link MCAUtil#write(MCAFile, File, boolean)} without changing the timestamps.
|
* Calls {@link MCAUtil#write(MCAFile, File, boolean)} without changing the timestamps.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user