Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Registering objects with @ObjectHolder


Recommended Posts

Hello, I've recently decided to clean up my mod because it was a huge mess, so one thing I did was move all of the registration out of the one "registration" god class and divide the registration tasks into categories of block and item. Somewhere during this process, I must have gone wrong because my mod either fails to load or inevitably crashes when loading a world. I've played around with adding listeners and registering classes to the forge and mod busses, and gotten different errors. One thing I noticed is that they all lead to null pointers to items whose fields should have been injected from registries using the @ObjectHolder tag, so this is where I focused my research. I'm struggling to find anything about object holders, and beyond the idea that I didn't update the resource locations to match my new modid I'm stumped.

Latest Log and crash report (which correspond to the version on my repo) are attached.

Repo: https://github.com/eddie1101/PortalTest

Can someone tell me what I'm doing wrong?

latest.log crash-2021-02-01_20.37.37-client.txt

Link to post
Share on other sites

All of these methods are pointless, just call setRegistryName instead of calling a wrapper function that calls one line of code.

https://github.com/eddie1101/PortalTest/blob/c26623c062770115212536c540219f7abda1091f/src/main/java/erg/voidcraft/common/util/Util.java#L12

 

All of the declared types of these can just be Block

https://github.com/eddie1101/PortalTest/blob/c26623c062770115212536c540219f7abda1091f/src/main/java/erg/voidcraft/common/block/VoidcraftBlocks.java#L10-L14

Also, you haven't @ObjectHolder'd them, so you're not even using the thing you said you are in your thread title.

 

You aren't registering any blocks or items, because you haven't registered your classes with the event bus:

https://github.com/eddie1101/PortalTest/blob/c26623c062770115212536c540219f7abda1091f/src/main/java/erg/voidcraft/common/Voidcraft.java#L40

(You also aren't using the @EventBusSubscriber annotation)

 

Or the @SubscribeEvent annotation:

https://github.com/eddie1101/PortalTest/blob/master/src/main/java/erg/voidcraft/common/block/VoidcraftBlocks.java#L16

  • Thanks 1

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 post
Share on other sites

If you use @Object holder, the field needs to be final and null, so you can't assign a value to it like you are.

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 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.   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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I added a network channel, but how can i know if the channel exist on the client side ?  By the way I can't find the way to get the current server IP in 1.16.5, can you help me with that please ? 
    • I want to make texture pack and I have a problem with models. I want to make sides of diamond armor logner, can anybody help me? When i change this in layers, and render my texture pack it just turning to mess.
    • Experienced modders, I come to you with hat in hand and request if you could share with me your thoughts and suggestions for a direction I should take on implementing a feature in my mod. First, the concept. What I would like to achieve is to provide the end user a json config file in which they can place a list of biomes and provide some addition details/criteria to apply to the world generation about those biomes. The first I would like to achieve is applying a min and max distance that a biome can spawn at from the center of the world. For example, if they wanted to make sure that desert biome was never any closer to 0, 0 then say 200 blocks they could have that in the json and then the world would skip desert as an allowed biome whenever the player is generating terrain before 200 blocks out. So far I have been able to implement my own WorldType and BiomeProvider and strong arm the getBiomeNoise function to check the distance loaded in from center against the value loaded in from the config file and just wholesale swap it for a different hardcoded biome choice, but obvious that brute force attack is not ideal at all. So I have two questions maybe you can offer advise about: 1. I would actually like this feature to allow whatever the existing generation algorithm is to do its things and just make this one additional criteria check, but obviously this seems unlikely. I have been reading up on Mixins but I am not sure yet if this will let me achieve my goals or if I even SHOULD go that route. 2. What do you think is a better strategy for replacing the chosen biome with a new one? Look for the closest neighbor biome and go that route? Whats the best way to do that?   Thanks ahead of time for anyone who even bothered to read this lol.
    • Yeah, I changed the JAVA_HOME variable to the path of my JDK (C:\Program Files\Java\jdk1.8.0_281) and it worked. Thanks.
    • use NetworkHooks#openGui look how minecraft create container, but basically you need the container and a screen tutorials are not the best solution to learn something, read the forge docs and look here in the forum, then try to create a container, if you have problems creating it you can still ask
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.