Jump to content

[1.12.1] My fluid handler items don't seem to be saving fluid (empty after load)


Recommended Posts

Posted

I've been bashing my head on this for a bit and need help.

 

So I have been revisiting fluids and got them working pretty nicely. So I decided to practice making a custom fluid handler item (called a "slime bag" as my fluid is "slime") and it also generally works:

1) In the creative tab (misc) it shows both the empty and full items with proper model (right now I'm using a bucket texture)

2) Using the full item places a fluid block in the world, using an empty item can fill if it is used on a fluid block

3) The model in the player hotbar properly reflects filling and emptying.

 

However, if I save and load all the items in the player inventory are empty. Not only do they look empty (empty model and also display name just says "Bag" which indicates empty) but it also behaves as empty (can't place fluid but can pick it up).

 

Now I know that capabilities might need work to sync across to client, and it is likely related to this problem, but I have a couple questions about that.

 

Q1) If you use an itemstack in the client, but the function of the item is to do something on the server side, doesn't the server have a sense of what is supposed to be in the inventory and wouldn't it process accordingly? Like even though the itemstack looks empty on client, wouldn't the server treat it as being filled (since it should have saved as filled)? In other words, is my problem a client sync problem or a server save problem?

 

Q2) What is the proper way to sync a built-in capability like fluid handling for an itemstack to client? I'm pretty familiar with packets, but I thought a capability with IStorage adds to the ItemStack NBT and I thought NBT data is already synced through various vanilla packets. Any advice here is appreciated.

 

Q3) Possibly related, but when I trace my code using console outputs I see that my item's initCapabilities is being called repeatedly and continuously by both server and Netty server whevever my itemstack is being displayed (e.g. looking at creative menu). I thought it would be only called when an ItemStack is created, so I'm guessing that somewhere the ItemStack is getting copied / recreated. Since the Netty server is doing it, I assume it has to do with packets?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Post your code.

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.

Posted
4 hours ago, Draco18s said:

Post your code.

I usually feel bad having people actually debugging my code, rather just want to understand the ideas. But sometimes it is about the details so appreciate you looking at it: here is link to the item class within my github repository. https://github.com/jabelar/ExampleMod-1.12/blob/master/src/main/java/com/blogspot/jabelarminecraft/examplemod/items/fluidcontainers/ItemSlimeBag.java

 

If you actually go as far as to try to run it, look at the miscellaneous tab in creative and grab the last two items "Bag" and "Slime Bag". Then go into survival and convince yourself that they work (Slime Bag can place Slime and turn into Bag and vice versa) then while at least one of them is filled save and load. You'll see all Slime Bags become Bags.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.