Jump to content

Mod Item Display Names


Starhide
 Share

Recommended Posts

Hi, I am trying to retrieve the names of items in recipes and storing the recipes in a file for other uses. I already have it store them in a file but it only stores regular Minecraft's item names and a few mods like Buildcraft. However, it does not retrieve names of items from lets say Industrial Craft 2 or Redpower 2.

 

So, here is an example of what I've tried that all have the same affect.

 

Example 1:

Itemstack item = new Itemstack(Item.appleRed);

item.getDisplayName(); // Only works for Vanilla Items

 

Example 2:

Itemstack item = new Itemstack(Item.appleRed);

StringTranslate.getInstance().translateKey(item.getItemName() + ".name"); // Also, only works for Vanilla Items

 

This is my code for retrieving basic crafting recipes

 

 

ItemStack recipeResult = null;
ArrayList recipes = (ArrayList) CraftingManager.getInstance().getRecipeList();

for (int scan = 0; scan < recipes.size(); scan++) {
IRecipe tmpRecipe = (IRecipe) recipes.get(scan);
if (tmpRecipe instanceof ShapedRecipes) {
	String recipe = "";
	ShapedRecipes recipe = (ShapedRecipes) tmpRecipe;
	recipeResult = recipe.getRecipeOutput();
	recipe  = recipe + recipeResult.stackSize + "*" + recipeResult.getDisplayName() + " = ";
	for (ItemStack a : recipe.recipeItems) {
		if (a != null) {
			recipe = recipe + a.getDisplayName() + ", ";
		}
	}
	recipes.add(recipe);
}
if (tmpRecipe instanceof ShapelessRecipes) {
	String recipe  = "";
	ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe;
	recipeResult = recipe.getRecipeOutput();
	recipe  = recipe  + recipeResult.stackSize + "*" + recipeResult.getDisplayName() + " = ";
	for (int a1 = 0; a1 < recipe.recipeItems.size(); a1++) {
		if (recipe.recipeItems.get(a1) != null) {
			ItemStack c = (ItemStack) recipe.recipeItems.get(a1);
			recipe  = recipe  + c.getDisplayName() + ", ";
		}
	}
	recipes.add(recipe);
}
}

 

 

EDIT: I am using 1.4.7 due to Redpower not being updated

Link to comment
Share on other sites

getUnlocalizedName()

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

Well, that probably works but i forgot to mention I am in 1.4.7 which as far as I know does not have that.

So, unless someone finds a solution ill swap to 1.5.2

 

1.4.7 uses setItemName(...) for items and setBlockName(...) for blocks.

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

Honestly haven't messed with it in 1.47

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

If a new minecraft version comes out, you should GENERALLY move to it. But if it wrecks your code too much, then stay on the previous version.

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

If a new minecraft version comes out, you should GENERALLY move to it. But if it wrecks your code too much, then stay on the previous version.

 

I've been doing both 1.5.1 and some backporting of my code to 1.4.7, as I'm doing a plugin for Mystcraft, which hasn't updated for 1.5.2 yet, and one person is still using 1.4.7 for a Youtube series (for several reasons, one is because Custom Ore Generation hasn't updated yet).

 

But yeah, generally a good idea to update.

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

Though soon updating is going to be the death of modders... Stupid Modding API....

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

I figured it out getDisplayName() works fine only if its called after the game has started not when the mods are loading.

 

Calling it after mods have loaded is probably a good idea :P

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

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