0

So, in Forge 1.6 and previous, if you wanted to get a list of all items available in the game, you could just do

Items.itemList

This would return an Item[], containing all the vanilla items and all the items added by other mods. The problem is, in 1.7, as part of the new changes to the block/item system, they got rid of this field, in preference for the itemRegistry. My question is, has anyone yet figured out how to do the same thing in 1.7, i.e. retrieve a list of items for use? I'd imagine there has to be some way to do this, because mods like TMI have updated for 1.7. Only issue is they're closed-source.

If no one knows, then I suppose I'll just have to wait for NEI to be updated and look at his code.

  • Have you checked the API? I looked over it a couple times and saw nothing but it is a good place to start. Its available under the 'javadoc' link on this page. – willl459 Feb 10 '14 at 5:23
  • I'll admit, I haven't looked at it as heavily as perhaps I might have, but I have gone through a few searches and found nothing. – Morgan Patch Feb 10 '14 at 5:30
  • I've tried looking through the javadocs, but have still been unable to find anything which can do this. If I use reflection on net.minecraft.init.Items, I can get a list of Fields which allow me to get all of the vanilla items, but I was hoping to get it for all of the mods. – Morgan Patch Feb 10 '14 at 22:44
1
Set example = GameData.itemRegistry.getKeys();

Returns a Set with the registered items. You can also get the block version by substituting item for block. I haven't tested to see what you can actually do with this but at the very least you should be able to get the unlocalized name of registered items out of this Set.

  • This seems a little unclear. Is it a Set of Items, or a Set of Strings of the ids (i.e. unlocalized names)? – Morgan Patch Mar 17 '14 at 4:23
  • itemRegistry is deprecated. Any alternatives? – ndm13 Aug 25 '15 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.