mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
fix
This commit is contained in:
parent
42fc07a888
commit
655fa87fb8
1 changed files with 25 additions and 0 deletions
|
|
@ -439,6 +439,31 @@ class Player{
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function removeItem($type, $damage, $count, $send = true){
|
||||
while($count > 0){
|
||||
$remove = 0;
|
||||
foreach($this->inventory as $s => $item){
|
||||
if($item->getID() === $type and $item->getMetadata() === $damage){
|
||||
$remove = min($count, $item->count);
|
||||
if($remove < $item->count){
|
||||
$item->count -= $remove;
|
||||
}else{
|
||||
$this->inventory[$s] = BlockAPI::getItem(AIR, 0, 0);
|
||||
}
|
||||
if($send === true){
|
||||
$this->sendInventorySlot($s);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($remove <= 0){
|
||||
return false;
|
||||
}
|
||||
$count -= $remove;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $slot
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue