Fixed Item->equals() not working for no-NBT items since 9bb3c93285d8589cde855b08318e32514eff78c4

This commit is contained in:
Dylan K. Taylor 2018-10-29 12:45:39 +00:00
parent 3760307a88
commit 95be571481

View File

@ -785,10 +785,11 @@ class Item implements ItemIds, \JsonSerializable{
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($checkCompound){
if($this->hasNamedTag() and $item->hasNamedTag()){
//Serialized NBT didn't match, check the cached object tree.
if($this->hasNamedTag() and $item->hasNamedTag()){ //both items have NBT
return $this->getNamedTag()->equals($item->getNamedTag());
}
return (!$this->hasNamedTag() and !$item->hasNamedTag()); //both items must have no NBT
}else{
return true;
}