mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
Merge pull request #2 from yefengeeeeeeeeeee/multiversion
This commit is contained in:
commit
60b802ba6c
5 changed files with 15 additions and 10 deletions
|
|
@ -505,8 +505,6 @@ class BlockAPI{
|
||||||
if($hand->isSolid === true && ($hand->getID() != BED_BLOCK && $hand->getID() != CARPET)){
|
if($hand->isSolid === true && ($hand->getID() != BED_BLOCK && $hand->getID() != CARPET)){
|
||||||
$aabb = $hand->getAABB($block->level, $block->x, $block->y, $block->z);
|
$aabb = $hand->getAABB($block->level, $block->x, $block->y, $block->z);
|
||||||
$playerbb = $player->entity->boundingBox;
|
$playerbb = $player->entity->boundingBox;
|
||||||
//$aabb->intersectsWith($playerbb) is not good enough for this case
|
|
||||||
//minY+0.21 is used to stop sneaking from triggering action cancelling
|
|
||||||
if(($aabb->maxX > $playerbb->minX && $aabb->minX < $playerbb->maxX) && ($aabb->maxY > ($playerbb->minY+0.21) && $aabb->minY < $playerbb->maxY) && ($aabb->maxZ > $playerbb->minZ && $aabb->minZ < $playerbb->maxZ)){
|
if(($aabb->maxX > $playerbb->minX && $aabb->minX < $playerbb->maxX) && ($aabb->maxY > ($playerbb->minY+0.21) && $aabb->minY < $playerbb->maxY) && ($aabb->maxZ > $playerbb->minZ && $aabb->minZ < $playerbb->maxZ)){
|
||||||
return $this->cancelAction($block, $player, false); //Entity in block
|
return $this->cancelAction($block, $player, false); //Entity in block
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ class Player{
|
||||||
*/
|
*/
|
||||||
public function __construct($clientID, $ip, $port, $MTU){
|
public function __construct($clientID, $ip, $port, $MTU){
|
||||||
$this->bigCnt = 0;
|
$this->bigCnt = 0;
|
||||||
$this->MTU = min($MTU, 1100);
|
$this->MTU = min($MTU, 1492);
|
||||||
$this->server = ServerAPI::request();
|
$this->server = ServerAPI::request();
|
||||||
$this->lastBreak = microtime(true);
|
$this->lastBreak = microtime(true);
|
||||||
$this->clientID = $clientID;
|
$this->clientID = $clientID;
|
||||||
|
|
@ -355,7 +355,9 @@ class Player{
|
||||||
if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY){
|
if(EventHandler::callEvent(new DataPacketSendEvent($this, $packet)) === BaseEvent::DENY){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$packet->PROTOCOL = $this->PROTOCOL;
|
|
||||||
|
$packet->PROTOCOL = $this->PROTOCOL;
|
||||||
|
|
||||||
$packet->encode();
|
$packet->encode();
|
||||||
$len = strlen($packet->buffer) + 1;
|
$len = strlen($packet->buffer) + 1;
|
||||||
$MTU = $this->MTU - 24;
|
$MTU = $this->MTU - 24;
|
||||||
|
|
@ -1268,6 +1270,8 @@ class Player{
|
||||||
public function sendBlockUpdateQueue(){
|
public function sendBlockUpdateQueue(){
|
||||||
if($this->blockUpdateQueueLength > 0 && $this->blockUpdateQueue instanceof RakNetPacket){
|
if($this->blockUpdateQueueLength > 0 && $this->blockUpdateQueue instanceof RakNetPacket){
|
||||||
$this->blockUpdateQueue->seqNumber = $this->counter[0]++;
|
$this->blockUpdateQueue->seqNumber = $this->counter[0]++;
|
||||||
|
$this->recoveryQueue[$this->blockUpdateQueue->seqNumber] = $this->blockUpdateQueue;
|
||||||
|
$this->blockUpdateQueue->sendtime = microtime(true);
|
||||||
$this->send($this->blockUpdateQueue);
|
$this->send($this->blockUpdateQueue);
|
||||||
}
|
}
|
||||||
$this->blockUpdateQueueLength = 0;
|
$this->blockUpdateQueueLength = 0;
|
||||||
|
|
@ -2982,13 +2986,13 @@ class Player{
|
||||||
switch($packet->pid()){
|
switch($packet->pid()){
|
||||||
case RakNetInfo::NACK:
|
case RakNetInfo::NACK:
|
||||||
foreach($packet->packets as $count){
|
foreach($packet->packets as $count){
|
||||||
|
|
||||||
if(isset($this->recoveryQueue[$count])){
|
if(isset($this->recoveryQueue[$count])){
|
||||||
$this->resendQueue[$count] =& $this->recoveryQueue[$count];
|
$this->resendQueue[$count] =& $this->recoveryQueue[$count];
|
||||||
$this->lag[] = $time - $this->recoveryQueue[$count]->sendtime;
|
$this->lag[] = $time - $this->recoveryQueue[$count]->sendtime;
|
||||||
unset($this->recoveryQueue[$count]);
|
unset($this->recoveryQueue[$count]);
|
||||||
|
}else{
|
||||||
|
++$this->packetStats[1]; //lost and wont be recovered
|
||||||
}
|
}
|
||||||
++$this->packetStats[1];
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -590,10 +590,10 @@ class PocketMinecraftServer{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->clients[$CID] = new Player($packet->clientID, $packet->ip, $packet->port, $packet->mtuSize); //New Session!
|
$this->clients[$CID] = $c = new Player($packet->clientID, $packet->ip, $packet->port, $packet->mtuSize); //New Session!
|
||||||
$pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_2);
|
$pk = new RakNetPacket(RakNetInfo::OPEN_CONNECTION_REPLY_2);
|
||||||
$pk->serverID = $this->serverID;
|
$pk->serverID = $this->serverID;
|
||||||
$pk->mtuSize = $packet->mtuSize;
|
$pk->mtuSize = $c->MTU;
|
||||||
$pk->ip = $packet->ip;
|
$pk->ip = $packet->ip;
|
||||||
$pk->port = $packet->port;
|
$pk->port = $packet->port;
|
||||||
$this->send($pk);
|
$this->send($pk);
|
||||||
|
|
|
||||||
|
|
@ -1421,7 +1421,6 @@ class Entity extends Position
|
||||||
$this->player->directDataPacket($pk, 0);
|
$this->player->directDataPacket($pk, 0);
|
||||||
}
|
}
|
||||||
$this->knockbackTime = 10;
|
$this->knockbackTime = 10;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@
|
||||||
class UnknownPacket extends RakNetDataPacket{
|
class UnknownPacket extends RakNetDataPacket{
|
||||||
public $packetID = -1;
|
public $packetID = -1;
|
||||||
|
|
||||||
|
public function __construct($pid = -1){
|
||||||
|
$this->packetID = $pid;
|
||||||
|
}
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
return $this->packetID;
|
return $this->packetID;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue