Jump to content

[1.16] Tag Collection Empty When Connecting to Server


Tikaji

Recommended Posts

I noticed that when I am running a world locally that calling BlockTags.getCollection() will return a filled out collection of tags. However, when I attempt to connect to a server that the same call results in a collection that is empty. This is causing a null pointer exception (because the list is empty) in my mod when I attempt to fill out JEI recipes. I did notice that the BlockTag collection was being filled out on the server however.

I figured that these tags would be synced from server to client, but I think I'm wrong on that one. Any suggestions on what I should be doing so that I can access those tags from the server?

Link to comment
Share on other sites

11 minutes ago, Tikaji said:

This is causing a null pointer exception (because the list is empty) in my mod when I attempt to fill out JEI recipes

Well that depends on how you are calling the tags. Recipes are not affected by block tags, only item tags. My guess is that you're calling the tags collections before they are initialized in the world.

Link to comment
Share on other sites

That would make sense to me and upon further investigation, that seems to be the case. JEI runs and builds it's recipe list, and then the Tag Collections are created. I'm not sure if this is a question that the community here would be able to answer or if its something I should take to JEI, but since it seems to be the case that Tags are initialized after JEI runs, what is the best way to load in those recipes that allow for tags? Or perhaps I'm doing something else entirely wrong.

Link to JEI package in my repo if it helps: https://github.com/NovaMachina/ExNihiloSequentia/tree/1.16/src/main/java/com/novamachina/exnihilosequentia/common/compat/jei

Link to comment
Share on other sites

7 minutes ago, Tikaji said:

I'm not sure if this is a question that the community here would be able to answer or if its something I should take to JEI, but since it seems to be the case that Tags are initialized after JEI runs, what is the best way to load in those recipes that allow for tags?

If I'm not mistaken, JEI does initialize recipes after the world loads up so it should be fine for tags. You just shouldn't have any direct references to tags in your code. They can be deserialized by the recipe itself.

Link to comment
Share on other sites

Sorry, I should have stated that the normal crafting recipes work just fine, but custom recipes that I load from a JSON file do not. I had the thought that I should create custom recipe serializes and use a data pack. Would this potentially be the right route to solve my problem?

Link to comment
Share on other sites

11 minutes ago, Tikaji said:

So, best course of action is to implement datapack support.

Yes, you would then be able to deserialize the instances correctly and on world load. If you really don't feel like it, you can also just add a reload listener to the server datapack and just refresh the data whenever that is loaded. Or, if you expect it to never change will ingame, I believe FMLServerStartedEvent is perfect for that.

Edited by ChampionAsh5357
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.

Announcements



×
×
  • Create New...

Important Information

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