diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index afe6e7917..b9d048afc 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -268,7 +268,8 @@ class Block extends Position{ if(($t = $this->world->getTile($this)) !== null){ $t->onBlockDestroyed(); } - return $this->getWorld()->setBlock($this, VanillaBlocks::AIR()); + $this->getWorld()->setBlock($this, VanillaBlocks::AIR()); + return true; } /** diff --git a/src/pocketmine/block/Ice.php b/src/pocketmine/block/Ice.php index eccf9dee5..71429e0a1 100644 --- a/src/pocketmine/block/Ice.php +++ b/src/pocketmine/block/Ice.php @@ -43,7 +43,8 @@ class Ice extends Transparent{ public function onBreak(Item $item, ?Player $player = null) : bool{ if(($player === null or $player->isSurvival()) and !$item->hasEnchantment(Enchantment::SILK_TOUCH())){ - return $this->getWorld()->setBlock($this, VanillaBlocks::WATER()); + $this->getWorld()->setBlock($this, VanillaBlocks::WATER()); + return true; } return parent::onBreak($item, $player); } diff --git a/src/pocketmine/world/ChunkManager.php b/src/pocketmine/world/ChunkManager.php index 129cee286..eeac6332f 100644 --- a/src/pocketmine/world/ChunkManager.php +++ b/src/pocketmine/world/ChunkManager.php @@ -47,9 +47,9 @@ interface ChunkManager{ * @param int $z * @param Block $block * - * @return bool TODO: remove + * @throws \InvalidArgumentException */ - public function setBlockAt(int $x, int $y, int $z, Block $block) : bool; + public function setBlockAt(int $x, int $y, int $z, Block $block) : void; /** * @param int $chunkX diff --git a/src/pocketmine/world/SimpleChunkManager.php b/src/pocketmine/world/SimpleChunkManager.php index 8869f4189..6baaa5166 100644 --- a/src/pocketmine/world/SimpleChunkManager.php +++ b/src/pocketmine/world/SimpleChunkManager.php @@ -58,13 +58,13 @@ class SimpleChunkManager implements ChunkManager{ return VanillaBlocks::AIR(); } - public function setBlockAt(int $x, int $y, int $z, Block $block) : bool{ + public function setBlockAt(int $x, int $y, int $z, Block $block) : void{ if($this->terrainPointer->moveTo($x, $y, $z, true)){ $this->terrainPointer->currentSubChunk->setFullBlock($x & 0xf, $y & 0xf, $z & 0xf, $block->getFullId()); $this->terrainPointer->currentChunk->setChanged(true); - return true; + }else{ + throw new \InvalidArgumentException("Cannot set block at coordinates x=$x,y=$y,z=$z, terrain is not loaded or out of bounds"); } - return false; } /** diff --git a/src/pocketmine/world/World.php b/src/pocketmine/world/World.php index b4d7034b7..3f0a72500 100644 --- a/src/pocketmine/world/World.php +++ b/src/pocketmine/world/World.php @@ -1446,18 +1446,15 @@ class World implements ChunkManager{ /** * Sets the block at the given Vector3 coordinates. - * @see World::setBlockAt() * * @param Vector3 $pos * @param Block $block * @param bool $update * - * @return bool Whether the block has been updated or not - * * @throws \InvalidArgumentException if the position is out of the world bounds */ - public function setBlock(Vector3 $pos, Block $block, bool $update = true) : bool{ - return $this->setBlockAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z), $block, $update); + public function setBlock(Vector3 $pos, Block $block, bool $update = true) : void{ + $this->setBlockAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z), $block, $update); } /** @@ -1472,11 +1469,9 @@ class World implements ChunkManager{ * @param Block $block * @param bool $update * - * @return bool Whether the block has been updated or not - * * @throws \InvalidArgumentException if the position is out of the world bounds */ - public function setBlockAt(int $x, int $y, int $z, Block $block, bool $update = true) : bool{ + public function setBlockAt(int $x, int $y, int $z, Block $block, bool $update = true) : void{ if(!$this->isInWorld($x, $y, $z)){ throw new \InvalidArgumentException("Pos x=$x,y=$y,z=$z is outside of the world bounds"); } @@ -1511,8 +1506,6 @@ class World implements ChunkManager{ } $this->timings->setBlock->stopTiming(); - - return true; } /**