Basically... I want to have my robot hover over to a chest, count how many occupied slots there are and do something based on that count.
What I tried was:
Assuming that "ic" is "component.inventory_controller"
`ic.getAllStacks(sides.front)`
I was assuming that would offer something along the lines of 'ic.getAllStacks(sides.front).slotsOccupied() which would return what I was looking for... I found 'ic.getAllStacks(sides.front).count()' which I thought would do exactly what I wanted!
Then I found out that did the exact same thing as 'ic.getInventorySize()'. Returning the total number of slots in the entire inventory... I don't really understand why we have two functions that do the exact same thing, but oh well...
The other options are `.getAll()` and `.reset()`.
The solution i've gone for, which is incredibly memory intensive, is to `.getAll()`and then interate through that map to count each slot that isn't "air" and then return that number... It works, but I really struggle to believe there isn't a function premade for that...
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.
Basically... I want to have my robot hover over to a chest, count how many occupied slots there are and do something based on that count.
What I tried was:
Assuming that "ic" is "component.inventory_controller"
`ic.getAllStacks(sides.front)`
I was assuming that would offer something along the lines of 'ic.getAllStacks(sides.front).slotsOccupied() which would return what I was looking for... I found 'ic.getAllStacks(sides.front).count()' which I thought would do exactly what I wanted!
Then I found out that did the exact same thing as 'ic.getInventorySize()'. Returning the total number of slots in the entire inventory... I don't really understand why we have two functions that do the exact same thing, but oh well...
The other options are `.getAll()` and `.reset()`.
The solution i've gone for, which is incredibly memory intensive, is to `.getAll()`and then interate through that map to count each slot that isn't "air" and then return that number... It works, but I really struggle to believe there isn't a function premade for that...
So question is:
Is there a better way of going about that?
Link to post
Share on other sites