Storage Drawers: Forestry Pack

Storage Drawers: Forestry Pack

6M Downloads

[Question][1.12.2] Drawer API and drawer controller interaction

bafomdad opened this issue ยท 2 comments

commented

I have my own storage mod which does it's own thing, but more or less recently I've decided that I wanted to try making it compatible with SD by adding it as part of the blocks that the drawer controller can see and interact with. This storage block is strictly not a drawer in the traditional sense.

This works just fine when inserting items into the drawer controller, but for the extraction part, it does nothing. When I further tested this with Refined Storage's external storage pipe onto the drawer controller, it cannot see any of the items in my storage block, but despite that, it is still able to insert items into it via the controller.

Looking at the code for the item extraction part, I find

            return ItemStack.EMPTY;```
in the DrawerItemHandler class, for slots with an index of 0, which would explain why nothing would happen if I try extracting with a hopper on the controller.

Why is this `slotIsVirtual(slot)` check here, and what can I do to remedy this?
commented

That makes much more sense now, thank you for the explanation.

The original problem has already been fixed, but now I am looking at a possible weird interaction between SD, my mod and RS. The gist of the webm link posted below is that it can extract the diamonds from the drawer controller, from my storage block fine when it is over the max stack size, but any less than that and it does not completely empty out the inventory. Instead, what it seems to do is return the remaining stack from the result of (64 - remainder)

https://cdn.discordapp.com/attachments/375860824457084931/426597755335475200/hmm2.webm

This is the current implementation I use for SD interaction: https://gist.github.com/bafomdad/95c70f08f500b5e68a1d27ed21f48e9d
What it does is just simply wrap it around each of the inventory slots in the filing cabinets,

commented

Slot 0 on the controller is, as you point out, "virtual". It's a slot that can always accept any amount of any item (so long as the network as a whole can accommodate it), but cannot be extracted from. A permanently empty slot, basically.

It's both an optimization and protects SD's auto-sorting behavior from mods that enumerate the slots in order and try to insert the item in each one. Either it may be expensive to check all the drawers (only to find out you can't insert an item), or the mod might do its own item matching and not attempt to insert an item into a drawer that should actually accept the item, and end up not trying to insert it at all.

DrawerItemHandler exposes one more slot than your inventory provides, so your slot 0 should show up as slot 1 in the item handler.

Maybe I can offer some better pointers if you show me your current implementation.