def apply(self, inv_plugin):
        clicked = self.slot
        cursor = inv_plugin.cursor_slot
        if clicked == cursor:
            if self.button == constants.INV_BUTTON_LEFT:
                clicked.amount = 0
            elif self.button == constants.INV_BUTTON_RIGHT:
                clicked.amount -= 1
            self.cleanup_if_empty(clicked)
        elif self.button == constants.INV_BUTTON_LEFT:
            if clicked.stacks_with(cursor):
                self.transfer(cursor, clicked, cursor.amount)
            else:
                self.swap_slots(cursor, clicked)
        elif self.button == constants.INV_BUTTON_RIGHT:
            if cursor.is_empty:
                # transfer half, round up
                self.transfer(clicked, cursor, (clicked.amount + 1) // 2)
            elif clicked.is_empty or clicked.stacks_with(cursor):
                self.transfer(cursor, clicked, 1)
            else:  # slot items do not stack
                self.swap_slots(cursor, clicked)
        else:
            raise NotImplementedError(
                'Clicking with button %s not implemented' % self.button)
dataset/ETHPy150Open SpockBotMC/SpockBot/spockbot/mcdata/windows.py/SingleClick.apply/original