Jump to content

[Solved][1.7.2]Fluid Container Registry Null Pointer Exception


Taji34

Recommended Posts

So I have created a liquid and I'm creating a bucket for it, however, the fluid container registry line is throwing a null pointer exception.

 

Troncraft.java: https://gist.github.com/anonymous/c6006d69a773edea63e5

Crash Report: https://gist.github.com/anonymous/fc4f35a84df9bab4d088

 

This line in particular is the one having the issue:

FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("liquidEnergy", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(liquidEnergyBucket), new ItemStack(Items.bucket));

 

When I comment this line out, everything works fine, bucket functions normally. I figured this line was there to reqister how many mB it is and some other properties, so I need it correct? Every parameter appears to me to not be null, but obviously that's not the case, could someone help me figure this out? Again, it's not affecting the buckets functionality, I just figured this line was important since it was in the tutorial.

Link to comment
Share on other sites

Try putting a breakpoint at that line, so you can see the null value so that you can search deeper as why that's null, and how to solve it.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

You cannot call getFluidStack() on an unregistered fluid. You must call FluidRegistry#registerFluid(Fluid f) before that, or you will get a null.

Link to comment
Share on other sites

You cannot call getFluidStack() on an unregistered fluid. You must call FluidRegistry#registerFluid(Fluid f) before that, or you will get a null.

 

But I did register a fluid. This is the second line of my preint:

FluidRegistry.registerFluid(liquidEnergy);

Which I do before I call the getFluidStack. Does the name parameter need to be the localized or unlocalized name of my fluid?

 

EDIT: I did some experimenting and figured it out! I needed to do liquidEnergy.getName() for the string name parameter.

Link to comment
Share on other sites

No, the real issue is you need to register (and retrieve) your fluid with an all lowercase name, as that is how the key is stored.

Link to comment
Share on other sites

I mean, is doing it the way I have right now going to cause problems in the future?

 

Not knowing when to use the proper case is always a source of problems in programming.

Link to comment
Share on other sites

Ok, the case issue makes sense, staying consistent and what not with standards. However, is there anything wrong with using fluid.getName() instead of "fluidname"?

Nothing wrong with doing it that way. Whatever works. :)

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.