Jump to content

[SOLVED] Add element to world list without editing base classes!


Rexozz

Recommended Posts

add an element to the vanilla world list!

 

What?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Oh. You're trying to add another line of text to the screen that lets you pick a world to play (the "load a save" screen).

 

The not-coremod way of doing this would be to create your own GUI screen and replace it when the vanilla one is invoked (there's events for that).

 

This probably isn't the best way (COG does stuff in a way that's a holdover from when another person was maintaining it, all I did was make sure that it continued to work on 1.10--also that code only adds a button to the "create new world" screen rather than replacing the entire GUI).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Oh. You're trying to add another line of text to the screen that lets you pick a world to play (the "load a save" screen).

 

The not-coremod way of doing this would be to create your own GUI screen and replace it when the vanilla one is invoked (there's events for that).

 

This probably isn't the best way (COG does stuff in a way that's a holdover from when another person was maintaining it, all I did was make sure that it continued to work on 1.10--also that code only adds a button to the "create new world" screen rather than replacing the entire GUI).

Whoahh, thank you so much!

Actually, that would be so easy if I wouldn't think so complicated!

First I tried to do it with java reflection! How stupid can I be? ;D:o

 

You probably do not need to replace the whole GuiScreen.

Is there another way to achieve this?

Link to comment
Share on other sites

Yeahhhhh, got my computer to work!

 

Now this is my result:

Unbenannt-2.png

 

Everything works perfectly! Thanks ^^

 

EDIT: If someone else has problems with this:

1. Copy the classes GuiWorldSelection, GuiListWorldSelection and GuiListWorldSelectionEntry to your mod and edit the drawEntry method in the GuiListWorldSelectionEntry class

2. Create an class that does this:

You can easily draw additional stuff onto an existing

GuiScreen

using

GuiScreenEvent.DrawScreenEvent

(you could also use the InitGuiEvent like I, depends on what you want to do! When the events are called is really self-explanatory)

And register the event in your client proxy or client side in your main mod or common proxy init method!

3. Here's the source for the event class:

http://pastebin.com/w1E98q97

 

Don't know if there's an easier way but I hope it helps ^^

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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