mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 23:45:34 +00:00
Item: do not compare serialized NBT in equals()
this isn't cached anymore, and would be a performance drag. It would be nice to have some kind of fast path for this, but comparing NBT binary isn't it.
This commit is contained in:
parent
6c7dada232
commit
9b02b8e51e
@ -735,20 +735,9 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
* @param bool $checkCompound Whether to verify that the items' NBT match.
|
* @param bool $checkCompound Whether to verify that the items' NBT match.
|
||||||
*/
|
*/
|
||||||
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
|
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
|
||||||
if($this->id === $item->getId() and (!$checkDamage or $this->getDamage() === $item->getDamage())){
|
return $this->id === $item->getId() and
|
||||||
if($checkCompound){
|
(!$checkDamage or $this->getDamage() === $item->getDamage()) and
|
||||||
if($item->getCompoundTag() === $this->getCompoundTag()){
|
(!$checkCompound or $this->getNamedTag()->equals($item->getNamedTag()));
|
||||||
return true;
|
|
||||||
}elseif($this->hasCompoundTag() and $item->hasCompoundTag()){
|
|
||||||
//Serialized NBT didn't match, check the cached object tree.
|
|
||||||
return $this->getNamedTag()->equals($item->getNamedTag());
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user