Jump to content

Connect to the server by a button.


Creepmander

Recommended Posts

Hi!

I wanna ask it, what do you think about it? It is possible? If it is, how? :?

They are the main questions :) I tryed to find it, but i couldn't.

[Harder Description]

For example: I have gota GuiScreen...mmm like the MainMenu, and i wanna make a button which connect to the "localhost:25565" server by a click.

I cant describe more easy. :D

Link to comment
Share on other sites

There are 2 ways of doing this: Either you use Forge to change GuiMainMenu to MyGuiMainMenu (using If's and Ticks) - this option will work only for one mod (yours) and will cause incompatibility with other MainMenu-changing-mods.

Or you just change vanillia code and every time you instal your mod, you change minecraft.jar files :C

 

 

Note: You can also make Button that will make your account relog to other server INGAME (more compatibility) For example you make Gui that will be shown when you click ,,P" on keyboard and there will be Button that will use Method that will relog you from one server to another or from SP to MP or something.

 

 

Skipping to code: (I am refering to GuiMainMenu BaseClass editing, to make Ticking stuff with Forge you will just need to use proper methods, hope you know them)

//In GuiMainMenu:
private void addSingleplayerMultiplayerButtons(int par1, int par2)
{
//Add this, remember to move around your button to not hide it under others.
this.buttonList.add(new GuiButton(ID, this.width / 2 - 100, par1, I18n.getString("MyServer")));
}
protected void actionPerformed(GuiButton par1GuiButton)
{
//Add this:
if (par1GuiButton.id == ID)
{
	this.mc.displayGuiScreen(new GuiConnecting(this, mc, "myip.com", 12345)); //this number is port
}
}

Well thats is :P

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

There are 2 ways of doing this: Either you use Forge to change GuiMainMenu to MyGuiMainMenu (using If's and Ticks) - this option will work only for one mod (yours) and will cause incompatibility with other MainMenu-changing-mods.

Or you just change vanillia code and every time you instal your mod, you change minecraft.jar files :C

 

 

Note: You can also make Button that will make your account relog to other server INGAME (more compatibility) For example you make Gui that will be shown when you click ,,P" on keyboard and there will be Button that will use Method that will relog you from one server to another or from SP to MP or something.

 

 

Skipping to code: (I am refering to GuiMainMenu BaseClass editing, to make Ticking stuff with Forge you will just need to use proper methods, hope you know them)

//In GuiMainMenu:
private void addSingleplayerMultiplayerButtons(int par1, int par2)
{
//Add this, remember to move around your button to not hide it under others.
this.buttonList.add(new GuiButton(ID, this.width / 2 - 100, par1, I18n.getString("MyServer")));
}
protected void actionPerformed(GuiButton par1GuiButton)
{
//Add this:
if (par1GuiButton.id == ID)
{
	this.mc.displayGuiScreen(new GuiConnecting(this, mc, "myip.com", 12345)); //this number is port
}
}

Well thats is :P

Or you could use reflection to add a button to the main game gui ;)

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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