mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Fixed Item->equals() not working for no-NBT items since 9bb3c93285
This commit is contained in:
@ -785,10 +785,11 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
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())){
|
if($this->id === $item->getId() and (!$checkDamage or $this->getDamage() === $item->getDamage())){
|
||||||
if($checkCompound){
|
if($checkCompound){
|
||||||
if($this->hasNamedTag() and $item->hasNamedTag()){
|
if($this->hasNamedTag() and $item->hasNamedTag()){ //both items have NBT
|
||||||
//Serialized NBT didn't match, check the cached object tree.
|
|
||||||
return $this->getNamedTag()->equals($item->getNamedTag());
|
return $this->getNamedTag()->equals($item->getNamedTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (!$this->hasNamedTag() and !$item->hasNamedTag()); //both items must have no NBT
|
||||||
}else{
|
}else{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user