$chest = getTile(Vector 3(X,y,Z)) if(chest instanceof Chest){ $chest->getInventory ()->addItem(item) } As i'm lazy i make you code.