Jump to content

Recommended Posts

Posted (edited)

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
Posted

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.

Posted (edited)

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

Posted (edited)

are you saying that all of the things are being loaded in pre init? so should I do the iteration in the post init? Also, for what Version will this function be available under?

Edited by Sudomeapizza
Posted

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.

Posted

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.

Posted (edited)

ahh ok. so then it would be this: 

@EventHandler
public void init(FMLInitializationEvent event) {
	for (Item fooditem : Items.REGISTRY){
		
	};
}

 

Edited by Sudomeapizza
Posted
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

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.