- 2,325 views, 1 today
- 126 downloads, 0 today
0
Update complete - please switch immediately, both developers and users, to patch a dangerous security vulnerability.
Description
StringTranslatorMod is a nifty tool that I have adapted from Notch's StringTranslate class. It allows you to define a .lang file, and choose properties for it! Developers may use this to have custom names, item IDs, damage values, power levels, max stack sizes... It's endless!
It works for both Modloader and Non-ML mods. I have aimed to please everybody!
What does that 'all' in the title mean?
It will work for all versions of Minecraft, no matter what - no need to wait endlessly for me to update!
Why lang files?
Lang files are what Notch chose to use as his properties file replacement. It's pretty much native to Minecraft, and it's far easier to use than generic Properties files.
I'm not a developer! Why do I need this?
If you're not a mod developer, you may need this because a developer uses it in his or her mod. Just use that download up there!
Alright, how do I use it in my mods?
I'll be making a real tutorial really soon, for now, just use this piece of junk I wrote up quickly:
First, imagine we have a mod_Emeralds class. The Emerald Item has a data value of 2100. We have this line:
public static final Item emeraldItem = new ItemEmerald(2100).setItemName("itemEmerald");
First, we add this above that:
public static StringTranslatorMod stm = new StringTranslatorMod("/lang/yourfile.lang");
Just change yourfile.lang to whatever you called your .lang file. Note that it MUST BE A .LANG FILE.
Now, we can change the original Item declaration to this:
public static final Item emeraldItem = new ItemEmerald(stm.translateInt("mod.emeraldid")).setItemName("itemEmerald");
What does this do? It calls translateInt from StringTranslatorMod's API. You feed it with a String as the property to obtain. The API turns it into an integer, with some magical work behind the scenes. The String provided is mod.emeraldid. Therefore, our .lang file, which I named emeralds.lang, looks like this:
mod.emeraldid=2100
You could also make a property getter for the name - like so:
public mod_Emeralds() {
ModLoader.AddName(stm.translateKey("mod.emeraldname"));
}
There are also methods for obtaining shorts (translateShort), longs (translateLong) and booleans (translateBool).
translateKey will get a String from the file instead of an integer. Simple enough!
There are also methods for obtaining shorts (translateShort), longs (translateLong) and booleans (translateBool). And you can use the methods from the API for anything involving Strings, Integers, Shorts, Longs, and Booleans.
TODO:
Add character reading, maybe.
Enjoy! Leave feedback! Hope it helps all you modders out there!
Description
StringTranslatorMod is a nifty tool that I have adapted from Notch's StringTranslate class. It allows you to define a .lang file, and choose properties for it! Developers may use this to have custom names, item IDs, damage values, power levels, max stack sizes... It's endless!
It works for both Modloader and Non-ML mods. I have aimed to please everybody!
What does that 'all' in the title mean?
It will work for all versions of Minecraft, no matter what - no need to wait endlessly for me to update!
Why lang files?
Lang files are what Notch chose to use as his properties file replacement. It's pretty much native to Minecraft, and it's far easier to use than generic Properties files.
I'm not a developer! Why do I need this?
If you're not a mod developer, you may need this because a developer uses it in his or her mod. Just use that download up there!
Alright, how do I use it in my mods?
I'll be making a real tutorial really soon, for now, just use this piece of junk I wrote up quickly:
First, imagine we have a mod_Emeralds class. The Emerald Item has a data value of 2100. We have this line:
public static final Item emeraldItem = new ItemEmerald(2100).setItemName("itemEmerald");
First, we add this above that:
public static StringTranslatorMod stm = new StringTranslatorMod("/lang/yourfile.lang");
Just change yourfile.lang to whatever you called your .lang file. Note that it MUST BE A .LANG FILE.
Now, we can change the original Item declaration to this:
public static final Item emeraldItem = new ItemEmerald(stm.translateInt("mod.emeraldid")).setItemName("itemEmerald");
What does this do? It calls translateInt from StringTranslatorMod's API. You feed it with a String as the property to obtain. The API turns it into an integer, with some magical work behind the scenes. The String provided is mod.emeraldid. Therefore, our .lang file, which I named emeralds.lang, looks like this:
mod.emeraldid=2100
You could also make a property getter for the name - like so:
public mod_Emeralds() {
ModLoader.AddName(stm.translateKey("mod.emeraldname"));
}
There are also methods for obtaining shorts (translateShort), longs (translateLong) and booleans (translateBool).
translateKey will get a String from the file instead of an integer. Simple enough!
There are also methods for obtaining shorts (translateShort), longs (translateLong) and booleans (translateBool). And you can use the methods from the API for anything involving Strings, Integers, Shorts, Longs, and Booleans.
TODO:
Add character reading, maybe.
Enjoy! Leave feedback! Hope it helps all you modders out there!
Credit | Notch and Mojang |
Progress | 90% complete |
Game Version | Minecraft 1.0 |
Tags |
3 Update Logs
Security Update : by ziddia 12/02/2011 7:55:19 amDec 2nd, 2011
Stops a potentially dangerous security issue in which a malicious developer could load an unwanted class for use. Please update immediately.
LOAD MORE LOGS
tools/tracking
353330
7
stringtranslatormod-api-all-versions
Create an account or sign in to comment.
Should be ready and tested withing the next couple of days.