Made McRegion reading work.

This commit is contained in:
sk89q 2011-03-09 23:44:04 -08:00
parent 5e7d9c7f7d
commit 96e75a4cae
3 changed files with 7 additions and 4 deletions

View File

@ -60,7 +60,9 @@ public class ForwardSeekableInputStream extends InputStream {
@Override
public int read(byte[] b, int off, int len) throws IOException {
throw new IOException("Offset not supported for read()");
int read = super.read(b, off, len);
position += read;
return read;
}
@Override

View File

@ -48,11 +48,12 @@ public abstract class McRegionChunkStore extends ChunkStore {
protected McRegionReader getReader(Vector2D pos) throws DataException, IOException {
String filename = getFilename(pos);
if (curFilename.equals(filename)) {
if (curFilename != null && curFilename.equals(filename)) {
return cachedReader;
}
InputStream stream = getInputStream(filename);
cachedReader = new McRegionReader(stream);
//curFilename = filename;
return cachedReader;
}

View File

@ -117,8 +117,8 @@ public class McRegionReader {
public synchronized InputStream getChunkInputStream(Vector2D pos)
throws IOException, DataException {
int x = pos.getBlockX();
int z = pos.getBlockZ();
int x = pos.getBlockX() & 31;
int z = pos.getBlockZ() & 31;
if (x < 0 || x >= 32 || z < 0 || z >= 32) {
throw new DataException("MCRegion file does not contain " + x + "," + z);