From 914098310c0a6706e8f484ffd13ce4771ea5e9c5 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 1 Mar 2014 11:26:19 +0100 Subject: [PATCH] Guess NBTTag_List components type automatically --- src/nbt/tags/TAG_List.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/nbt/tags/TAG_List.php b/src/nbt/tags/TAG_List.php index e54f8c65d..328a9b764 100644 --- a/src/nbt/tags/TAG_List.php +++ b/src/nbt/tags/TAG_List.php @@ -168,6 +168,17 @@ class NBTTag_List extends NamedNBTTag implements ArrayAccess, Iterator{ } public function write(NBT $nbt){ + if(!isset($this->tagType)){ + foreach($this->value as $tag){ + if(!isset($id)){ + $id = $tag->getType(); + }elseif($id !== $tag->getType()){ + return false; + } + } + $this->tagType = $id; + } + $nbt->putByte($this->tagType); $nbt->putInt(count($this->value)); foreach($this->value as $tag){