public function onBreak(Item $item) { $block = $this; if ($this->getLevel()->getBlock($this->temporalVector->setComponents($block->x - 1, $block->y, $block->z))->getId() == Block::PORTAL or $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x + 1, $block->y, $block->z))->getId() == Block::PORTAL) { //x方向 for ($x = $block->x; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $block->y, $block->z))->getId() == Block::PORTAL; $x++) { for ($y = $block->y; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $block->z))->getId() == Block::PORTAL; $y++) { $this->getLevel()->setBlock($this->temporalVector->setComponents($x, $y, $block->z), new Air()); } for ($y = $block->y - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $block->z))->getId() == Block::PORTAL; $y--) { $this->getLevel()->setBlock($this->temporalVector->setComponents($x, $y, $block->z), new Air()); } } for ($x = $block->x - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $block->y, $block->z))->getId() == Block::PORTAL; $x--) { for ($y = $block->y; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $block->z))->getId() == Block::PORTAL; $y++) { $this->getLevel()->setBlock($this->temporalVector->setComponents($x, $y, $block->z), new Air()); } for ($y = $block->y - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $block->z))->getId() == Block::PORTAL; $y--) { $this->getLevel()->setBlock($this->temporalVector->setComponents($x, $y, $block->z), new Air()); } } } else { //z方向 for ($z = $block->z; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $block->y, $z))->getId() == Block::PORTAL; $z++) { for ($y = $block->y; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $y, $z))->getId() == Block::PORTAL; $y++) { $this->getLevel()->setBlock($this->temporalVector->setComponents($block->x, $y, $z), new Air()); } for ($y = $block->y - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $y, $z))->getId() == Block::PORTAL; $y--) { $this->getLevel()->setBlock($this->temporalVector->setComponents($block->x, $y, $z), new Air()); } } for ($z = $block->z - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $block->y, $z))->getId() == Block::PORTAL; $z--) { for ($y = $block->y; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $y, $z))->getId() == Block::PORTAL; $y++) { $this->getLevel()->setBlock($this->temporalVector->setComponents($block->x, $y, $z), new Air()); } for ($y = $block->y - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $y, $z))->getId() == Block::PORTAL; $y--) { $this->getLevel()->setBlock($this->temporalVector->setComponents($block->x, $y, $z), new Air()); } } } parent::onBreak($item); }
public function onBreak(Item $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(Block::PORTAL, 0));//在破坏处放置一个方块防止计算出错 if ($this->getLevel()->getBlock($this->temporalVector->setComponents($block->x - 1, $block->y, $block->z))->getId() == Block::PORTAL or $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x + 1, $block->y, $block->z))->getId() == Block::PORTAL) { //x方向 for ($x = $block->x; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $block->y, $block->z))->getId() == Block::PORTAL; $x++) { for ($y = $block->y; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $block->z))->getId() == Block::PORTAL; $y++) { $this->getLevel()->setBlock($this->temporalVector->setComponents($x, $y, $block->z), new Air()); } for ($y = $block->y - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $block->z))->getId() == Block::PORTAL; $y--) { $this->getLevel()->setBlock($this->temporalVector->setComponents($x, $y, $block->z), new Air()); } } for ($x = $block->x - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $block->y, $block->z))->getId() == Block::PORTAL; $x--) { for ($y = $block->y; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $block->z))->getId() == Block::PORTAL; $y++) { $this->getLevel()->setBlock($this->temporalVector->setComponents($x, $y, $block->z), new Air()); } for ($y = $block->y - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($x, $y, $block->z))->getId() == Block::PORTAL; $y--) { $this->getLevel()->setBlock($this->temporalVector->setComponents($x, $y, $block->z), new Air()); } } } else { //z方向 for ($z = $block->z; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $block->y, $z))->getId() == Block::PORTAL; $z++) { for ($y = $block->y; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $y, $z))->getId() == Block::PORTAL; $y++) { $this->getLevel()->setBlock($this->temporalVector->setComponents($block->x, $y, $z), new Air()); } for ($y = $block->y - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $y, $z))->getId() == Block::PORTAL; $y--) { $this->getLevel()->setBlock($this->temporalVector->setComponents($block->x, $y, $z), new Air()); } } for ($z = $block->z - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $block->y, $z))->getId() == Block::PORTAL; $z--) { for ($y = $block->y; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $y, $z))->getId() == Block::PORTAL; $y++) { $this->getLevel()->setBlock($this->temporalVector->setComponents($block->x, $y, $z), new Air()); } for ($y = $block->y - 1; $this->getLevel()->getBlock($this->temporalVector->setComponents($block->x, $y, $z))->getId() == Block::PORTAL; $y--) { $this->getLevel()->setBlock($this->temporalVector->setComponents($block->x, $y, $z), new Air()); } } } parent::onBreak($item); }