mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +00:00
BaseInventory: fixed items with userdata stacking with items without userdata
This commit is contained in:
parent
a30b1fb6d5
commit
ab5b4d112b
@ -253,11 +253,9 @@ abstract class BaseInventory implements Inventory{
|
|||||||
|
|
||||||
public function canAddItem(Item $item) : bool{
|
public function canAddItem(Item $item) : bool{
|
||||||
$item = clone $item;
|
$item = clone $item;
|
||||||
$checkDamage = !$item->hasAnyDamageValue();
|
|
||||||
$checkTags = $item->hasCompoundTag();
|
|
||||||
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
|
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
|
||||||
$slot = $this->getItem($i);
|
$slot = $this->getItem($i);
|
||||||
if($item->equals($slot, $checkDamage, $checkTags)){
|
if($item->equals($slot)){
|
||||||
if(($diff = $slot->getMaxStackSize() - $slot->getCount()) > 0){
|
if(($diff = $slot->getMaxStackSize() - $slot->getCount()) > 0){
|
||||||
$item->setCount($item->getCount() - $diff);
|
$item->setCount($item->getCount() - $diff);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user