Hey there, how can I add items to a chest every second? I got this code: PHP: $chest = $this->getMatch()->getMap()->getLevel()->getTile($team->getSpawnChestPos());$inv = $chest->getInventory();if($inv->canAddItem($this->item)) { $inv->setItem($inv->firstEmpty(), $this->item);} And this all gets called every second. But firstEmpty() returns the $index where no item is, but I want that the item stacks. How can I do that?
Thats not the problem. I got that what I wrote in the first post and that gets called every second. But how can I do it, that the Inventory gets the first place, to add the item? With the first place I mean, the first where the same item is and where it's not full stacked.
PHP: $chest = $lv->getTile(new Vector3($x,$y,$z));if ($chest instanceof Chest){ $chest->getInventory()->addItem(Item::get(1,0,64));}