Jump to content

Recommended Posts

Posted

So, I'm trying to implement a customizable crafting recipe system (going pretty well) but I've hit one hitch. I've included this in the config system as string formatted like this: "<modid (would be minecraft for a vanilla item)>:<unlocalized name>" which means that the user has an easy way to configure crafting recipes in the event of a recipe conflict or the user simply wants to change it around. However, as of yet I've not found a way with which I can search the blockRegistry for a block using an unlocalized name. I imagine it wouldn't be that hard, and I've implemented a system for searching this way in my mod:

 

List<Item> itemList = new ArrayList<Item>();

public Item getItemByUnlocalizedName(String unlocalizedName) {
    for (int i = 0; i < itemList.size(); i++) {
        if (itemList.get(i).getUnlocalizedName().substring(5).equals(unlocalizedName) {
            return itemList.get(i);
        }
    }

    return "";
}

 

And I think that works pretty well. Any help would be greatly appreciated, thanks in advance!

Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*.

 

Also this. Check it out.

width=700 height=200http://i.imgur.com/J4rrGt6.png[/img]

Posted

Why not use the item's

GameRegistry

name and

GameRegistry.findItem

?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Thank you very much. That has helped tremendously, but are you sure that applies to vanilla items as well? The class GameRegistry seems to have been registered by Forge, and unless Forge has included vanilla items in it, I'm not sure that would work. However, I'd also like to know if it can encompass items and blocks as well, because I wouldn't want it to only support items or only blocks.

Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*.

 

Also this. Check it out.

width=700 height=200http://i.imgur.com/J4rrGt6.png[/img]

Posted

Got it. Thank you very much, but I'd still like to know if there's a way in which I can include both

GameRegistry#findItem

and

GameRegistry#findBlock

.

 

Also, the string that users will have to use will be item id instead of unlocalized name... Those are different...

 

What's the difference? How do I switch over to that? There doesn't appear to be any

setItemId

in the Block or Item class...

Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*.

 

Also this. Check it out.

width=700 height=200http://i.imgur.com/J4rrGt6.png[/img]

Posted

Got it. Thank you very much, but I'd still like to know if there's a way in which I can include both

GameRegistry#findItem

and

GameRegistry#findBlock

.

 

Also, the string that users will have to use will be item id instead of unlocalized name... Those are different...

 

What's the difference? How do I switch over to that? There doesn't appear to be any

setItemId

in the Block or Item class...

1) findItem also gives you blocks, because those are items too (while in your inventory, aren't they items?)

2) Item id is modid + : + string that you register your item with GameRegistry.registerItem.

Posted

So what's the point of adding modid to the findItem method if it already includes it?

 

You don't. Just pass the mod ID and item name as separate arguments.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

So the item name is the name that I used to register the item with

GameRegistry#registerItem

?

 

Yes.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

OK, thanks!

 

EDIT 1

 

Minecraft's unlocalized names are the same as its item names, right? I can't speak about any items from other mods, and I suppose users will have to use those at their own discretion, but Minecraft and my own mod are what I'm hoping to target here.

Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*.

 

Also this. Check it out.

width=700 height=200http://i.imgur.com/J4rrGt6.png[/img]

Posted

OK, thanks!

 

EDIT 1

 

Minecraft's unlocalized names are the same as its item names, right? I can't speak about any items from other mods, and I suppose users will have to use those at their own discretion, but Minecraft and my own mod are what I'm hoping to target here.

 

They're usually similar, but not always the same. The wiki does have a list of all vanilla block and item names here, though.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I suppose it doesn't really matter what the unlocalized name is if I make all of mine the same, and I can simply refer the user to the wiki entry. Thank you everyone!

Who are you? Why have you brought me here? And why are there so many PewDiePie fanboys surrounding meeeeeeeee....... *falls into pit and dies*.

 

Also this. Check it out.

width=700 height=200http://i.imgur.com/J4rrGt6.png[/img]

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...

×   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.

Announcements



×
×
  • Create New...

Important Information

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