ItemSerializer: avoid slow NBT check

hasNamedTag() rebuilds the NBT from item properties to decide if there's any NBT.
This is a waste of resources when we then fetch the tag to encode anyway.
This commit is contained in:
Dylan K. Taylor
2025-09-10 20:06:35 +01:00
parent 54e8ad2a9c
commit c854f2c765

View File

@@ -117,8 +117,8 @@ final class ItemSerializer{
$data = $serializer($item);
}
if($item->hasNamedTag()){
$resultTag = $item->getNamedTag();
if($resultTag->count() > 0){
$extraTag = $data->getTag();
if($extraTag !== null){
$resultTag = $resultTag->merge($extraTag);