Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

  • Author

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

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.

  • Author

The getItemName and getBlockName methods return things like item.apple or tile.dirt and don't return anything for modded items.

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.

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

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.

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

  • Author

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

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

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.