Fix setting item custom name does not update inventory

If a NamedTag was already present, it was modifying the object directly
WITHOUT serializing the tag back to raw NBT for sending. This commit
fixes that by always serializing the tag on change.
This commit is contained in:
Dylan K. Taylor 2017-01-10 00:38:23 +00:00
parent b566c4e609
commit 058468104a

View File

@ -559,7 +559,7 @@ class Item implements ItemIds, \JsonSerializable{
$this->clearCustomName();
}
if(!($hadCompoundTag = $this->hasCompoundTag())){
if($this->hasCompoundTag()){
$tag = new CompoundTag("", []);
}else{
$tag = $this->getNamedTag();
@ -573,9 +573,7 @@ class Item implements ItemIds, \JsonSerializable{
]);
}
if(!$hadCompoundTag){
$this->setCompoundTag($tag);
}
return $this;
}