Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

43 minutes ago, dickdanieljr said:

When I try to get the stacks from my inventory capability all are empty.

Where are you trying to get them at?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author
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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.