diff --git a/src/Player.php b/src/Player.php index 50054c24..c00af045 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1607,6 +1607,7 @@ class Player{ } if($this->entity->inAction === true){ $this->entity->inAction = false; + $this->entity->inActionCounter = 0; $this->entity->updateMetadata(); } break; @@ -1665,6 +1666,7 @@ class Player{ if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place if($this->entity->inAction === true){ $this->entity->inAction = false; + $this->entity->inActionCounter = 0; $this->entity->updateMetadata(); } @@ -1697,6 +1699,7 @@ class Player{ break; }elseif($packet->face === 0xff and $this->server->handle("player.action", $data) !== false){ $this->entity->inAction = true; + $this->entity->inActionCounter = 0; $this->startAction = microtime(true); $this->entity->updateMetadata(); } @@ -1736,7 +1739,7 @@ class Player{ * args: xvel, yvel, zvel, (power+power)*1.5, 1.0 */ - $initalPower = 72000 - (72000 - 20); //assume we used a bow for 1 second + $initalPower = $this->entity->inActionCounter; $power = $initalPower / 20; $power = ($power * $power + $power * 2) / 3; if($power > 1.0) $power = 1; @@ -1744,7 +1747,7 @@ class Player{ //CANCEL but i am too lazy $power = 0.1; } - + //console("Arrow sent! power: $power"); $e->shoot($e->speedX, $e->speedY, $e->speedZ, ($power+$power) * 1.5, 1.0); //TODO bow power $this->server->api->entity->spawnToAll($e); } @@ -1752,6 +1755,7 @@ class Player{ } $this->startAction = false; $this->entity->inAction = false; + $this->entity->inActionCounter = 0; $this->entity->updateMetadata(); break; case 6: //get out of the bed @@ -1811,6 +1815,7 @@ class Player{ $this->sendArmor(); if($this->entity->inAction === true){ $this->entity->inAction = false; + $this->entity->inActionCounter = 0; $this->entity->updateMetadata(); } break; @@ -1876,6 +1881,7 @@ class Player{ $packet->eid = $this->eid; if($this->entity->inAction === true){ $this->entity->inAction = false; + $this->entity->inActionCounter = 0; $this->entity->updateMetadata(); } switch($packet->event){ @@ -1947,6 +1953,7 @@ class Player{ } if($this->entity->inAction === true){ $this->entity->inAction = false; + $this->entity->inActionCounter = 0; $this->entity->updateMetadata(); } break; diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 404f4b9e..53d01a03 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -70,6 +70,7 @@ class Entity extends Position public $random; public $radius; public $inAction = false; + public $inActionCounter = 0; public $hasKnockback; public $hasJumped; public $invincible, $crouched, $fire, $health, $status; @@ -499,6 +500,7 @@ class Entity extends Position if($this->closed === true){ return false; } + $now = microtime(true); if($this->check === false){ $this->lastUpdate = $now; @@ -727,19 +729,27 @@ class Entity extends Position $hasUpdate = true; } } + + if($this->knockbackTime > 0){ --$this->knockbackTime; } - if($this->moveTime > 0){ - -- $this->moveTime; + --$this->moveTime; } if($this->lookTime > 0){ - -- $this->lookTime; + --$this->lookTime; } if($this->idleTime > 0){ - -- $this->idleTime; + --$this->idleTime; } + + + if($this->inAction){ + ++$this->inActionCounter; + } + + if($this->lastHeadYaw != $this->headYaw){ $this->sendHeadYaw(); } diff --git a/src/entity/object/Arrow.php b/src/entity/object/Arrow.php index c7aae0cb..69279a20 100644 --- a/src/entity/object/Arrow.php +++ b/src/entity/object/Arrow.php @@ -59,12 +59,6 @@ class Arrow extends Projectile{ //parent::update(); $this->needsUpdate = true; - $this->speedY -= $this->gravity; - - $this->speedX *= 0.99; - $this->speedY *= 0.99; - $this->speedZ *= 0.99; - if($this->speedX != 0 or $this->speedY != 0 or $this->speedZ != 0){ $f = sqrt(($this->speedX * $this->speedX) + ($this->speedZ * $this->speedZ)); $this->yaw = (atan2($this->speedX, $this->speedZ) * 180 / M_PI); @@ -73,6 +67,12 @@ class Arrow extends Projectile{ $this->x += $this->speedX; $this->y += $this->speedY; $this->z += $this->speedZ; + + $this->speedX *= 0.99; + $this->speedY *= 0.99; + $this->speedZ *= 0.99; + $this->speedY -= $this->gravity; + $this->sendMotion(); $this->updatePosition(); }