Jump to content

How do I add a server to the server list using a mod?


The_Fireplace

Recommended Posts

I have a modpack and I am working on a mod to put in it that I want to automatically a.) Check to see if the official server is on the list and b.) add it to the server list if it isn't already there. How would I go about doing that?

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Link to comment
Share on other sites

If you really want to do it from mod, why not looking into GuiMultiplayer?

 

Two ways:

1. Decode servers.dat (I belive it's NBT format, check out read/write methods) on mod startup, check if server entry exists and add your own if not.

 

2. Add server entry manually in gui screen.

Few things:

- You can only add the servers when the Gui is opened. Since GuiMultiplayer extends GuiScreen you can subscribe to GuiOpenEvent check if newGui is instanceof GuiMultiplayer and if so, pass an argument to add entry if it doesn't exist.

Edit: Actually no, GuiOpenEvent will be fired before server lists exist (I think), so you will have to make some Integer in client proxy which will be your "delay" and then launch code (you will also need ClientTickEvent to count-down).

 

Provide some code for more help.

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

Link to comment
Share on other sites

You don't need a mod for that. Just go to your Minecraft, remove all servers and add the default one. Copy the servers.dat file in .minecraft to your mod pack main directory.

Wouldt that remove other servers the user has added every time the pack updates? Just because I want to add the official server doesn't mean no other server will be running the modpack.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

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.