Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Registry Object not Present.
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
JamFactory

Registry Object not Present.

By JamFactory, November 24, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

JamFactory    0

JamFactory

JamFactory    0

  • Tree Puncher
  • JamFactory
  • Members
  • 0
  • 4 posts
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

Share this post


Link to post
Share on other sites

Draco18s    2407

Draco18s

Draco18s    2407

  • Reality Controller
  • Draco18s
  • Members
  • 2407
  • 15945 posts
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.

Share this post


Link to post
Share on other sites

JamFactory    0

JamFactory

JamFactory    0

  • Tree Puncher
  • JamFactory
  • Members
  • 0
  • 4 posts
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

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      Valhelsia 3 server not starting

      By diesieben07 · Posted 17 minutes ago

      You can use https://gist.github.com/ for large text files.
    • diesieben07
      Disconnection From Server When Placing Modded Block

      By diesieben07 · Posted 18 minutes ago

      Your repository crashes for a different reason: You have two items with the same name. Additionally, you are not registering your registry entries properly. You need to either use @ObjectHolder or DeferredRegister.
    • squidlex
      Check if player wakes up in the Morning

      By squidlex · Posted 21 minutes ago

      This is perfect, thank you!
    • diesieben07
      Check if player wakes up in the Morning

      By diesieben07 · Posted 24 minutes ago

      The world time is definitely updated before the event is fired (see ServerWorld#tick, where it calls wakeUpAllPlayers). There is also SleepFinishedTimeEvent, which fires when the server decides that all players are asleep and changes the time to day, it is fired before the time changes and before all players are woken up.
    • octa
      Disconnection From Server When Placing Modded Block

      By octa · Posted 33 minutes ago

      Repo is fixed. How do I run my client with system properties? It works on the server but when I add it to JVM arguments in the launcher's installation settings the game crashes.
  • Topics

    • Purity
      7
      Valhelsia 3 server not starting

      By Purity
      Started 15 hours ago

    • octa
      3
      Disconnection From Server When Placing Modded Block

      By octa
      Started 3 hours ago

    • squidlex
      2
      Check if player wakes up in the Morning

      By squidlex
      Started 38 minutes ago

    • squidlex
      2
      How to create the regeneration effect on hearts for other HUD elements

      By squidlex
      Started 22 hours ago

    • Tyrone117
      4
      Unable to install forge 1.16.5

      By Tyrone117
      Started 15 hours ago

  • Who's Online (See full list)

    • TheidenHD
    • Yuqera
    • Shlub
    • octa
    • _xlxrenz_
    • loordgek
    • kikohou
    • CapeGamerBoi
    • Purity
    • diesieben07
    • XDKara
    • Galaxy173354YT
    • GThoro
    • vemerion
    • SlickPotato7
    • Majd123mc
    • Microcellule
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Registry Object not Present.
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community