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

@ -27,17 +27,11 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\ContainerIds;
class ContainerSetContentPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::CONTAINER_SET_CONTENT_PACKET;
const SPECIAL_INVENTORY = 0;
const SPECIAL_OFFHAND = 0x77;
const SPECIAL_ARMOR = 0x78;
const SPECIAL_CREATIVE = 0x79;
const SPECIAL_HOTBAR = 0x7a;
const SPECIAL_FIXED_INVENTORY = 0x7b;
public $windowid;
public $targetEid;
public $slots = [];
@ -70,7 +64,7 @@ class ContainerSetContentPacket extends DataPacket{
foreach($this->slots as $slot){
$this->putSlot($slot);
}
if($this->windowid === self::SPECIAL_INVENTORY and count($this->hotbar) > 0){
if($this->windowid === ContainerIds::INVENTORY and count($this->hotbar) > 0){
$this->putUnsignedVarInt(count($this->hotbar));
foreach($this->hotbar as $slot){
$this->putVarInt($slot);

View File

@ -0,0 +1,38 @@
<?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/
*
*
*/
declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol\types;
interface ContainerIds{
const NONE = -1;
const INVENTORY = 0;
const FIRST = 1;
const LAST = 100;
const OFFHAND = 119;
const ARMOR = 120;
const CREATIVE = 121;
const HOTBAR = 122;
const FIXED_INVENTORY = 123;
}