When coding my client I wanted to be able to add custom splash texts to
the main menu, I tried creating a txt file and putting them in there and
changing the address the splashes.txt to my one.
That worked in Eclipse but when I recompiled and put it in my client it didn't work, the reason for this is that MCP only reads .java/class files so it didn't include it and I didn't want to have to manually include it every time so I came up with a workaround.
1) First create a file called SplashHandler and put it anywhere.
2) Then inside it you want to create a method and add this to it
3) Then change the Text 1, Text 2 etc except for the last one that says SplashHandler error, this will tell you if anything goes wrong.
4) If you want to add anymore then copy and paste one of the text lines and add it in, don't forget to change
by adding another number to the 6.
5) Now go to the class file, GuiMainMenu and change
to
6) Now comment out or delete this code
Hope you like the tutorial and I understand this may have not been the best way to do this but it is a way nontheless.
Credit to:-Keir
That worked in Eclipse but when I recompiled and put it in my client it didn't work, the reason for this is that MCP only reads .java/class files so it didn't include it and I didn't want to have to manually include it every time so I came up with a workaround.
1) First create a file called SplashHandler and put it anywhere.
2) Then inside it you want to create a method and add this to it
3) Then change the Text 1, Text 2 etc except for the last one that says SplashHandler error, this will tell you if anything goes wrong.
4) If you want to add anymore then copy and paste one of the text lines and add it in, don't forget to change
Code:
randomNumber.nextInt(6)
5) Now go to the class file, GuiMainMenu and change
Code:
splashText = "missingno";
Code:
splashText = SplashHandler.splashHandler()
Code:
try
{
ArrayList arraylist = new ArrayList();
// Infiltrator
//BufferedReader bufferedreader = new BufferedReader(new
InputStreamReader((net.minecraft.src.GuiMainMenu.class).getResourceAsStream("/title/splashes.txt"),
Charset.forName("UTF-8")));
BufferedReader bufferedreader = new BufferedReader(new
InputStreamReader((net.minecraft.src.GuiMainMenu.class).getResourceAsStream("/bt/iKeirNez/Infiltrator/Resources/splash.txt"),
Charset.forName("UTF-8")));
String s = "";
do
{
String s1;
if ((s1 = bufferedreader.readLine()) == null)
{
break;
}
s1 = s1.trim();
if (s1.length() > 0)
{
arraylist.add(s1);
}
}
while (true);
do
{
splashText = (String)arraylist.get(rand.nextInt(arraylist.size()));
}
while (splashText.hashCode() == 0x77f432f);
}
catch (Exception exception) { }
updateCounter = rand.nextFloat();
Hope you like the tutorial and I understand this may have not been the best way to do this but it is a way nontheless.
Credit to:-Keir
No comments:
Post a Comment