Beispiel #1
0
 public function onBreak(Item $item)
 {
     parent::onBreak($item);
     $sound = new EndermanTeleportSound($this);
     $this->getLevel()->addSound($sound);
     $particle = new PortalParticle($this);
     $this->getLevel()->addParticle($particle);
     $block = $this;
     $this->getLevel()->setBlock($block, new Block(90, 0));
     //在破坏处放置一个方块防止计算出错
     if ($this->getLevel()->getBlock($block->add(-1, 0, 0))->getId() == 90 or $this->getLevel()->getBlock($block->add(1, 0, 0))->getId() == 90) {
         //x方向
         for ($x = $block->getX(); $this->getLevel()->getBlock(new Vector3($x, $block->getY(), $block->getZ()))->getId() == 90; $x++) {
             for ($y = $block->getY(); $this->getLevel()->getBlock(new Vector3($x, $y, $block->getZ()))->getId() == 90; $y++) {
                 $this->getLevel()->setBlock(new Vector3($x, $y, $block->getZ()), new Block(0, 0));
             }
             for ($y = $block->getY() - 1; $this->getLevel()->getBlock(new Vector3($x, $y, $block->getZ()))->getId() == 90; $y--) {
                 $this->getLevel()->setBlock(new Vector3($x, $y, $block->getZ()), new Block(0, 0));
             }
         }
         for ($x = $block->getX() - 1; $this->getLevel()->getBlock(new Vector3($x, $block->getY(), $block->getZ()))->getId() == 90; $x--) {
             for ($y = $block->getY(); $this->getLevel()->getBlock(new Vector3($x, $y, $block->getZ()))->getId() == 90; $y++) {
                 $this->getLevel()->setBlock(new Vector3($x, $y, $block->getZ()), new Block(0, 0));
             }
             for ($y = $block->getY() - 1; $this->getLevel()->getBlock(new Vector3($x, $y, $block->getZ()))->getId() == 90; $y--) {
                 $this->getLevel()->setBlock(new Vector3($x, $y, $block->getZ()), new Block(0, 0));
             }
         }
     } else {
         //z方向
         for ($z = $block->getZ(); $this->getLevel()->getBlock(new Vector3($block->getX(), $block->getY(), $z))->getId() == 90; $z++) {
             for ($y = $block->getY(); $this->getLevel()->getBlock(new Vector3($block->getX(), $y, $z))->getId() == 90; $y++) {
                 $this->getLevel()->setBlock(new Vector3($block->getX(), $y, $z), new Block(0, 0));
             }
             for ($y = $block->getY() - 1; $this->getLevel()->getBlock(new Vector3($block->getX(), $y, $z))->getId() == 90; $y--) {
                 $this->getLevel()->setBlock(new Vector3($block->getX(), $y, $z), new Block(0, 0));
             }
         }
         for ($z = $block->getZ() - 1; $this->getLevel()->getBlock(new Vector3($block->getX(), $block->getY(), $z))->getId() == 90; $z--) {
             for ($y = $block->getY(); $this->getLevel()->getBlock(new Vector3($block->getX(), $y, $z))->getId() == 90; $y++) {
                 $this->getLevel()->setBlock(new Vector3($block->getX(), $y, $z), new Block(0, 0));
             }
             for ($y = $block->getY() - 1; $this->getLevel()->getBlock(new Vector3($block->getX(), $y, $z))->getId() == 90; $y--) {
                 $this->getLevel()->setBlock(new Vector3($block->getX(), $y, $z), new Block(0, 0));
             }
         }
     }
 }