Jump to content

Registry Object not Present.


JamFactory

Recommended Posts

I usually don't ask forums unless I've been stuck for a number of days, and so here I am. I'm new to the modding scene and trying to put together my first mod with basic world gen but I can't get it to work.
INFO: I've followed this and this tutorial about world gen, and I've got it to the point where I can spawn vanilla blocks just fine. I tested and the blocks I added-- Tungsten Block and Tungsten Ore-- work fine and can be placed/mined and whatnot. I made a test with gold blocks spawning underground and that's all fine and dandy, however
PROBLEM: When I attempt to use `RegistryHandler.EXAMPLE_ORE.get(), the game crashes with the message "Registry Object not Present," which according to the registry object code just means that the registry object field is null.
Where I'm confused is at a different point in the code I have the line `...ITEMS.register("example_ore", () -> new BlockItemBase(EXAMPLE_ORE.get()));` which has that same `EXAMPLE_ORE.get()` expression but when I went into the constructor of BlockItemBase and printed what it had passed into it, it displayed it just fine. I tried doing a sysout of the `EXAMPLE_ORE.get()` expression immediately before and after this `...ITEMS.register("example_ore", () -> new BlockItemBase(EXAMPLE_ORE.get()));` line but they both returned null. I was wondering if it was a timing/threading thing 

Here's the git repo, and to make it not crash just replace `RegistryHandler.TUNGSTEN_ORE.get()` on line util.RegistryHandler.java:55 with `Blocks.GOLD_BLOCK`

 

Any help is greatly appreciated. I've been at this for a while heh

Edited by JamFactory
Link to comment
Share on other sites

BlockItemBase is an antipattern. There is already a base BlockItem class, it is called BlockItem.

Ditto ItemBase. It's called Item.

Code Style #4

Edited by Draco18s

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.

Link to comment
Share on other sites

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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.