399 IS A NUMBER, but it is also a Object like Sander said if it is an OBJECT i can use get(399, 0) but if its a block I use getId() === 35
Just try this code and you will see: Again, if it doesn’t work, try adding elses to your ifs to find out your exact problem. Item::get() always returns an Item object (object). $item->getId() always returns the ID of the item (integer). That means $item->getId() === Item::get(1) can NEVER work because getId() returns an integer and Item::get() an Item object.
Checked and I think I found the problem. I tried using the onheld function with adding an effect at the same time as adding an item. The effect part worked because I got speed 1 when I held the block. Is there a diffrent way of adding the item?
PHP: $player->getInventory()->addItem(Item::get(1, 0, 1)); Is the part that doesnt work because when I used that and made it add effects also it added the effects but didnt give the other item.
PHP: <?phpnamespace MSelector;use pocketmine\event\Listener;use pocketmine\event\PlayerInteractEvent; // wot https://github.com/pmmp/PocketMine-MP/tree/master/src/pocketmine/event
Are you sure there aren’t any errors in console? Are you sure that item has really been added to inventory?
Compare the IDs, not the objects. Comparing two different objects will make it false as they are, wait for it, different. They may be of the same class, but that doesn't mean they are the same object. Just look here for proof.