Jump to content

How to iterate through items?


Sudomeapizza

Recommended Posts

I was making a mod for my personal use and was wondering how to iterate through all of the items in minecraft / though other mods as well if they are there.

Using this info I wanted to use each individual item to be in a separate shapeless crafting recipe that does something to that item (I'm specifying towards food items)

and got stuck at the start. How do I even Iterate through the items?

Edited by Sudomeapizza
Link to comment
Share on other sites

Look at Items.REGISTRY

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

You can access all of Forge's registries via ForgeRegistries. Note, however, that when you iterate over the registry, you will only be iterating over the things that have already been registered. If a mod loads after yours, it will not be in the list.

 

Edit: This is assuming you are doing the iterating in preInit, as Draco said below. If not, ignore that second part.

Edited by TheMasterGabriel
Clarification
Link to comment
Share on other sites

55 minutes ago, TheMasterGabriel said:

. If a mod loads after yours, it will not be in the list.

Not entirely true.  As items/blocks/etc can only be registered during PreInit, then any point after that will see every item that exists, regardless of mod load order.

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

Items may still be being created by mods (that load after yours) during preInit, but after preInit (init, postInit, during game) the registries are finalized and cannot be modified.

 

So yes.

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

Function? You mean init and postInit? Those methods have been around since forever.

If you mean Items.REGISTRY (which is a field) I don't know when it was added.

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

11 minutes ago, Sudomeapizza said:

The only thing though is that I hate (with love) the attack cooldown thingy, and was wondering if I could do an @override to disable it. Otherwise I would gracefully move up that far.

The only way i've seen is with plugins, but I have'nt been able to find a mod that does it

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