Use constructor parameter for ListTags instead of setTagType() and removed some unnecessary type setting

This commit is contained in:
Dylan K. Taylor 2017-10-14 13:49:24 +01:00
parent f5abed95ec
commit cd8006e242
2 changed files with 2 additions and 6 deletions

View File

@ -49,8 +49,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
$this->inventory = new ChestInventory($this);
if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof ListTag)){
$this->namedtag->Items = new ListTag("Items", []);
$this->namedtag->Items->setTagType(NBT::TAG_Compound);
$this->namedtag->Items = new ListTag("Items", [], NBT::TAG_Compound);
}
for($i = 0; $i < $this->getSize(); ++$i){
@ -81,7 +80,6 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
public function saveNBT(){
$this->namedtag->Items->setValue([]);
$this->namedtag->Items->setTagType(NBT::TAG_Compound);
for($index = 0; $index < $this->getSize(); ++$index){
$this->setItem($index, $this->inventory->getItem($index));
}

View File

@ -66,8 +66,7 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
$this->inventory = new FurnaceInventory($this);
if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof ListTag)){
$this->namedtag->Items = new ListTag("Items", []);
$this->namedtag->Items->setTagType(NBT::TAG_Compound);
$this->namedtag->Items = new ListTag("Items", [], NBT::TAG_Compound);
}
for($i = 0; $i < $this->getSize(); ++$i){
@ -110,7 +109,6 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{
public function saveNBT(){
$this->namedtag->Items->setValue([]);
$this->namedtag->Items->setTagType(NBT::TAG_Compound);
for($index = 0; $index < $this->getSize(); ++$index){
$this->setItem($index, $this->inventory->getItem($index));
}