Send correct entity motion

This commit is contained in:
Shoghi Cervantes 2013-05-26 14:06:26 +02:00
parent 7622151a21
commit 6262fbffcb
2 changed files with 21 additions and 16 deletions

View File

@ -472,16 +472,16 @@ class Player{
)); ));
break; break;
case "entity.motion": case "entity.motion":
/*if($data->eid === $this->eid or $data->level !== $this->level){ if($data->eid === $this->eid or $data->level !== $this->level){
break; break;
} }
$this->dataPacket(MC_SET_ENTITY_MOTION, array( $this->dataPacket(MC_SET_ENTITY_MOTION, array(
"eid" => $data->eid, "eid" => $data->eid,
"speedX" => (int) ($data->speedX * 32000), "speedX" => (int) ($data->speedX * 400),
"speedY" => (int) ($data->speedY * 32000), "speedY" => (int) ($data->speedY * 400),
"speedZ" => (int) ($data->speedZ * 32000), "speedZ" => (int) ($data->speedZ * 400),
)); ));
break;*/ break;
case "entity.remove": case "entity.remove":
if($data->eid === $this->eid or $data->level !== $this->level){ if($data->eid === $this->eid or $data->level !== $this->level){
break; break;

View File

@ -354,25 +354,33 @@ class Entity extends Position{
} }
} }
if($this->class === ENTITY_ITEM or $this->class === ENTITY_MOB){ if($this->class === ENTITY_ITEM or $this->class === ENTITY_MOB){
$update = false;
if($this->speedX != 0){ if($this->speedX != 0){
$this->x += $this->speedX * 5; $this->x += $this->speedX * 5;
$update = true;
} }
if($this->speedY != 0){ if($this->speedY != 0){
$this->y += $this->speedY * 5; $this->y += $this->speedY * 5;
$update = true;
} }
if($this->speedZ != 0){ if($this->speedZ != 0){
$this->z += $this->speedZ * 5; $this->z += $this->speedZ * 5;
$update = true;
} }
if($support === false){ if($support === false){
$this->speedY -= 0.04 * 5; $this->speedY -= 0.04 * 5;
//$this->server->api->handle("entity.motion", $this); $update = true;
}elseif($this->speedY < 0){ }elseif($this->speedY < 0){
$this->y = $y + 1; $this->y = $y + 1;
$this->speedX = 0; $this->speedX = 0;
$this->speedY = 0; $this->speedY = 0;
$this->speedZ = 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){ }elseif($this->class === ENTITY_PLAYER){
if($support === false and ($this->player->gamemode & 0x01) === 0x00){ if($support === false and ($this->player->gamemode & 0x01) === 0x00){
if($this->fallY === false or $this->fallStart === false){ if($this->fallY === false or $this->fallStart === false){
@ -399,9 +407,6 @@ class Entity extends Position{
$this->fallStart = false; $this->fallStart = false;
} }
}
if($this->class === ENTITY_PLAYER){
$this->calculateVelocity(); $this->calculateVelocity();
if($this->speed <= 5 or ($this->speed <= 12 and ($this->player->gamemode & 0x01) === 0x01)){ 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]); $this->player->lastCorrect = new Vector3($this->last[0], $this->last[1], $this->last[2]);
@ -416,9 +421,6 @@ class Entity extends Position{
}else{ }else{
$this->setPosition($this->last[0], $this->last[1], $this->last[2], $this->last[3], $this->last[4]); $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; return;
} }
$this->updateLast(); $this->updateLast();
@ -629,9 +631,12 @@ class Entity extends Position{
$speedX = ($this->last[0] - $this->x) / $diffTime; $speedX = ($this->last[0] - $this->x) / $diffTime;
$speedY = ($this->last[1] - $this->y) / $diffTime; $speedY = ($this->last[1] - $this->y) / $diffTime;
$speedZ = ($this->last[2] - $this->z) / $diffTime; $speedZ = ($this->last[2] - $this->z) / $diffTime;
if($this->speedX != $speedX or $this->speedY = $speedY or $this->speedZ = $speedZ){
$this->speedX = $speedX; $this->speedX = $speedX;
$this->speedY = $speedY; $this->speedY = $speedY;
$this->speedZ = $speedZ; $this->speedZ = $speedZ;
$this->server->api->handle("entity.motion", $this);
}
$this->speed = $origin->distance($final) / $diffTime; $this->speed = $origin->distance($final) / $diffTime;
unset($this->speedMeasure[key($this->speedMeasure)]); unset($this->speedMeasure[key($this->speedMeasure)]);
$this->speedMeasure[] = $this->speed; $this->speedMeasure[] = $this->speed;