Merge network refactors

This commit is contained in:
Dylan K. Taylor
2017-07-14 13:04:02 +01:00
23 changed files with 1213 additions and 650 deletions

View File

@ -112,7 +112,6 @@ class CraftingManager{
}
$pk->encode();
$pk->isEncoded = true;
$this->craftingDataCache = $pk;
Timings::$craftingDataCacheRebuildTimer->stopTiming();

View File

@ -32,6 +32,7 @@ use pocketmine\network\mcpe\protocol\ContainerSetContentPacket;
use pocketmine\network\mcpe\protocol\ContainerSetSlotPacket;
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
use pocketmine\network\mcpe\protocol\types\ContainerIds;
use pocketmine\Player;
use pocketmine\Server;
@ -238,7 +239,7 @@ class PlayerInventory extends BaseInventory{
$pk->item = $item;
$pk->inventorySlot = $this->getHeldItemSlot();
$pk->hotbarSlot = $this->getHeldItemIndex();
$pk->windowId = ContainerSetContentPacket::SPECIAL_INVENTORY;
$pk->windowId = ContainerIds::INVENTORY;
if(!is_array($target)){
$target->dataPacket($pk);
@ -419,12 +420,11 @@ class PlayerInventory extends BaseInventory{
$pk->entityRuntimeId = $this->getHolder()->getId();
$pk->slots = $armor;
$pk->encode();
$pk->isEncoded = true;
foreach($target as $player){
if($player === $this->getHolder()){
$pk2 = new ContainerSetContentPacket();
$pk2->windowid = ContainerSetContentPacket::SPECIAL_ARMOR;
$pk2->windowid = ContainerIds::ARMOR;
$pk2->slots = $armor;
$pk2->targetEid = $player->getId();
$player->dataPacket($pk2);
@ -467,13 +467,12 @@ class PlayerInventory extends BaseInventory{
$pk->entityRuntimeId = $this->getHolder()->getId();
$pk->slots = $armor;
$pk->encode();
$pk->isEncoded = true;
foreach($target as $player){
if($player === $this->getHolder()){
/** @var Player $player */
$pk2 = new ContainerSetSlotPacket();
$pk2->windowid = ContainerSetContentPacket::SPECIAL_ARMOR;
$pk2->windowid = ContainerIds::ARMOR;
$pk2->slot = $index - $this->getSize();
$pk2->item = $this->getItem($index);
$player->dataPacket($pk2);
@ -523,7 +522,7 @@ class PlayerInventory extends BaseInventory{
public function sendCreativeContents(){
$pk = new ContainerSetContentPacket();
$pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE;
$pk->windowid = ContainerIds::CREATIVE;
if($this->getHolder()->getGamemode() === Player::CREATIVE){
foreach(Item::getCreativeItems() as $i => $item){
$pk->slots[$i] = clone $item;