InventoryManager: avoid calling TypeConverter::getInstance() in a loop

This commit is contained in:
Dylan K. Taylor 2023-03-20 23:24:52 +00:00
parent ee72e80fbb
commit ecc830a689
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -479,8 +479,9 @@ class InventoryManager{
$entry->predictions = [];
$entry->pendingSyncs = [];
$contents = [];
$typeConverter = TypeConverter::getInstance();
foreach($inventory->getContents(true) as $slot => $item){
$itemStack = TypeConverter::getInstance()->coreItemStackToNet($item);
$itemStack = $typeConverter->coreItemStackToNet($item);
$info = $this->trackItemStack($entry, $slot, $itemStack, null);
$contents[] = new ItemStackWrapper($info->getStackId(), $itemStack);
}