From ffa3e8a0aa3bbf01b4344d61b620a84ba85bb2ad Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 26 May 2014 10:46:30 +0200 Subject: [PATCH] Fixes for Chest & Furnace --- src/pocketmine/Player.php | 3 +-- src/pocketmine/tile/Chest.php | 14 ++++++++------ src/pocketmine/tile/Furnace.php | 14 ++++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index f626c955d..75d47b169 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2057,12 +2057,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ } $this->craftingItems = []; } - break; }else{ $this->toCraft = []; $this->craftingItems = []; } - if(!isset($this->windowIndex[$packet->windowid])){ + if($packet->windowid == 0 or !isset($this->windowIndex[$packet->windowid])){ break; } diff --git a/src/pocketmine/tile/Chest.php b/src/pocketmine/tile/Chest.php index 1d3af6a61..ed5d9254a 100644 --- a/src/pocketmine/tile/Chest.php +++ b/src/pocketmine/tile/Chest.php @@ -55,8 +55,8 @@ class Chest extends Spawnable implements InventoryHolder, Container{ } public function saveNBT(){ - $this->namedtag->Inventory = new Enum("Inventory", []); - $this->namedtag->Inventory->setTagType(NBT::TAG_Compound); + $this->namedtag->Items = new Enum("Items", []); + $this->namedtag->Items->setTagType(NBT::TAG_Compound); for($index = 0; $index < $this->getSize(); ++$index){ $this->setItem($index, $this->inventory->getItem($index)); } @@ -110,9 +110,6 @@ class Chest extends Spawnable implements InventoryHolder, Container{ */ public function setItem($index, Item $item){ $i = $this->getSlotIndex($index); - if($i < 0){ - return false; - } $d = new Compound(false, array( new Byte("Count", $item->getCount()), @@ -126,7 +123,12 @@ class Chest extends Spawnable implements InventoryHolder, Container{ unset($this->namedtag->Items[$i]); } }elseif($i < 0){ - $this->namedtag->Items[] = $d; + for($i = 0; $i <= $this->getSize(); ++$i){ + if(!isset($this->namedtag->Items[$i])){ + break; + } + } + $this->namedtag->Items[$i] = $d; }else{ $this->namedtag->Items[$i] = $d; } diff --git a/src/pocketmine/tile/Furnace.php b/src/pocketmine/tile/Furnace.php index 95e54f449..7931e6bc3 100644 --- a/src/pocketmine/tile/Furnace.php +++ b/src/pocketmine/tile/Furnace.php @@ -60,8 +60,8 @@ class Furnace extends Tile implements InventoryHolder, Container{ } public function saveNBT(){ - $this->namedtag->Inventory = new Enum("Inventory", []); - $this->namedtag->Inventory->setTagType(NBT::TAG_Compound); + $this->namedtag->Items = new Enum("Inventory", []); + $this->namedtag->Items->setTagType(NBT::TAG_Compound); for($index = 0; $index < $this->getSize(); ++$index){ $this->setItem($index, $this->inventory->getItem($index)); } @@ -115,9 +115,6 @@ class Furnace extends Tile implements InventoryHolder, Container{ */ public function setItem($index, Item $item){ $i = $this->getSlotIndex($index); - if($i < 0){ - return false; - } $d = new Compound(false, array( new Byte("Count", $item->getCount()), @@ -131,7 +128,12 @@ class Furnace extends Tile implements InventoryHolder, Container{ unset($this->namedtag->Items[$i]); } }elseif($i < 0){ - $this->namedtag->Items[] = $d; + for($i = 0; $i <= $this->getSize(); ++$i){ + if(!isset($this->namedtag->Items[$i])){ + break; + } + } + $this->namedtag->Items[$i] = $d; }else{ $this->namedtag->Items[$i] = $d; }