Hello, I want to remove 1 item from 1 stack in players hand Code : PHP: $player->getInventory()->removeItem($player->getInventory()->getItemInHand()); But this code will remove 1 stack in players hand
PHP: public function Remove(Player $player) { $inv = $player->getInventory(); $slot = $inv->getHeldItemIndex(); return $inv->setItem($slot, Item::get(Item::AIR)); } and use: $this->Remove($player); to remove item in player's hand
or use remove instead removeItem in your code, but if you use this for remove glass in your inv, if you have 10000 blocks in your inventory this will remove all of glass blocks but if you want just remove items in hand slot, use this:
PHP: $item = $player->getInventory()->getItemInHand();$item->setCount($item->getCount() - 1);$player->getInventory()->setItemInHand($item);
ok wait wait wait What the hell is going on here????? so for start i should say to you upgrade your knowledge in Coding & Pmmp & English bacause i think you didnt see: ok and his code is : What the hell is going on here????? this fucntion : PHP: $inv->removeItem(Item Id Here); will reduce items in player inventory @RicardoMilos384 try it then anwser tyo people and confuse them |: so what is it? what do you mean? what's the problem? removeItem will reduce item in player inv remove will remove all blocks in player inv are you kidding me? @NakiFx also im gonna suicide for: