mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 08:19:45 +00:00
removed return value of ChunkManager->setBlockAt() and World->setBlock()
This commit is contained in:
parent
703ae3a172
commit
80d277f1b5
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user