fixing chunk sending

This commit is contained in:
Intyre 2016-02-27 16:35:38 +01:00
parent b766b969e2
commit e11b76318c
No known key found for this signature in database
GPG Key ID: B06D41D26935005A
5 changed files with 94 additions and 2 deletions

View File

@ -101,6 +101,7 @@ use pocketmine\nbt\tag\StringTag;
use pocketmine\network\protocol\AdventureSettingsPacket;
use pocketmine\network\protocol\AnimatePacket;
use pocketmine\network\protocol\BatchPacket;
use pocketmine\network\protocol\ChunkRadiusUpdatePacket;
use pocketmine\network\protocol\ContainerClosePacket;
use pocketmine\network\protocol\ContainerSetContentPacket;
use pocketmine\network\protocol\DataPacket;
@ -2874,6 +2875,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
}
break;
case ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET:
if($this->spawned){
$this->viewDistance = $packet->radius ** 2;
}
$pk = new ChunkRadiusUpdatePacket();
$pk->radius = $packet->radius;
$this->dataPacket($pk);
break;
default:
break;
}

View File

@ -31,6 +31,7 @@ use pocketmine\network\protocol\AddPlayerPacket;
use pocketmine\network\protocol\AdventureSettingsPacket;
use pocketmine\network\protocol\AnimatePacket;
use pocketmine\network\protocol\BatchPacket;
use pocketmine\network\protocol\ChunkRadiusUpdatePacket;
use pocketmine\network\protocol\ContainerClosePacket;
use pocketmine\network\protocol\ContainerOpenPacket;
use pocketmine\network\protocol\ContainerSetContentPacket;
@ -42,6 +43,7 @@ use pocketmine\network\protocol\DataPacket;
use pocketmine\network\protocol\DropItemPacket;
use pocketmine\network\protocol\FullChunkDataPacket;
use pocketmine\network\protocol\Info;
use pocketmine\network\protocol\RequestChunkRadiusPacket;
use pocketmine\network\protocol\SetEntityLinkPacket;
use pocketmine\network\protocol\BlockEntityDataPacket;
use pocketmine\network\protocol\EntityEventPacket;
@ -332,5 +334,7 @@ class Network{
$this->registerPacket(ProtocolInfo::SET_DIFFICULTY_PACKET, SetDifficultyPacket::class);
$this->registerPacket(ProtocolInfo::SET_PLAYER_GAMETYPE_PACKET, SetPlayerGameTypePacket::class);
$this->registerPacket(ProtocolInfo::PLAYER_LIST_PACKET, PlayerListPacket::class);
$this->registerPacket(ProtocolInfo::REQUEST_CHUNK_RADIUS_PACKET, RequestChunkRadiusPacket::class);
$this->registerPacket(ProtocolInfo::CHUNK_RADIUS_UPDATE_PACKET, ChunkRadiusUpdatePacket::class);
}
}

View File

@ -0,0 +1,40 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class ChunkRadiusUpdatePacket extends DataPacket{
const NETWORK_ID = Info::CHUNK_RADIUS_UPDATE_PACKET;
public $radius;
public function decode(){
}
public function encode(){
$this->reset();
$this->putInt($this->radius);
}
}

View File

@ -89,8 +89,8 @@ interface Info{
// const SPAWN_EXPERIENCE_ORB_PACKET = 0xc5
// const CLIENTBOUND_MAP_ITEM_DATA_PACKET = 0xc6;
// const MAP_INFO_REQUEST_PACKET = 0xc7;
// const REQUEST_CHUNK_RADIUS_PACKET = 0xc8;
// const CHUNK_RADIUS_UPDATE_PACKET = 0xc9;
const REQUEST_CHUNK_RADIUS_PACKET = 0xc8;
const CHUNK_RADIUS_UPDATE_PACKET = 0xc9;
// const ITEM_FRAME_DROP_ITEM_PACKET = 0xca;
// const REPLACE_SELECTED_ITEM_PACKET = 0xcb;
}

View File

@ -0,0 +1,39 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\network\protocol;
#include <rules/DataPacket.h>
class RequestChunkRadiusPacket extends DataPacket{
const NETWORK_ID = Info::REQUEST_CHUNK_RADIUS_PACKET;
public $radius;
public function decode(){
$this->radius = $this->getInt();
}
public function encode(){
}
}