本文整理汇总了Python中bravo.chunk.Chunk.sed方法的典型用法代码示例。如果您正苦于以下问题:Python Chunk.sed方法的具体用法?Python Chunk.sed怎么用?Python Chunk.sed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bravo.chunk.Chunk
的用法示例。
在下文中一共展示了Chunk.sed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestChunkBlocks
# 需要导入模块: from bravo.chunk import Chunk [as 别名]
# 或者: from bravo.chunk.Chunk import sed [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)
示例2: TestChunkBlocks
# 需要导入模块: from bravo.chunk import Chunk [as 别名]
# 或者: from bravo.chunk.Chunk import sed [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)