What's the method for getting an item stack from the slot of either an entity or tile entity? I need to input a slot as an integer and return an ItemStack.
To get it from a tile entity, I've been using
(IInventory) replace.getSource().getWorld().getTileEntity(sourcePos).getStackInSlot(sourceSlot)
which works properly, but someone else told me that IInventory won't work for anything outside of the vanilla game and that I should instead use the "IItemHandler wrapper." Not sure exactly what that is though.
However, I still haven't figured out how to do this with mobs, so I could use some help with that.
Edit: I suppose I should specify that this is being used for a command (the above code line is in ".executes((replace) -> {})")