From 10ed95a469de8b236a4a43a26d0d36f37572e787 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Sun, 19 May 2013 17:53:40 +0200 Subject: [PATCH] Don't fire change events if block has not changed --- src/world/Level.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/world/Level.php b/src/world/Level.php index 76ce12b871..1f6caa8b5c 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -176,15 +176,17 @@ class Level{ 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){ return false; - }elseif(!($pos instanceof Position)){ - $pos = new Position($pos->x, $pos->y, $pos->z, $this); } - if($this->server->api->dhandle("block.change", array( - "position" => $pos, - "block" => $block, - )) !== false){ - $ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata()); + $ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata()); + if($ret === true){ + if(!($pos instanceof Position)){ + $pos = new Position($pos->x, $pos->y, $pos->z, $this); + } + $this->server->trigger("block.change", array( + "position" => $pos, + "block" => $block, + )); if($update === true){ $this->server->api->block->blockUpdate($this->getBlock($pos), BLOCK_UPDATE_NORMAL); //????? water? $this->server->api->block->blockUpdateAround($pos, BLOCK_UPDATE_NORMAL); @@ -194,9 +196,8 @@ class Level{ $t[0]->close(); } } - return $ret; } - return false; + return $ret; } public function getMiniChunk($X, $Y, $Z){