Fixes for Chest & Furnace

This commit is contained in:
Shoghi Cervantes 2014-05-26 10:46:30 +02:00
parent 274f972b58
commit ffa3e8a0aa
3 changed files with 17 additions and 14 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}