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

[1.16.5] TileEntity don't save data (inventory)


Recommended Posts

I have created a tileentity which should add items to an ItemStackHandler when you right-click.
if after adding the item I check whether the item is present in the ItemStackHandler, It returns false.
this is my TE

I suspect it is due to the synchronization between client and server,
but I'm not sure, because it could be something else

does anyone have any idea what I have to change?

Link to post
Share on other sites
Posted (edited)
2 hours ago, diesieben07 said:

You have to only change the inventory server side.

okay i'm now checking whether the world is a ServerWorld
but this has not fixed the error, if I print the inventory on the console after interacting, every slot is empty
this is the updated class

Edited by Luis_ST
Link to post
Share on other sites
Posted (edited)
19 minutes ago, diesieben07 said:

You are setting simulate to true. So, the item handler complies and simulates the insertion. What did you expect?

I changed it, but the inventory remains empty

Edited by Luis_ST
Link to post
Share on other sites
Posted (edited)

Update: I'm trying to adapt my TileEntity, I used the CampfireTileEntity as an example
because it actually works the same way

Edited by Luis_ST
Link to post
Share on other sites
  • Your getNextSlot function is pointless. Simply keep calling insertItem until it manages to insert something and keep increasing the slot number.
  • You must not modify the ItemStack after you have given it to the IItemHandler, otherwise you will modify it inside the item handler. The IItemHandler takes care of any stack math and stack merging, it will simply give you the result back (whatever could not be inserted). Simply give that back to the player.
Link to post
Share on other sites
43 minutes ago, diesieben07 said:
  • Your getNextSlot function is pointless. Simply keep calling insertItem until it manages to insert something and keep increasing the slot number.
  • You must not modify the ItemStack after you have given it to the IItemHandler, otherwise you will modify it inside the item handler. The IItemHandler takes care of any stack math and stack merging, it will simply give you the result back (whatever could not be inserted). Simply give that back to the player.

i try that thanks

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.



×
×
  • Create New...

Important Information

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