mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 19:59:11 +00:00
Add __clone to CompoundTag and ListTag, fixed issues with items sharing the same NBT tag objects
This commit is contained in:
@@ -111,4 +111,12 @@ class CompoundTag extends NamedTag implements \ArrayAccess{
|
|||||||
}
|
}
|
||||||
return $str . "}";
|
return $str . "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __clone(){
|
||||||
|
foreach($this as $key => $tag){
|
||||||
|
if($tag instanceof Tag){
|
||||||
|
$this->{$key} = clone $tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -220,4 +220,12 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{
|
|||||||
}
|
}
|
||||||
return $str . "}";
|
return $str . "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __clone(){
|
||||||
|
foreach($this as $key => $tag){
|
||||||
|
if($tag instanceof Tag){
|
||||||
|
$this->{$key} = clone $tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user