Jump to content

[SOLVED] Inventory capability returns empty slots unless I instantiate slots and add them to a container


Recommended Posts

Posted (edited)

When I try to get the stacks from my inventory capability all are empty. If I open the associated container (extends Container, not IItemHandler) though, and some slots are instantiated and added, the inventory capability with the method getStackInSlot for some reason returns the proper stacks. I havent been able to debug yet what really makes the Slot .

 

Is there something I can do to load the contents of the IItemHandler capability? Iterating through the slots (and getting them) does not work (that returns empty stacks). Is this a somewhat known bug/misuse and (how) can I debug this better?

 

I copied the code from here:

https://github.com/Azanor/Baubles

 

Here is the capability code:

https://github.com/Azanor/Baubles/tree/master/src/main/java/baubles/api/cap

and here the container/slot code:

https://github.com/Azanor/Baubles/tree/master/src/main/java/baubles/common/container

 

(it is possible I have missed something when copying and also checking that I didnt forget something later)

 

Many thanks

Edited by dickdanieljr
Posted (edited)
9 hours ago, Animefan8888 said:

Where are you trying to get them at?

Hey Animefan8888, thanks for your post.

 

I'm trying to get them at PlayerTickEvent and in a LayerRenderer<EntityPlayer>. Actually it seems the server can get the itemstacks from the IItemHandler just well, but the client doesnt.. (I just realized that now)

 

Edit: Ok I found the error. I forgot to sync 1 little field.. stupid

Edited by dickdanieljr

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.