Minecraft Mods

StringTranslatorMod API [All Versions!]

  • 2,325 views, 1 today
  • 126 downloads, 0 today
  • 6
  • 1
  • 13
ziddia's Avatar ziddia
Level 27 : Expert Modder
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!
CreditNotch and Mojang
Progress90% complete
Game VersionMinecraft 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

Create an account or sign in to comment.

1
12/03/2011 8:04 pm
Level 27 : Expert Modder
ziddia
ziddia's Avatar
New developers update available at zidmc.info/alpha/STM/1.2.0/StringTranslatorMod.java

Should be ready and tested withing the next couple of days.
1
12/02/2011 7:55 am
Level 27 : Expert Modder
ziddia
ziddia's Avatar
Update complete - please switch immediately, both developers and users, to patch a dangerous security vulnerability.
1
12/01/2011 10:40 pm
Level 27 : Expert Modder
ziddia
ziddia's Avatar
Update is imminent to try and fix a vulnerability. I just need to test it - developers can get the source for compiling early by using the link in the description.
1
11/23/2011 5:48 pm
Level 27 : Expert Modder
ziddia
ziddia's Avatar
Also, I need to know what you want me to include next.
1
11/23/2011 5:37 pm
Level 27 : Expert Modder
ziddia
ziddia's Avatar
Updated to feature support for booleans, shorts, and longs.
1
11/23/2011 3:57 am
Level 1 : New Miner
digitaldragon
digitaldragon's Avatar
This sounds great. I'll wait until all the Pro mod'ers (and everyone else on planet Minecraft) has parsed this completely and verified that its good code and not malicious. Thanks in advance for your contribution to the community!
1
11/23/2011 5:25 pm
Level 27 : Expert Modder
ziddia
ziddia's Avatar
Okidoke, tell me how it goes for you. :)
1
11/22/2011 10:08 pm
Level 17 : Journeyman Hunter
scykin
scykin's Avatar
so wat does the mod do
1
11/23/2011 5:25 pm
Level 27 : Expert Modder
ziddia
ziddia's Avatar
It's an API for modders to add properties files for item ids, so the end user can avoid conflicts with other mods.
1
11/26/2011 4:55 pm
Level 17 : Journeyman Hunter
scykin
scykin's Avatar
so it make all mod compatible with each other?
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome