mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
InventoryManager: avoid useless work in trackItemStack()
this attempts to accommodate slots being set to themselves, which is a rare enough occurrence (only plugins will cause it) that it doesn't make sense to penalize every inventory update this way. attempting to avoid changing the itemstackID in this way is detrimental to performance, and it doesn't actually matter if we set a new itemstackID anyway.
This commit is contained in:
@ -603,11 +603,6 @@ class InventoryManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function trackItemStack(InventoryManagerEntry $entry, int $slotId, ItemStack $itemStack, ?int $itemStackRequestId) : ItemStackInfo{
|
private function trackItemStack(InventoryManagerEntry $entry, int $slotId, ItemStack $itemStack, ?int $itemStackRequestId) : ItemStackInfo{
|
||||||
$existing = $entry->itemStackInfos[$slotId] ?? null;
|
|
||||||
if($existing !== null && $existing->getItemStack()->equals($itemStack) && $existing->getRequestId() === $itemStackRequestId){
|
|
||||||
return $existing;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: ItemStack->isNull() would be nice to have here
|
//TODO: ItemStack->isNull() would be nice to have here
|
||||||
$info = new ItemStackInfo($itemStackRequestId, $itemStack->getId() === 0 ? 0 : $this->newItemStackId(), $itemStack);
|
$info = new ItemStackInfo($itemStackRequestId, $itemStack->getId() === 0 ? 0 : $this->newItemStackId(), $itemStack);
|
||||||
return $entry->itemStackInfos[$slotId] = $info;
|
return $entry->itemStackInfos[$slotId] = $info;
|
||||||
|
Reference in New Issue
Block a user