Exemplo n.º 1
0
    def test_multi_command_structure(self):
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = []

        class MockStructure(Structure):
            def generate_build(self, ):
                self._add_command(
                    clone(Position(0, 0, 0), Position(1, 1, 1),
                          Position(2, 0, 2)))
                self._add_command(
                    clone(Position(0, 0, 0), Position(1, 1, 1),
                          Position(2, 0, 2)))
                self._add_command(
                    clone(Position(0, 0, 0), Position(1, 1, 1),
                          Position(2, 0, 2)))
                self._add_command(
                    clone(Position(0, 0, 0), Position(1, 1, 1),
                          Position(2, 0, 2)))
                self._add_command(
                    clone(Position(0, 0, 0), Position(1, 1, 1),
                          Position(2, 0, 2)))
                self._add_command(
                    clone(Position(0, 0, 0), Position(1, 1, 1),
                          Position(2, 0, 2)))

            def register_arguments(self):
                return []

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(len(commands), 6)
Exemplo n.º 2
0
    def test_generate_clone_with_rotate_90(self):
        '''This clone selects a quad from 0,0,0 to 1,1,1 and clones it to 2,0,2
		This whole selection is then rotated 90* clockwise.
		The positions in the clone command is going to change when rotating 
		to ensure the first position is always lower on the x-z coords than the second position.
		This test ensures this rule is respected.'''

        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [1, 1, 1, 1]

        class MockStructure(Structure):
            def generate_build(self, length, width, height, rotation):
                self._add_command(
                    clone(Position(0, 0, 0), Position(width, height, length),
                          Position(width + 1, 0, length + 1)))
                self._rotate(rotation)

            def register_arguments(self):
                return [
                    Argument("Length", "The length of the structure"),
                    Argument("Width", "The width of the structure"),
                    Argument("Height", "The height of the structure"),
                    Argument("Rotation", "The rotation of the structure"),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(commands, ["clone ~-1 ~0 ~0 ~0 ~1 ~1 ~-3 ~0 ~2"])
Exemplo n.º 3
0
    def test_setblock_with_redstone_torch_and_rotate_270(self):
        '''assuming the player is facing east (+x), placing a torch on the wall in front of them will cause it to point west (-x)'''
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [0, 0, 0, 3]

        class MockStructure(Structure):
            def generate_build(self, pos_x, pos_y, pos_z, rotation):
                self._add_command(
                    setblock(Position(pos_x, pos_y, pos_z),
                             redstone_torch('-x')))
                self._rotate(rotation)

            def register_arguments(self):
                return [
                    Argument("PosX", "The X position of the block"),
                    Argument("PosY", "The Y position of the block"),
                    Argument("PosZ", "The Z position of the block"),
                    Argument("Rotation", ""),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(
            commands,
            ["setblock ~0 ~0 ~0 minecraft:redstone_wall_torch[facing=south]"])
Exemplo n.º 4
0
    def test_generate_fill_with_rotate_270(self):
        '''This fill selects a quad from 0,0,0 to 1,1,1
		This whole selection is then rotated 270* clockwise.
		The positions in the fill command are going to change when rotating 
		to ensure the first position is always lower on the x-z coords than the second position.
		This test ensures this rule is respected.'''
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [1, 1, 1, 3]

        class MockStructure(Structure):
            def generate_build(self, length, width, height, rotation):
                self._add_command(
                    fill(Position(0, 0, 0), Position(width, height, length),
                         base_block()))
                self._rotate(rotation)

            def register_arguments(self):
                return [
                    Argument("Length", "The length of the structure"),
                    Argument("Width", "The width of the structure"),
                    Argument("Height", "The height of the structure"),
                    Argument("Rotation", "The rotation of the structure"),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(commands,
                         ["fill ~0 ~0 ~-1 ~1 ~1 ~0 minecraft:iron_block"])
Exemplo n.º 5
0
    def test_generate_clone_with_different_argument_handler(self):
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [18, 99, 50]

        class MockStructure(Structure):
            def generate_build(self, length, width, height):
                self._add_command(
                    clone(Position(0, 0, 0), Position(length, height, width),
                          Position(length + 1, 0, width + 1)))

            def register_arguments(self):
                return [
                    Argument("Length", "The length of the structure"),
                    Argument("Width", "The width of the structure"),
                    Argument("Height", "The height of the structure"),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(commands, ["clone ~0 ~0 ~0 ~18 ~50 ~99 ~19 ~0 ~100"])
Exemplo n.º 6
0
    def test_setblock_with_redstone_dust(self):
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [23, 17, 77]

        class MockStructure(Structure):
            def generate_build(self, pos_x, pos_y, pos_z):
                self._add_command(
                    setblock(Position(pos_x, pos_y, pos_z), redstone_dust()))

            def register_arguments(self):
                return [
                    Argument("PosX", "The X position of the block"),
                    Argument("PosY", "The Y position of the block"),
                    Argument("PosZ", "The Z position of the block"),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(commands,
                         ["setblock ~23 ~17 ~77 minecraft:redstone_wire"])
Exemplo n.º 7
0
    def test_setblock_with_base_block_and_translate(self):
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [10, 18, 15]

        class MockStructure(Structure):
            def generate_build(self, pos_x, pos_y, pos_z):
                self._add_command(setblock(Position(0, 0, 0), base_block()))
                self._translate(pos_x, pos_y, pos_z)

            def register_arguments(self):
                return [
                    Argument("PosX", "The X position of the block"),
                    Argument("PosY", "The Y position of the block"),
                    Argument("PosZ", "The Z position of the block"),
                    Argument("Rotation", ""),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(commands,
                         ["setblock ~10 ~18 ~15 minecraft:iron_block"])
Exemplo n.º 8
0
    def test_setblock_with_repeater(self):
        '''assuming the player is facing east (+x), placing a repeater on the ground in front of them will cause its output to point east (+x) and its input to point west (-x)'''
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [23, 17, 77]

        class MockStructure(Structure):
            def generate_build(self, pos_x, pos_y, pos_z):
                self._add_command(
                    setblock(Position(pos_x, pos_y, pos_z), repeater('+x')))

            def register_arguments(self):
                return [
                    Argument("PosX", "The X position of the block"),
                    Argument("PosY", "The Y position of the block"),
                    Argument("PosZ", "The Z position of the block"),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(
            commands, ["setblock ~23 ~17 ~77 minecraft:repeater[facing=west]"])
Exemplo n.º 9
0
    def test_generate_fill(self):
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [23, 17, 99]

        class MockStructure(Structure):
            def generate_build(self, length, width, height):
                self._add_command(
                    fill(Position(0, 0, 0), Position(width, height, length),
                         base_block()))

            def register_arguments(self):
                return [
                    Argument("Length", "The length of the structure"),
                    Argument("Width", "The width of the structure"),
                    Argument("Height", "The height of the structure"),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(commands,
                         ["fill ~0 ~0 ~0 ~17 ~99 ~23 minecraft:iron_block"])
Exemplo n.º 10
0
    def test_setblock_with_base_block_and_rotate_270(self):
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [23, 17, 77, 3]

        class MockStructure(Structure):
            def generate_build(self, pos_x, pos_y, pos_z, rotation):
                self._add_command(
                    setblock(Position(pos_x, pos_y, pos_z), base_block()))
                self._rotate(rotation)

            def register_arguments(self):
                return [
                    Argument("PosX", "The X position of the block"),
                    Argument("PosY", "The Y position of the block"),
                    Argument("PosZ", "The Z position of the block"),
                    Argument("Rotation", ""),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(commands,
                         ["setblock ~77 ~17 ~-23 minecraft:iron_block"])
Exemplo n.º 11
0
    def test_clone_and_translate(self):
        argument_handler = ArgumentHandler()
        argument_handler.handle = Mock()
        argument_handler.handle.return_value = [10, 18, 15]

        class MockStructure(Structure):
            def generate_build(self, pos_x, pos_y, pos_z):
                self._add_command(
                    clone(Position(0, 0, 0), Position(1, 1, 1),
                          Position(2, 0, 2)))
                self._translate(pos_x, pos_y, pos_z)

            def register_arguments(self):
                return [
                    Argument("PosX", "The X position of the block"),
                    Argument("PosY", "The Y position of the block"),
                    Argument("PosZ", "The Z position of the block"),
                    Argument("Rotation", ""),
                ]

        commands = generate(MockStructure(), argument_handler)
        self.assertEqual(commands,
                         ["clone ~10 ~18 ~15 ~11 ~19 ~16 ~12 ~18 ~17"])