So I am coding a AFK mod which basically holds left click in servers (Skyblock). The problem is that once I tabbed out , the island sometimes restarts and I am warped to the community centre. I have coded so it automatically rejoin, but it doesn't hold left click anymore even I used the setKeyBindState method for keyBindAttack(I am tabbed out at this point). But after I went in the game window again, it somehow works again without me pressing left click. So is there any way that I can make setKeyBindState work after tabbing out and rejoining a server?
P.S. I observed that after rejoining the server if I am tabbed out, my mouse cursor would somehow move to the centre of the game screen automatically so maybe some other code is affecting.