InventoryManager: avoid use of PlayerHotbarPacket

it doesn't work so well when the selected slot is empty.
This commit is contained in:
Dylan K. Taylor 2019-08-10 18:09:38 +01:00
parent 85ad78dda8
commit 399f9242e0

View File

@ -36,7 +36,7 @@ use pocketmine\network\mcpe\protocol\ContainerOpenPacket;
use pocketmine\network\mcpe\protocol\ContainerSetDataPacket; use pocketmine\network\mcpe\protocol\ContainerSetDataPacket;
use pocketmine\network\mcpe\protocol\InventoryContentPacket; use pocketmine\network\mcpe\protocol\InventoryContentPacket;
use pocketmine\network\mcpe\protocol\InventorySlotPacket; use pocketmine\network\mcpe\protocol\InventorySlotPacket;
use pocketmine\network\mcpe\protocol\PlayerHotbarPacket; use pocketmine\network\mcpe\protocol\MobEquipmentPacket;
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds; use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
use pocketmine\network\mcpe\protocol\types\inventory\WindowTypes; use pocketmine\network\mcpe\protocol\types\inventory\WindowTypes;
use pocketmine\player\Player; use pocketmine\player\Player;
@ -146,7 +146,12 @@ class InventoryManager{
} }
public function syncSelectedHotbarSlot() : void{ public function syncSelectedHotbarSlot() : void{
$this->session->sendDataPacket(PlayerHotbarPacket::create($this->player->getInventory()->getHeldItemIndex(), ContainerIds::INVENTORY)); $this->session->sendDataPacket(MobEquipmentPacket::create(
$this->player->getId(),
$this->player->getInventory()->getItemInHand(),
$this->player->getInventory()->getHeldItemIndex(),
ContainerIds::INVENTORY
));
} }
public function syncCreative() : void{ public function syncCreative() : void{