示例#1
0
def testBigEndianIntHeightMap():
    """ Test modifying, saving, and loading the new TAG_Int_Array heightmap
    added with the Anvil format.
    """
    region = RegionFile(TempFile("AnvilWorld/region/r.0.0.mca"))
    chunk_data = region.readChunkBytes(0, 0)
    chunk = nbt.load(buf=chunk_data)

    hm = chunk["Level"]["HeightMap"]
    hm.value[2] = 500
    oldhm = numpy.array(hm.value)

    filename = mktemp("ChangedChunk")
    chunk.save(filename)
    changedChunk = nbt.load(filename)
    os.unlink(filename)

    eq = (changedChunk["Level"]["HeightMap"].value == oldhm)
    assert eq.all()
示例#2
0
def testBigEndianIntHeightMap():
    """ Test modifying, saving, and loading the new TAG_Int_Array heightmap
    added with the Anvil format.
    """
    region = RegionFile(TempFile("AnvilWorld/region/r.0.0.mca"))
    chunk_data = region.readChunkBytes(0, 0)
    chunk = nbt.load(buf=chunk_data)

    hm = chunk["Level"]["HeightMap"]
    hm.value[2] = 500
    oldhm = numpy.array(hm.value)

    filename = mktemp("ChangedChunk")
    chunk.save(filename)
    changedChunk = nbt.load(filename)
    os.unlink(filename)

    eq = (changedChunk["Level"]["HeightMap"].value == oldhm)
    assert eq.all()
示例#3
0
def testBigEndianIntHeightMap(tmpdir, temp_file):
    """ Test modifying, saving, and loading the new TAG_Int_Array heightmap
    added with the Anvil format.
    """
    region = RegionFile(temp_file.strpath)
    chunk_data = region.readChunkBytes(0, 0)
    chunk = nbt.load(buf=chunk_data)

    hm = chunk["Level"]["HeightMap"]
    hm.value[2] = 500
    oldhm = numpy.array(hm.value)

    filename = tmpdir.join("ChangedChunk").strpath
    chunk.save(filename)
    changedChunk = nbt.load(filename)
    os.unlink(filename)

    eq = (changedChunk["Level"]["HeightMap"].value == oldhm)
    assert eq.all()
示例#4
0
def testBigEndianIntHeightMap(tmpdir, temp_file):
    """ Test modifying, saving, and loading the new TAG_Int_Array heightmap
    added with the Anvil format.
    """
    region = RegionFile(temp_file.strpath)
    chunk_data = region.readChunkBytes(0, 0)
    chunk = nbt.load(buf=chunk_data)

    hm = chunk["Level"]["HeightMap"]
    hm.value[2] = 500
    oldhm = numpy.array(hm.value)

    filename = tmpdir.join("ChangedChunk").strpath
    chunk.save(filename)
    changedChunk = nbt.load(filename)
    os.unlink(filename)

    eq = (changedChunk["Level"]["HeightMap"].value == oldhm)
    assert eq.all()
示例#5
0
    def getRegionFile(self, rx, rz, dimName):
        """

        :type rx: int or dtype
        :type rz: int or dtype
        :type dimName: unicode or str
        :return:
        :rtype: RegionFile
        """
        regionFile = self.regionFiles.get((rx, rz, dimName))
        if regionFile:
            return regionFile
        path = self.getRegionFilename(rx, rz, dimName)
        if not os.path.exists(path):
            self._dimensionNames.add(dimName)
            self._regionPositionsByDim[dimName].add((rx, rz))
        regionFile = RegionFile(path)
        self.regionFiles[rx, rz, dimName] = regionFile
        return regionFile
示例#6
0
    def getRegionFile(self, rx, rz, dimName):
        """

        :type rx: int or dtype
        :type rz: int or dtype
        :type dimName: unicode or str
        :return:
        :rtype: RegionFile
        """
        regionFile = self.regionFiles.get((rx, rz, dimName))
        if regionFile:
            return regionFile
        path = self.getRegionFilename(rx, rz, dimName)
        if not os.path.exists(path):
            self._dimensionNames.add(dimName)
            self._regionPositionsByDim[dimName].add((rx, rz))
        try:
            regionFile = RegionFile(path, self.readonly)
        except Exception:
            log.exception("Failed to open region file.")
            return None
        self.regionFiles[rx, rz, dimName] = regionFile
        return regionFile