diff --git a/src/Player.php b/src/Player.php index 25977d05c..d724809ab 100644 --- a/src/Player.php +++ b/src/Player.php @@ -746,9 +746,12 @@ class Player{ break; } if(($this->entity instanceof Entity) and $data["counter"] > $this->lastMovement){ - $this->lastMovement = $data["counter"]; - $this->entity->setPosition($data["x"], $data["y"], $data["z"], $data["yaw"], $data["pitch"]); - $this->server->api->dhandle("player.move", $this->entity); + $this->lastMovement = $data["counter"]; + if($this->server->api->handle("player.move", $this->entity) === false){ + $this->teleport(new Vecotr3($this->entity->x, $this->entity->y, $this->entity->z), $this->entity->yaw, $this->entity->pitch); + }else{ + $this->entity->setPosition($data["x"], $data["y"], $data["z"], $data["yaw"], $data["pitch"]); + } } break; case MC_PLAYER_EQUIPMENT: diff --git a/src/world/Entity.php b/src/world/Entity.php index 853097940..d26a9120e 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -351,7 +351,14 @@ class Entity extends stdClass{ } if($this->class !== ENTITY_OBJECT and ($this->last[0] != $this->x or $this->last[1] != $this->y or $this->last[2] != $this->z or $this->last[3] != $this->yaw or $this->last[4] != $this->pitch)){ - $this->server->api->dhandle("entity.move", $this); + if($this->server->api->handle("entity.move", $this) === false){ + if($this->class === ENTITY_PLAYER){ + $this->player->teleport(new Vector3($this->last[0], $this->last[1], $this->last[2]), $this->last[3], $this->last[4]); + }else{ + $this->setPosition($this->last[0], $this->last[1], $this->last[2], $this->last[3], $this->last[4]); + } + return; + } if($this->class === ENTITY_PLAYER){ $this->calculateVelocity(); }