Added lots of new events, enabled old features

This commit is contained in:
Shoghi Cervantes
2014-06-05 01:05:52 +02:00
parent 2b73da5412
commit 596f4ddb0e
10 changed files with 166 additions and 292 deletions

View File

@@ -30,6 +30,7 @@ use pocketmine\event\entity\EntityLevelChangeEvent;
use pocketmine\event\entity\EntityMotionEvent;
use pocketmine\event\entity\EntityMoveEvent;
use pocketmine\event\entity\EntitySpawnEvent;
use pocketmine\event\entity\EntityTeleportEvent;
use pocketmine\level\format\pmf\LevelFormat;
use pocketmine\level\Level;
use pocketmine\level\Position;
@@ -904,6 +905,14 @@ abstract class Entity extends Position implements Metadatable{
}
public function teleport(Vector3 $pos, $yaw = false, $pitch = false){
$from = Position::fromObject($this, $this->getLevel());
$to = Position::fromObject($pos, $pos instanceof Position ? $pos->getLevel() : $this->getLevel());
$this->server->getPluginManager()->callEvent($ev = new EntityTeleportEvent($this, $from, $to));
if($ev->isCancelled()){
return false;
}
$pos = $ev->getTo();
$this->setMotion(new Vector3(0, 0, 0));
if($this->setPositionAndRotation($pos, $yaw === false ? $this->yaw : $yaw, $pitch === false ? $this->pitch : $pitch) !== false){
if($this instanceof Player){