Better Item Exchanging
hammy275 opened this issue ยท 7 comments
Main things are:
- We should allow grabbing items even if the hand item is full (if there's inventory space).
- Stack with items already in the inventory more often.
There's two code paths that handle swaps:
ItemStorage#placeItem
for world storage Immersives.ImmersiveLogicHelpers#swapItems
for not world storage Immersives.
These two code paths really need to be combined. However, because of how intertwined the return count logic is in the first, this is easier said than done.
I think the best approach would be to move placeItem
to somewhere in ServerUtil
, and make the provided ItemStorage
@Nullable
. From here, both methods above can call it, with the latter providing null
since there are no return item counts to increment. All of the item count changing should be made into helper functions in ItemStorage
to make the function far less messy.
Reopening, since I'm 99% sure the item return counts get messed up when switching between two different, not empty items
Yeah, need to clear before we increment at https://github.com/hammy275/immersive-mc/blob/1.21.1/common/src/main/java/com/hammy275/immersivemc/server/swap/Swap.java#L102