Move inventory ID constants to their own interface

ContainerSetContentPacket will be removed in 1.2, and these aren't specific to ContainerSetContentPacket anyway.
This commit is contained in:
Dylan K. Taylor
2017-07-12 20:01:46 +01:00
parent a5c6c8b973
commit 5283975f20
4 changed files with 49 additions and 15 deletions

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);
@ -424,7 +425,7 @@ class PlayerInventory extends BaseInventory{
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);
@ -473,7 +474,7 @@ class PlayerInventory extends BaseInventory{
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 +524,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;