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

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

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.

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

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.

  • Author

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

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.

  • Author

I just edited my post so that I had my second question in there, but what Version <= ?

Or what I am trying to say is will the be available in 1.8

 

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.

  • Author

but this loop does look right, right? 

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

 

  • Author

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.

  • Author

ahh ok. so then it would be this: 

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

 

Edited by Sudomeapizza

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

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.