Posted March 31, 20178 yr 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 March 31, 20178 yr by Sudomeapizza
March 31, 20178 yr 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.
March 31, 20178 yr 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 March 31, 20178 yr by TheMasterGabriel Clarification
March 31, 20178 yr 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.
March 31, 20178 yr 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 March 31, 20178 yr by Sudomeapizza
March 31, 20178 yr 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.
March 31, 20178 yr 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
March 31, 20178 yr 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.
March 31, 20178 yr Author dang... I'll move my mods to 1.8 instead of 1.7.10 because that isn't in there...
March 31, 20178 yr Author but this loop does look right, right? @EventHandler public void init(FMLInitializationEvent event) { for (ItemStack fooditem : Items.REGISTRY){ }; }
March 31, 20178 yr 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.
March 31, 20178 yr Author ahh ok. so then it would be this: @EventHandler public void init(FMLInitializationEvent event) { for (Item fooditem : Items.REGISTRY){ }; } Edited March 31, 20178 yr by Sudomeapizza
March 31, 20178 yr 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
March 31, 20178 yr For the list of items, I think I tend to use: List<Item> list = ImmutableList.copyOf(Item.itemRegistry); Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.