def testCopyConvertBlocks(self):
        indevlevel = self.indevLevel.level
        level = self.anvilLevel.level
        x, y, z = level.bounds.origin
        x += level.bounds.size[0] / 2 & ~15
        z += level.bounds.size[2] / 2 & ~15
        x -= indevlevel.Width / 2
        z -= indevlevel.Height / 2

        middle = (x, y, z)

        oldEntityCount = len(
            level.getEntitiesInBox(BoundingBox(middle,
                                               indevlevel.bounds.size)))
        level.copyBlocksFrom(indevlevel, indevlevel.bounds, middle)

        convertedSourceBlocks, convertedSourceData = block_copy.convertBlocks(
            indevlevel, level, indevlevel.Blocks[0:16, 0:16,
                                                 0:indevlevel.Height],
            indevlevel.Data[0:16, 0:16, 0:indevlevel.Height])

        assert ((level.getChunk(
            x >> 4, z >>
            4).Blocks[0:16, 0:16,
                      0:indevlevel.Height] == convertedSourceBlocks).all())

        assert (oldEntityCount +
                len(indevlevel.getEntitiesInBox(indevlevel.bounds)) == len(
                    level.getEntitiesInBox(
                        BoundingBox(middle, indevlevel.bounds.size))))
Exemplo n.º 2
0
    def testCopyConvertBlocks(self):
        indevlevel = self.indevLevel.level
        level = self.anvilLevel.level
        x, y, z = level.bounds.origin
        x += level.bounds.size[0] / 2 & ~15
        z += level.bounds.size[2] / 2 & ~15
        x -= indevlevel.Width / 2
        z -= indevlevel.Height / 2

        middle = (x, y, z)

        oldEntityCount = len(level.getEntitiesInBox(BoundingBox(middle, indevlevel.bounds.size)))
        level.copyBlocksFrom(indevlevel, indevlevel.bounds, middle)

        convertedSourceBlocks, convertedSourceData = block_copy.convertBlocks(indevlevel, level,
                                                                              indevlevel.Blocks[0:16, 0:16,
                                                                              0:indevlevel.Height],
                                                                              indevlevel.Data[0:16, 0:16,
                                                                              0:indevlevel.Height])

        assert ((level.getChunk(x >> 4, z >> 4).Blocks[0:16, 0:16, 0:indevlevel.Height]
                 == convertedSourceBlocks).all())

        assert (oldEntityCount + len(indevlevel.getEntitiesInBox(indevlevel.bounds))
                == len(level.getEntitiesInBox(BoundingBox(middle, indevlevel.bounds.size))))
Exemplo n.º 3
0
    def testImportSchematic(self):
        level = self.anvilLevel.level
        cx, cz = level.allChunks.next()

        schem = mclevel.fromFile("schematics/CreativeInABox.schematic")
        box = BoundingBox((cx * 16, 64, cz * 16), schem.bounds.size)
        level.copyBlocksFrom(schem, schem.bounds, (0, 64, 0))
        schem = MCSchematic(shape=schem.bounds.size)
        schem.copyBlocksFrom(level, box, (0, 0, 0))
        convertedSourceBlocks, convertedSourceData = block_copy.convertBlocks(schem, level, schem.Blocks, schem.Data)
        assert (level.getChunk(cx, cz).Blocks[0:1, 0:3, 64:65] == convertedSourceBlocks).all()
    def testImportSchematic(self):
        level = self.anvilLevel.level
        cx, cz = level.allChunks.next()

        schem = mclevel.fromFile("schematics/CreativeInABox.schematic")
        box = BoundingBox((cx * 16, 64, cz * 16), schem.bounds.size)
        level.copyBlocksFrom(schem, schem.bounds, (0, 64, 0))
        schem = MCSchematic(shape=schem.bounds.size)
        schem.copyBlocksFrom(level, box, (0, 0, 0))
        convertedSourceBlocks, convertedSourceData = block_copy.convertBlocks(
            schem, level, schem.Blocks, schem.Data)
        assert (level.getChunk(
            cx, cz).Blocks[0:1, 0:3, 64:65] == convertedSourceBlocks).all()