JamFactory Posted November 24, 2020 Share Posted November 24, 2020 (edited) 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 November 24, 2020 by JamFactory Quote Link to comment Share on other sites More sharing options...
Draco18s Posted November 24, 2020 Share Posted November 24, 2020 (edited) 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 November 24, 2020 by Draco18s Quote 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 More sharing options...
JamFactory Posted November 24, 2020 Author Share Posted November 24, 2020 Welp I fixed it by putting the call in an onBlocksRegistry event. I tried this earlier but it didn't work, but regardless I appreciate the coding style help. I'm no longer using Bases Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.