mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
Don't fire change events if block has not changed
This commit is contained in:
parent
04f0500822
commit
10ed95a469
@ -176,15 +176,17 @@ class Level{
|
|||||||
public function setBlock(Vector3 $pos, Block $block, $update = true, $tiles = false){
|
public function setBlock(Vector3 $pos, Block $block, $update = true, $tiles = false){
|
||||||
if((($pos instanceof Position) and $pos->level !== $this) or $pos->x < 0 or $pos->y < 0 or $pos->z < 0){
|
if((($pos instanceof Position) and $pos->level !== $this) or $pos->x < 0 or $pos->y < 0 or $pos->z < 0){
|
||||||
return false;
|
return false;
|
||||||
}elseif(!($pos instanceof Position)){
|
|
||||||
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->server->api->dhandle("block.change", array(
|
$ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata());
|
||||||
"position" => $pos,
|
if($ret === true){
|
||||||
"block" => $block,
|
if(!($pos instanceof Position)){
|
||||||
)) !== false){
|
$pos = new Position($pos->x, $pos->y, $pos->z, $this);
|
||||||
$ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata());
|
}
|
||||||
|
$this->server->trigger("block.change", array(
|
||||||
|
"position" => $pos,
|
||||||
|
"block" => $block,
|
||||||
|
));
|
||||||
if($update === true){
|
if($update === true){
|
||||||
$this->server->api->block->blockUpdate($this->getBlock($pos), BLOCK_UPDATE_NORMAL); //????? water?
|
$this->server->api->block->blockUpdate($this->getBlock($pos), BLOCK_UPDATE_NORMAL); //????? water?
|
||||||
$this->server->api->block->blockUpdateAround($pos, BLOCK_UPDATE_NORMAL);
|
$this->server->api->block->blockUpdateAround($pos, BLOCK_UPDATE_NORMAL);
|
||||||
@ -194,9 +196,8 @@ class Level{
|
|||||||
$t[0]->close();
|
$t[0]->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
return false;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMiniChunk($X, $Y, $Z){
|
public function getMiniChunk($X, $Y, $Z){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user