item output logic flawed
rapus95 opened this issue ยท 5 comments
Describe the bug
Machines always place their output into the first slot that's available. Thus, if at some later place there's half a stack it will never first fill that stack up but instead start a new stack.
Environment (please complete the following information with the version):
- Minecraft: 1.19
- Mod Loader: fabric
Additional context
back when I was modding myself, there was a helper function, that returned the first non-full stack or the first empty slot if no such stack existed
@Technici4n @modmuss50 It looks like this belongs to FAPI and not to TR
Vanilla hopper behavior is to not stack the items in chests. So FAPI follows this by default.
EDIT: damn, looks like this is part of the experimental transaction/transfer API :/
EDIT2: OTOH you already use the experimental API anyway
@drcrazy @Technici4n but there nevertheless seems to be some logic right in the API which actually is
..., trying to "stack" first, i.e. prioritizing slots that already contain the resource.
It only works for List<SingleSlotStorage<T>>
, which wrappers around vanilla inventories contain under the hood, but we don't really know what exactly is a vanilla wrapper. ;)
We could add an instanceof check for InventoryStorage, however I believe this would still be a problem with double chests because they use a CombinedStorage
for the two parts.
A clean way to handle this in the transfer API would be nice. BTW the API is experimental but it's still safe to use.