diff --git a/textures.py b/textures.py index fd199e4..f19c5c3 100644 --- a/textures.py +++ b/textures.py @@ -878,14 +878,17 @@ def getBiomeData(worlddir, chunkX, chunkY): if biomeFile == currentBiomeFile: return currentBiomeData - currentBiomeFile = biomeFile - f = open(os.path.join(worlddir, "biomes", biomeFile), "rb") rawdata = f.read() f.close() - + + # make sure the file size is correct + if not len(rawdata) == 512 * 512 * 2: + raise Exception("Biome file %s is not valid." % (biomeFile,)) + data = numpy.frombuffer(rawdata, dtype=numpy.dtype(">u2")) + currentBiomeFile = biomeFile currentBiomeData = data return data