From d4cc7d13cd33568c881ab7bca18f2267cbde5542 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 19 May 2017 19:11:36 +0100 Subject: [PATCH] Fixed setValue() being useless for CompoundTags and ListTags --- src/pocketmine/nbt/tag/CompoundTag.php | 10 ++++++++++ src/pocketmine/nbt/tag/ListTag.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/pocketmine/nbt/tag/CompoundTag.php b/src/pocketmine/nbt/tag/CompoundTag.php index 45ab5bf6d..0448f0580 100644 --- a/src/pocketmine/nbt/tag/CompoundTag.php +++ b/src/pocketmine/nbt/tag/CompoundTag.php @@ -49,6 +49,16 @@ class CompoundTag extends NamedTag implements \ArrayAccess{ return $count; } + public function setValue($value){ + if(is_array($value)){ + foreach($value as $name => $tag){ + if($tag instanceof NamedTag){ + $this->{$name} = $tag; + } + } + } + } + public function offsetExists($offset){ return isset($this->{$offset}) and $this->{$offset} instanceof Tag; } diff --git a/src/pocketmine/nbt/tag/ListTag.php b/src/pocketmine/nbt/tag/ListTag.php index 821744c61..6c8e70a68 100644 --- a/src/pocketmine/nbt/tag/ListTag.php +++ b/src/pocketmine/nbt/tag/ListTag.php @@ -48,6 +48,16 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{ return $value; } + public function setValue($value){ + if(is_array($value)){ + foreach($value as $name => $tag){ + if($tag instanceof NamedTag){ + $this->{$name} = $tag; + } + } + } + } + public function getCount(){ $count = 0; foreach($this as $tag){