Fixed Entity update

This commit is contained in:
Shoghi Cervantes 2013-06-05 13:15:40 +02:00
parent 67b533a44d
commit 18b437eec9

View File

@ -354,11 +354,11 @@ class Entity extends Position{
} }
if($this->isStatic === false){ if($this->isStatic === false){
$startX = ((int) round($this->x - 0.5)) - 1; $startX = floor($this->x - 0.5 - $this->size);
$y = (int) round($this->y - 1); $y = (int) round($this->y - 1);
$startZ = ((int) round($this->z - 0.5)) - 1; $startZ = floor($this->z - 0.5 - $this->size);
$endX = $startX + 2; $endX = ceil($startX + $this->size);
$endZ = $startZ + 2; $endZ = ceil($startZ + $this->size);
$support = false; $support = false;
$isFlying = true; $isFlying = true;
for($z = $startZ; $z <= $endZ; ++$z){ for($z = $startZ; $z <= $endZ; ++$z){
@ -430,14 +430,16 @@ class Entity extends Position{
if($support === false){ if($support === false){
$this->speedY -= ($this->class === ENTITY_FALLING ? 18:32) * $tdiff; $this->speedY -= ($this->class === ENTITY_FALLING ? 18:32) * $tdiff;
$update = true; $update = true;
}elseif($this->class === ENTITY_OBJECT or $this->speedY <= 0.1){ }else{
$this->speedX = 0; $this->speedX = 0;
$this->speedY = 0; $this->speedY = 0;
$this->speedZ = 0; $this->speedZ = 0;
$update = false;
$this->server->api->handle("entity.move", $this); $this->server->api->handle("entity.move", $this);
if($this->class === ENTITY_OBJECT or $this->speedY <= 0.1){
$update = false;
$this->server->api->handle("entity.motion", $this); $this->server->api->handle("entity.motion", $this);
} }
}
if($update === true){ if($update === true){
$hasUpdate = true; $hasUpdate = true;
@ -494,8 +496,6 @@ class Entity extends Position{
} }
$this->lastUpdate = $now; $this->lastUpdate = $now;
if($this->class !== ENTITY_PLAYER and $hasUpdate === true){ if($this->class !== ENTITY_PLAYER and $hasUpdate === true){
console($this->eid);
var_dump($this->speedX, $this->speedY, $this->speedZ);
$this->server->schedule(5, array($this, "update")); $this->server->schedule(5, array($this, "update"));
} }
} }