Made McRegion reading work.

Dieser Commit ist enthalten in:
sk89q 2011-03-09 23:44:04 -08:00
Ursprung 5e7d9c7f7d
Commit 96e75a4cae
3 geänderte Dateien mit 7 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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);