Jump to content

How to click GUI buttons with code


Recommended Posts

I want to be able to press buttons inside the server disconnected GUI and the Server select GUI from a client-side mod. I am playing on an SMP with a few other people, and we build lots of farms in which a lot of people afk. AFK-ing is fully allowed on the server, but my internet cuts out quite frequently, so I wanted to make a forge mod that would automatically reconnect (I know there is an autoreconnect mod for fabric, but we use forge mods on the client-side for a lot of things). I have tried

mc.currentScreen.mouseClicked(x, y, 0);
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.MouseClickedEvent.Pre(mc.currentScreen, x, y, 0));

, but I need a way to find the "back to server menu" button's location, as it changes depending on GUI scale. I also tried doing mouseClicked(x,y,0) for every 10th pixel, but that still didn't work, so maybe this just doesn't work. please help. 

Link to comment
Share on other sites

  • Guest locked this topic
This topic is now closed to further replies.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.