From 34c2510f0f7ba131a92968589782e935b8af0e04 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Thu, 22 May 2014 19:33:10 +0200 Subject: [PATCH] Allow setting null damage on items --- src/pocketmine/inventory/Inventory.php | 5 +++++ src/pocketmine/item/Item.php | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/inventory/Inventory.php b/src/pocketmine/inventory/Inventory.php index cb00e586c..fd56c7b71 100644 --- a/src/pocketmine/inventory/Inventory.php +++ b/src/pocketmine/inventory/Inventory.php @@ -28,6 +28,7 @@ use pocketmine\item\Item; use pocketmine\Player; interface Inventory{ + const MAX_STACK = 64; public function getSize(); @@ -150,4 +151,8 @@ interface Inventory{ * @return InventoryHolder */ public function getHolder(); + + public function onOpen(Player $who); + + public function onClose(Player $who); } diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index c781725bb..6bfe7a85f 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -475,8 +475,8 @@ class Item{ } public function __construct($id, $meta = 0, $count = 1, $name = "Unknown"){ - $this->id = (int) $id; - $this->meta = (int) $meta; + $this->id = $id & 0xffff; + $this->meta = $meta !== null ? $meta & 0xffff : null; $this->count = (int) $count; $this->name = $name; if(!isset($this->block) and $this->id <= 0xff and isset(Block::$list[$this->id])){ @@ -522,7 +522,7 @@ class Item{ } public function setDamage($meta){ - $this->meta = $meta & 0xFFFF; + $this->meta = $meta !== null ? $meta & 0xFFFF : null; } final public function getMaxStackSize(){