int tSlot = targetSlots[i];
ItemStack targetStack = target.getStackInSlot(tSlot);
if(targetStack != null && target.canExtractItem(i, targetStack, side.getOpposite().ordinal())) {
int res = ItemUtil.doInsertItem(this, targetStack, side.getOpposite());
if(res > 0) {
targetStack = targetStack.copy();
targetStack.stackSize -= res;
if(targetStack.stackSize <= 0) {
targetStack = null;
}
target.setInventorySlotContents(tSlot, targetStack);