Is there a piece of code that senses what world you currently have open? If so, please send it here, also is any explaining is needed, than explain please... Thanks!
instead of mc, you need to do ModLoader.getMinecraftInstance().
Some classes don't have access to mc, so you use the above thing instead.
Hmm... I can't seem to get this method to work either. Could you please give me an example of it being used? Such as to find the name of the current world you have open?
Edit: Would I use it like this If I wanted to print the name of the current world open?
public static void derprp(){
ModLoader modldr = new ModLoader();
System.out.println(modldr.getMinecraftInstance());
}
Hmm... That doesn't seem to work... It just prints "net.minecraft.src.MinecraftAppletImpl@670cfa"
Hmm... I can't seem to get this method to work either. Could you please give me an example of it being used? Such as to find the name of the current world you have open?
I'm not 100% on how to show the world name, although this is the code that does it in the world select screen
For ModLoader:
ModLoader.getMinecraftInstance().thePlayer
is the same as
mc.thePlayer
ModLoader.getMinecraftInstance().theWorld
is the same as
mc.theWorld
hmm.... I can't seem to get that to print the world name, it just prints "net.minecraft.src.MinecraftAppletImpl@670cfa." Would there be a way to possibly copy the mc.theWorld code, or make it accesible?
And this is SOOO close to what I need... the only problem is that I can't use "var7" (what holds the information of the world name) because it isn't static, and I can't make it static because there's a "this" in the top line, and "par1" can't be static unless it has another method, which I tried to build, but then you have to make a "try, catch" method which is a 50% chance it will work. I'm going to try and figure out how minecraft prints this out. In the meantime, sleepy time. 'night!
I tried mc.theWorld.getWorldInfo() awhile ago and got some weird thing, not knowing it extended to .getWorldName
When I did mc.theWorld.getWorldInfo().getWorldName(), I only got MpServer regardless of the world name.
World world = mc.theWorld;
hmm... it says "mc" cannot be resolved to a variable. Any help?
Some classes don't have access to mc, so you use the above thing instead.
Hmm... I can't seem to get this method to work either. Could you please give me an example of it being used? Such as to find the name of the current world you have open?
Edit: Would I use it like this If I wanted to print the name of the current world open?
Hmm... That doesn't seem to work... It just prints "net.minecraft.src.MinecraftAppletImpl@670cfa"
I'm not 100% on how to show the world name, although this is the code that does it in the world select screen
SaveFormatComparator var6 = (SaveFormatComparator)GuiSelectWorld.getSize(this.parentWorldGui).get(par1);
String var7 = var6.getDisplayName();
For ModLoader:
ModLoader.getMinecraftInstance().thePlayer
is the same as
mc.thePlayer
ModLoader.getMinecraftInstance().theWorld
is the same as
mc.theWorld
hmm.... I can't seem to get that to print the world name, it just prints "net.minecraft.src.MinecraftAppletImpl@670cfa." Would there be a way to possibly copy the mc.theWorld code, or make it accesible?
And this is SOOO close to what I need... the only problem is that I can't use "var7" (what holds the information of the world name) because it isn't static, and I can't make it static because there's a "this" in the top line, and "par1" can't be static unless it has another method, which I tried to build, but then you have to make a "try, catch" method which is a 50% chance it will work. I'm going to try and figure out how minecraft prints this out. In the meantime, sleepy time. 'night!
Depending on where you're calling it, you'll have to grab an instance of player.
Note I use forge, no guarantees if you don't.
I tried mc.theWorld.getWorldInfo() awhile ago and got some weird thing, not knowing it extended to .getWorldName
When I did mc.theWorld.getWorldInfo().getWorldName(), I only got MpServer regardless of the world name.
Hope it works
EDIT: Oh Crap, I understood the message incorrectly, I'll edit it soon
In single player you could get hacky and get access to the integrated server, but It'd crash on an actual server.
Your best bet would be to check somewhere minecraft provides you with the player then check if its a server to call it.
Something like:
or: