Jump to content

Recommended Posts

Posted

I apologize if this has been asked and solved before, but I did search and couldn't find anything useful.  I've got the basics of Java, but it's deep code that I'm not familiar with yet and I would like to ask for some help.

 

What I would like to do is be able to take my code for creating new creative tabs and for registering new recipes out of my central mod file and place them in their own separate files.  Will a simple 'Blah extends BlahBlah' in the separate files suffice, or will I need to put some code inside the central mod file to make load references to those separate files?  (Maybe import the separate files in the central mod file?)

 

Additionally, I do have a concern about the functionality of doing this with the creative tabs.  Will my items and blocks be allocated to their correct tabs if all the code is in a separate file?

 

Thanks for the help and the patience!

Posted

i do it also like that as recipes class you must have as example :

 

package invizzble.mods.nc.recipes;

 

import net.minecraft.item.ItemStack;

import invizzble.mods.nc.items.ModItems;

import invizzble.mods.nc.items.ModTools;

import cpw.mods.fml.common.registry.GameRegistry;

 

public class ShapedRecipes {

   

    public static void init(){

       

        GameRegistry.addRecipe(new ItemStack(ModItems.NightmareFuel), "xxx", "xyx", "xxx", Character.valueOf('x'), ModItems.NightMareDust, Character.valueOf('y'), ModItems.CreepyCoal);

        GameRegistry.addRecipe(new ItemStack(ModTools.NightmarePick), "xyx"," z " ," z ", Character.valueOf('x'), ModItems.DarkenedIngot, Character.valueOf('y'), ModItems.DarkOrb, Character.valueOf('z'), ModItems.DarkStick);

        GameRegistry.addRecipe(new ItemStack(ModItems.DarkOrb), "xxx", "xyx", "xxx", Character.valueOf('x'), ModItems.NightmareDiamond, Character.valueOf('y'), ModItems.NightMareDust);

    }

 

}

 

and then you just need to add in you init method

 

-your classname-.-name you called your method-

(in this example was it : ShapedRecipes.init();)

Posted

Thank you for the help! :)

 

Just for clarification: I should have a separate file for both shaped and shapeless recipes?  Your code looks like you've got a package for recipes, but a single file for each type.

 

So, if that's the case, I should have two files in my Recipes package and in the @init in my coremod file I should have:

 

ShapedRecipes.init();

ShapelessRecipes.init();

 

+karma for you, too :)

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.