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

@ -153,6 +153,7 @@ use pocketmine\network\mcpe\protocol\StartGamePacket;
use pocketmine\network\mcpe\protocol\TakeItemEntityPacket;
use pocketmine\network\mcpe\protocol\TextPacket;
use pocketmine\network\mcpe\protocol\TransferPacket;
use pocketmine\network\mcpe\protocol\types\ContainerIds;
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
use pocketmine\network\mcpe\protocol\UseItemPacket;
@ -2761,21 +2762,21 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
switch($packet->windowid){
case ContainerSetContentPacket::SPECIAL_INVENTORY: //Normal inventory change
case ContainerIds::INVENTORY: //Normal inventory change
if($packet->slot >= $this->inventory->getSize()){
return false;
}
$transaction = new BaseTransaction($this->inventory, $packet->slot, $this->inventory->getItem($packet->slot), $packet->item);
break;
case ContainerSetContentPacket::SPECIAL_ARMOR: //Armour change
case ContainerIds::ARMOR: //Armour change
if($packet->slot >= 4){
return false;
}
$transaction = new BaseTransaction($this->inventory, $packet->slot + $this->inventory->getSize(), $this->inventory->getArmorItem($packet->slot), $packet->item);
break;
case ContainerSetContentPacket::SPECIAL_HOTBAR: //Hotbar link update
case ContainerIds::HOTBAR: //Hotbar link update
//hotbarSlot 0-8, slot 9-44
$this->inventory->setHotbarSlotIndex($packet->hotbarSlot, $packet->slot - 9);
return true;