CraftItemEvent has functions you can use. Look at the source: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/event/inventory/CraftItemEvent.php