Jump to content

Recommended Posts

Posted

Hi, pretty noob to minecarft modding here, i alredy know how to program with java, and i was testing a bit with forge in the last weeks.

 

My question is, if i add a wood planks to the ore directory, in theory i should be able to use it in every minecraft recipe that require wood planks, right? Like to craft sticks.

I have done this with my custom block.

OreDictionary.registerOre("plankWood", ModBlocks.MY_PLANKS);

I have put this in the preInit event just after have instantiated the block in my ModBlock class.

Have i done something wrong? Or i have to make the recipe for every object that require wood planks with my wood by hand?

Thanks.

Posted

Block/item registration happens after preInit, and before init. So oredict registration should happen in init (i.e. in response to a FMLInitializationEvent).

 

You haven't posted your block registration code, but I sincerely hope you're doing it in a RegistryEvent.Register<Block> event handler?

Posted
39 minutes ago, desht said:

You haven't posted your block registration code, but I sincerely hope you're doing it in a RegistryEvent.Register<Block> event handler?

Sure.

 

39 minutes ago, desht said:

Block/item registration happens after preInit, and before init. So oredict registration should happen in init (i.e. in response to a FMLInitializationEvent).

Ok....but why the documentation tell me to put it in preInit?

https://mcforge.readthedocs.io/en/latest/utilities/oredictionary/

Quote

Add entries to the OreDictionary during the FMLPreInitializationEvent phase, after initializing the blocks and items that you will register.

 

Posted
7 minutes ago, Simsure said:

Ok....but why the documentation tell me to put it in preInit?

https://mcforge.readthedocs.io/en/latest/utilities/oredictionary/

 

Good question. I suspect that section of the docs is outdated.  It used to be the case that blocks & items were explicitly registered from preInit, but that's since been superseded by the registry events.  My guess is that part of the docs was written before that.  In any case, moving your ore dict registration from preInit to init should solve your problem (you can verify this with your IDE debugger - if you breakpoint your current code, you should see that ModBlocks.MY_PLANKS is null). 

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.