Example #1
0
 protected function save(array $items)
 {
     foreach ($items as $item) {
         if (!($blockType = $this->blockTypeRepository->getByName($item['name']))) {
             $blockType = new BlockType($item);
         } else {
             $blockType->updateData($item);
         }
         $this->blockTypeRepository->add($blockType);
     }
 }
Example #2
0
 public function scan(array $coordinates, $width, $length, $height)
 {
     $structure = new Structure();
     // go through the height
     for ($y = 1; $y <= $height; $y++) {
         // go through the length
         for ($z = 1; $z <= $length; $z++) {
             // go through the width
             for ($x = 1; $x <= $width; $x++) {
                 $currentX = $coordinates['x'] + $x;
                 $currentY = $coordinates['y'] + $y;
                 $currentZ = $coordinates['z'] + $z;
                 $currentCoordinates = array('x' => $currentX, 'y' => $currentY, 'z' => $currentZ);
                 $type = $this->scanner->detectBlockType($currentCoordinates);
                 // default to air
                 if (!$type) {
                     $type = new BlockType(array('name' => 'air', 'meta' => 0));
                 }
                 $structure->createBlock($type->getName(), array('x' => $x, 'y' => $y, 'z' => $z), $type->getMeta());
             }
         }
     }
     return $structure;
 }
Example #3
0
 /**
  * @param gries\MControl\Builder\BlockType $blockType
  */
 function it_generate_correct_command_string(BlockType $blockType)
 {
     $blockType->getName()->shouldBeCalled()->willReturn('minecraft:iron');
     $this->beConstructedWith(array('x' => 1, 'y' => 1, 'z' => 1), $blockType, 5);
     $this->getCommandString()->shouldReturn('testforblock 1 1 1 minecraft:iron 5');
 }