From fba12c6ddfb56eede099b738800ccd88647c6f17 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Wed, 10 Sep 2014 20:06:30 +0200 Subject: [PATCH] Fixed EntityMoveEvent not being cancelled correctly on players --- src/pocketmine/Player.php | 2 +- src/pocketmine/entity/Entity.php | 7 ++++++- src/pocketmine/level/Level.php | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 36f90e127..4463c1056 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1368,7 +1368,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->setRotation($packet->yaw, $packet->pitch); //$this->inBlock = $this->checkObstruction($this->x, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, $this->z); - $this->move($dx, $dy, $dz); + $revert = !$this->move($dx, $dy, $dz); $diffX = $this->x - $newPos->x; $diffZ = $this->z - $newPos->z; diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 49f6bd23f..f6520a153 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -715,7 +715,7 @@ abstract class Entity extends Position implements Metadatable{ //$collision = []; //$this->checkBlockCollision($collision); if($dx == 0 and $dz == 0 and $dy == 0){ - return; + return true; } //if($this->inBlock){ //TODO: noclip @@ -887,8 +887,11 @@ abstract class Entity extends Position implements Metadatable{ ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2 ); + $result = true; + if(!$this->setPosition($pos)){ $this->boundingBox->setBB($axisalignedbb); + $result = false; }else{ if($this instanceof Player){ @@ -922,6 +925,8 @@ abstract class Entity extends Position implements Metadatable{ //TODO: vehicle collision events (first we need to spawn them!) Timings::$entityMoveTimer->stopTiming(); + + return $result; //} } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 12066e394..af0e66f31 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -913,6 +913,7 @@ class Level implements ChunkManager, Metadatable{ } $this->changedBlocks[$index][$Y][] = clone $block; } + if($update === true){ $this->updateAround($pos, self::BLOCK_UPDATE_NORMAL); $block->onUpdate(self::BLOCK_UPDATE_NORMAL);