Thank you all for trying to point me out where to find the source/recomp library, but I know where would it be, it is just not present in my External Libraries list now, when I work with 1.16.1. The only way I can access it is from file explorer. Maybe some configuration error. Anyway, this thread seems to have deviated much from the topic.
I wrote a function:
public static void giveItemStack(PlayerEntity player, ItemStack stack) {
if (!player.addItemStackToInventory(stack)) {
player.dropItem(stack, false);
}
}
that now works pretty much the same as the /give command, which is exactly what I wanted.
Thanks @Dzuchun for that precious piece of information.