diff --git a/src/Player.php b/src/Player.php index 7c6e332a..07da0ef1 100644 --- a/src/Player.php +++ b/src/Player.php @@ -472,16 +472,16 @@ class Player{ )); break; case "entity.motion": - /*if($data->eid === $this->eid or $data->level !== $this->level){ + if($data->eid === $this->eid or $data->level !== $this->level){ break; } $this->dataPacket(MC_SET_ENTITY_MOTION, array( "eid" => $data->eid, - "speedX" => (int) ($data->speedX * 32000), - "speedY" => (int) ($data->speedY * 32000), - "speedZ" => (int) ($data->speedZ * 32000), + "speedX" => (int) ($data->speedX * 400), + "speedY" => (int) ($data->speedY * 400), + "speedZ" => (int) ($data->speedZ * 400), )); - break;*/ + break; case "entity.remove": if($data->eid === $this->eid or $data->level !== $this->level){ break; diff --git a/src/world/Entity.php b/src/world/Entity.php index 23341633..00a7b656 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -354,25 +354,33 @@ class Entity extends Position{ } } if($this->class === ENTITY_ITEM or $this->class === ENTITY_MOB){ + $update = false; if($this->speedX != 0){ $this->x += $this->speedX * 5; + $update = true; } if($this->speedY != 0){ $this->y += $this->speedY * 5; + $update = true; } if($this->speedZ != 0){ $this->z += $this->speedZ * 5; + $update = true; } if($support === false){ $this->speedY -= 0.04 * 5; - //$this->server->api->handle("entity.motion", $this); + $update = true; }elseif($this->speedY < 0){ $this->y = $y + 1; $this->speedX = 0; $this->speedY = 0; $this->speedZ = 0; - //$this->server->api->handle("entity.motion", $this); + $update = true; } + if($update === true){ + $this->server->api->handle("entity.motion", $this); + } + }elseif($this->class === ENTITY_PLAYER){ if($support === false and ($this->player->gamemode & 0x01) === 0x00){ if($this->fallY === false or $this->fallStart === false){ @@ -399,9 +407,6 @@ class Entity extends Position{ $this->fallStart = false; } - } - - if($this->class === ENTITY_PLAYER){ $this->calculateVelocity(); if($this->speed <= 5 or ($this->speed <= 12 and ($this->player->gamemode & 0x01) === 0x01)){ $this->player->lastCorrect = new Vector3($this->last[0], $this->last[1], $this->last[2]); @@ -416,9 +421,6 @@ class Entity extends Position{ }else{ $this->setPosition($this->last[0], $this->last[1], $this->last[2], $this->last[3], $this->last[4]); } - if($this->class === ENTITY_PLAYER){ - $this->calculateVelocity(); - } return; } $this->updateLast(); @@ -629,9 +631,12 @@ class Entity extends Position{ $speedX = ($this->last[0] - $this->x) / $diffTime; $speedY = ($this->last[1] - $this->y) / $diffTime; $speedZ = ($this->last[2] - $this->z) / $diffTime; - $this->speedX = $speedX; - $this->speedY = $speedY; - $this->speedZ = $speedZ; + if($this->speedX != $speedX or $this->speedY = $speedY or $this->speedZ = $speedZ){ + $this->speedX = $speedX; + $this->speedY = $speedY; + $this->speedZ = $speedZ; + $this->server->api->handle("entity.motion", $this); + } $this->speed = $origin->distance($final) / $diffTime; unset($this->speedMeasure[key($this->speedMeasure)]); $this->speedMeasure[] = $this->speed;