Add __clone to CompoundTag and ListTag, fixed issues with items sharing the same NBT tag objects

This commit is contained in:
Dylan K. Taylor 2017-03-29 13:55:10 +01:00
parent bc1c75a15a
commit 868602a559
2 changed files with 16 additions and 0 deletions

View File

@ -111,4 +111,12 @@ class CompoundTag extends NamedTag implements \ArrayAccess{
}
return $str . "}";
}
public function __clone(){
foreach($this as $key => $tag){
if($tag instanceof Tag){
$this->{$key} = clone $tag;
}
}
}
}

View File

@ -220,4 +220,12 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{
}
return $str . "}";
}
public function __clone(){
foreach($this as $key => $tag){
if($tag instanceof Tag){
$this->{$key} = clone $tag;
}
}
}
}