當前位置: 首頁>>代碼示例>>Python>>正文


Python Chunk.set_metadata方法代碼示例

本文整理匯總了Python中bravo.chunk.Chunk.set_metadata方法的典型用法代碼示例。如果您正苦於以下問題:Python Chunk.set_metadata方法的具體用法?Python Chunk.set_metadata怎麽用?Python Chunk.set_metadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bravo.chunk.Chunk的用法示例。


在下文中一共展示了Chunk.set_metadata方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_single_block_damage_packet

# 需要導入模塊: from bravo.chunk import Chunk [as 別名]
# 或者: from bravo.chunk.Chunk import set_metadata [as 別名]
 def test_single_block_damage_packet(self):
     chunk = Chunk(2, 1)
     chunk.populated = True
     chunk.set_block((2, 4, 8), 1)
     chunk.set_metadata((2, 4, 8), 2)
     packet = chunk.get_damage_packet()
     self.assertEqual(packet, '\x35\x00\x00\x00\x22\x04\x00\x00\x00\x18\x01\x02')
開發者ID:miea,項目名稱:bravo,代碼行數:9,代碼來源:test_chunk.py

示例2: TestChunkBlocks

# 需要導入模塊: from bravo.chunk import Chunk [as 別名]
# 或者: from bravo.chunk.Chunk import set_metadata [as 別名]
class TestChunkBlocks(unittest.TestCase):

    def setUp(self):
        self.c = Chunk(0, 0)

    def test_trivial(self):
        pass

    def test_set_block(self):
        self.assertEqual(self.c.blocks[0], 0)
        self.c.set_block((0, 0, 0), 1)
        self.assertEqual(self.c.blocks[0], 1)

    def test_set_block_xyz_xzy(self):
        """
        Test that set_block swizzles correctly.
        """

        self.c.set_block((1, 0, 0), 1)
        self.c.set_block((0, 1, 0), 2)
        self.c.set_block((0, 0, 1), 3)
        self.assertEqual(self.c.blocks[2048], 1)
        self.assertEqual(self.c.blocks[1], 2)
        self.assertEqual(self.c.blocks[128], 3)

    def test_destroy(self):
        """
        Test block destruction.
        """

        self.c.set_block((0, 0, 0), 1)
        self.c.set_metadata((0, 0, 0), 1)
        self.c.destroy((0, 0, 0))
        self.assertEqual(self.c.blocks[0], 0)
        self.assertEqual(self.c.metadata[0], 0)

    def test_sed(self):
        """
        ``sed()`` should work.
        """

        self.c.set_block((1, 1, 1), 1)
        self.c.set_block((2, 2, 2), 2)
        self.c.set_block((3, 3, 3), 3)

        self.c.sed(1, 3)

        self.assertEqual(self.c.get_block((1, 1, 1)), 3)
        self.assertEqual(self.c.get_block((2, 2, 2)), 2)
        self.assertEqual(self.c.get_block((3, 3, 3)), 3)

    def test_single_block_damage_packet(self):
        chunk = Chunk(2, 1)
        chunk.populated = True
        chunk.set_block((2, 4, 8), 1)
        chunk.set_metadata((2, 4, 8), 2)
        packet = chunk.get_damage_packet()
        self.assertEqual(packet, '\x35\x00\x00\x00\x22\x04\x00\x00\x00\x18\x01\x02')

    def test_set_block_correct_heightmap(self):
        """
        Test heightmap update for a single column.
        """

        self.c.populated = True

        self.assertEqual(self.c.heightmap[0], 0)
        self.c.set_block((0, 20, 0), 1)
        self.assertEqual(self.c.heightmap[0], 20)

        self.c.set_block((0, 10, 0), 1)
        self.assertEqual(self.c.heightmap[0], 20)

        self.c.set_block((0, 30, 0), 1)
        self.assertEqual(self.c.heightmap[0], 30)

        self.c.destroy((0, 10, 0))
        self.assertEqual(self.c.heightmap[0], 30)

        self.c.destroy((0, 30, 0))
        self.assertEqual(self.c.heightmap[0], 20)
開發者ID:miea,項目名稱:bravo,代碼行數:83,代碼來源:test_chunk.py

示例3: TestChunkBlocks

# 需要導入模塊: from bravo.chunk import Chunk [as 別名]
# 或者: from bravo.chunk.Chunk import set_metadata [as 別名]
class TestChunkBlocks(unittest.TestCase):

    def setUp(self):
        self.c = Chunk(0, 0)

    def test_trivial(self):
        pass

    def test_destroy(self):
        """
        Test block destruction.
        """

        self.c.set_block((0, 0, 0), 1)
        self.c.set_metadata((0, 0, 0), 1)
        self.c.destroy((0, 0, 0))
        self.assertEqual(self.c.get_block((0, 0, 0)), 0)
        self.assertEqual(self.c.get_metadata((0, 0, 0)), 0)

    def test_sed(self):
        """
        ``sed()`` should work.
        """

        self.c.set_block((1, 1, 1), 1)
        self.c.set_block((2, 2, 2), 2)
        self.c.set_block((3, 3, 3), 3)

        self.c.sed(1, 3)

        self.assertEqual(self.c.get_block((1, 1, 1)), 3)
        self.assertEqual(self.c.get_block((2, 2, 2)), 2)
        self.assertEqual(self.c.get_block((3, 3, 3)), 3)

    def test_set_block_heightmap(self):
        """
        Heightmaps work.
        """

        self.c.populated = True

        self.c.set_block((0, 20, 0), 1)
        self.assertEqual(self.c.heightmap[0], 20)

    def test_set_block_heightmap_underneath(self):
        """
        A block placed underneath the highest block will not alter the
        heightmap.
        """

        self.c.populated = True

        self.c.set_block((0, 20, 0), 1)
        self.assertEqual(self.c.heightmap[0], 20)

        self.c.set_block((0, 10, 0), 1)
        self.assertEqual(self.c.heightmap[0], 20)

    def test_set_block_heightmap_destroyed(self):
        """
        Upon destruction of the highest block, the heightmap will point at the
        next-highest block.
        """

        self.c.populated = True

        self.c.set_block((0, 30, 0), 1)
        self.c.set_block((0, 10, 0), 1)
        self.c.destroy((0, 30, 0))
        self.assertEqual(self.c.heightmap[0], 10)
開發者ID:MartysTardis,項目名稱:bravo,代碼行數:72,代碼來源:test_chunk.py


注:本文中的bravo.chunk.Chunk.set_metadata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。