protected function buildBlock(Block $block, array $startingCoordinates) { $relativeCoordinates = $block->getCoordinates(); // sum the coordinates $blockCoordinates = ['x' => $relativeCoordinates['x'] + $startingCoordinates['x'], 'y' => $relativeCoordinates['y'] + $startingCoordinates['y'], 'z' => $relativeCoordinates['z'] + $startingCoordinates['z']]; $this->commander->setBlock($block->getType(), $blockCoordinates, $block->getMeta()); }
/** * @param gries\MControl\Server\Commander $commander * @param gries\MControl\Storage\BlockType\BlockTypeRepository $repo */ function it_bruteforces_the_type_is_not_detected(Commander $commander, BlockTypeRepository $repo) { $dummyBlockType = new BlockType(array('name' => 'air')); $plankType = new BlockType(array('name' => 'minecraft:planks', 'title' => 'Wooden Planks')); $expectedType = new BlockType(array('name' => 'minecraft:planks', 'title' => 'Wooden Planks', 'meta' => 0)); $airBlockType = $dummyBlockType; $ironBlockType = new BlockType(array('name' => 'minecraft:iron_ore')); $coordinates = array('x' => 1, 'y' => 1, 'z' => 1); $commander->testForBlock($coordinates, $dummyBlockType)->shouldBeCalled()->willReturn('Wooden Planks'); $repo->getByName('minecraft:air')->shouldBeCalled()->willReturn($dummyBlockType); $repo->getByName('Wooden Planks')->shouldBeCalled()->willReturn(null); $repo->getByTitle('Wooden Planks')->shouldBeCalled()->willReturn(null); $repo->getAll()->shouldBeCalled()->willReturn(array($airBlockType, $ironBlockType, $plankType)); $commander->testForBlock($coordinates, $airBlockType)->shouldBeCalled()->willReturn('Wooden Planks'); $commander->testForBlock($coordinates, $ironBlockType)->shouldBeCalled()->willReturn('Wooden Planks'); $commander->testForBlock($coordinates, $plankType)->shouldBeCalled()->willReturn(true); $commander->testForBlock($coordinates, $plankType, 0)->shouldBeCalled()->willReturn(true); $this->detectBlockType($coordinates)->shouldBeLike($expectedType); }