diff --git a/src/Player.php b/src/Player.php index ef4999bc..b14ca45f 100755 --- a/src/Player.php +++ b/src/Player.php @@ -95,7 +95,7 @@ class Player{ $this->packetStats = [0, 0]; $this->buffer = new RakNetPacket(RakNetInfo::DATA_PACKET_0); $this->buffer->data = []; - $this->server->schedule(2, [$this, "handlePacketQueues"], [], true); + $this->server->schedule(1, [$this, "handlePacketQueues"], [], true); $this->server->schedule(20 * 60, [$this, "clearQueue"], [], true); $this->evid[] = $this->server->event("server.close", [$this, "close"]); console("[DEBUG] New Session started with " . $ip . ":" . $port . ". MTU " . $this->MTU . ", Client ID " . $this->clientID, true, true, 2); @@ -340,7 +340,7 @@ class Player{ $this->bufferLen = 0; $this->buffer = new RakNetPacket(RakNetInfo::DATA_PACKET_0); $this->buffer->data = []; - $this->nextBuffer = microtime(true) + 0.1; + $this->nextBuffer = microtime(true) + 0.05; } /** @@ -1110,7 +1110,7 @@ class Player{ } } - if($this->nextBuffer <= $time and $this->bufferLen > 0){ + if($this->bufferLen > 0){ $this->sendBuffer(); } @@ -1470,7 +1470,7 @@ class Player{ $this->server->api->entity->spawnToAll($this->entity); //$this->server->schedule(5, [$this->entity, "update"], [], true); - $this->server->schedule(2, [$this->entity, "updateMovement"], [], true); + //$this->server->schedule(2, [$this->entity, "updateMovement"], [], true); $this->sendArmor(); $array = explode("@n", (string)$this->server->motd); foreach($array as $msg){ diff --git a/src/entity/Entity.php b/src/entity/Entity.php index bd46d988..6b01beda 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -526,8 +526,27 @@ class Entity extends Position if(Utils::in_range($this->speedY, -0.007, 0.007)){ $this->speedY = 0; } + + $horizontalMultiplyFactor = 0.91; + if($this->onGround){ + $horizontalMultiplyFactor = 0.54; + $b = $this->level->level->getBlockID(floor($this->x), floor($this->boundingBox->minX) - 1, floor($this->z)); + if($b > 0){ + $horizontalMultiplyFactor = StaticBlock::getSlipperiness($b) * 0.91; + } + } + if($this->inWater){ + $this->speedX *= 0.8; + $this->speedY *= 0.8; + $this->speedZ *= 0.8; + }else{ + $this->speedX *= $horizontalMultiplyFactor; + $this->speedY *= 0.98; + $this->speedZ *= $horizontalMultiplyFactor; + } + $savedSpeedY = $this->speedY; - if($this->class === ENTITY_MOB || $this->class === ENTITY_ITEM || ($this->class === ENTITY_OBJECT && $this->type === OBJECT_PRIMEDTNT)){ + if($this->class === ENTITY_MOB || $this->class === ENTITY_ITEM || ($this->class === ENTITY_OBJECT && $this->type === OBJECT_PRIMEDTNT) || $this->class === ENTITY_FALLING){ $water = false; $aABB = $this->boundingBox->addCoord($this->speedX, $this->speedY, $this->speedZ); $x0 = floor($aABB->minX); @@ -560,23 +579,7 @@ class Entity extends Position $this->inWater = $water; } $support = $savedSpeedY != $this->speedY && $savedSpeedY < 0; - $horizontalMultiplyFactor = 0.91; - if($support){ - $horizontalMultiplyFactor = 0.54; - $b = $this->level->level->getBlockID(floor($this->x), floor($this->boundingBox->minX) - 1, floor($this->z)); - if($b > 0){ - $horizontalMultiplyFactor = StaticBlock::getSlipperiness($b) * 0.91; - } - } - if($this->inWater){ - $this->speedX *= 0.8; - $this->speedY *= 0.8; - $this->speedZ *= 0.8; - }else{ - $this->speedX *= $horizontalMultiplyFactor; - $this->speedY *= 0.98; - $this->speedZ *= $horizontalMultiplyFactor; - } + if($this->speedX != 0){ $this->x += $this->speedX; $update = true; @@ -587,26 +590,10 @@ class Entity extends Position } if($this->speedY != 0){ $ny = $this->y + $this->speedY; - if($this->class === ENTITY_FALLING && $ny <= $this->y){ - $x = (int) ($this->x - 0.5); - $z = (int) ($this->z - 0.5); - $lim = (int) floor($ny); - for($y = floor($this->y); $y >= $lim; --$y){ - if(StaticBlock::getIsSolid($this->level->level->getBlockID($x, $y, $z))){ - //$support = true; - $this->y = $ny; - $fall = $this->level->getBlock(new Vector3(intval($this->x - 0.5), intval(ceil($this->y)), intval($this->z - 0.5))); - $down = $this->level->getBlock(new Vector3(intval($this->x - 0.5), intval(ceil($this->y) - 1), intval($this->z - 0.5))); - if($fall->isFullBlock === false or $down->isFullBlock === false){ - $this->server->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"] & 0xFFFF, 0, 1), true); - } else{ - $this->level->setBlock($fall, BlockAPI::get($this->data["Tile"]), true, false, true); - } - $this->server->api->handle("entity.motion", $this); - $this->close(); - return false; - } - } + if($this->class === ENTITY_FALLING && $support){ + $this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, $this->data["Tile"], 0); + $this->close(); + return; } $this->y = $ny; @@ -700,7 +687,7 @@ class Entity extends Position if($this->lastHeadYaw != $this->headYaw){ $this->sendHeadYaw(); } - if($this->class !== ENTITY_PLAYER && $update){ + if($this->isPlayer() || $update){ $this->updateMovement(); }