Exemplo n.º 1
0
 public function onBreak(Item $item)
 {
     if ($this->getRandomExperience($item) > 0) {
         Entity::createEntity("ExperienceOrb", $this->level->getChunk($this->x >> 4, $this->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]))->spawnToAll();
     }
     return parent::onBreak($item);
 }
Exemplo n.º 2
0
 public function onBreak(Item $item)
 {
     parent::onBreak($item);
     if ($this->getLevel()->getServer()->netherEnabled) {
         for ($i = 0; $i <= 6; $i++) {
             if ($this->getSide($i)->getId() == self::PORTAL) {
                 break;
             }
             if ($i == 6) {
                 return;
             }
         }
         $block = $this->getSide($i);
         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());
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public function onBreak(Item $item)
 {
     parent::onBreak($item);
     if ($this->getLevel()->getServer()->netherEnabled) {
         for ($i = 0; $i <= 6; $i++) {
             if ($i == 6) {
                 return;
             } elseif ($this->getLevel()->getBlock($this->getSide($i))->getId() == 90) {
                 $side = $i;
                 break;
             }
         }
         $block = $this->getLevel()->getBlock($this->getSide($i));
         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));
                 }
             }
         }
     }
 }