Time Nick Message 19:43 Krock huh... item_OnDrop returns an empty ItemStack 19:45 Krock ah because it successfully dropped 1/1 count 19:47 sfan5 yeah got a big confused there too 19:47 sfan5 I'm currently debugging this 19:49 sfan5 hmm yeah I forgot about this case 19:50 sfan5 "on_drop can return any arbitrary item" doesn't really work when dropping a single item. because there will be (potentially) two results to put back 19:54 Krock my WIP so far https://pastebin.com/raw/FVKhMzAP 19:54 Krock if the returned item1 does not stack with src_item, it should be added to the inventory or dropped forcefully 19:55 Krock otherwise add to src_item 20:02 sfan5 maybe reverting the flexibility would be easier... 20:08 Krock sfan5: my proposal: https://pastebin.com/raw/64g1MhtA 20:08 Krock not sure if addItem would need to go into the branch above 20:10 Krock actually it should go into `if (src_can_take_count != -1)` above to avoid unintended side-effects of filling creative inventories (because addItem runs no callback) 20:13 Krock also the *_OnTake calls below need to be adjusted. 'src_item' is misleading in this case. We actually want to report how many items the player wanted to drop, which would be a backup of 'item1' 20:14 Krock or (original_src_item - src_item) 20:16 sfan5 I'd rather revert it actually 20:43 Krock okay I'd have a counter-proposal. Shall I PR, or would you like to revert directly? 20:45 sfan5 feel free to PR 20:45 sfan5 I'll PR the revert 20:52 Krock #17023 for those who might want to give it a shot 20:52 ShadowBot https://github.com/luanti-org/luanti/issues/17023 -- Inventory: Fix item loss caused by itemstack dropping by SmallJoker 21:24 sfan5 i guess I could write an unittest tomorrow too 21:37 sfan5 on_drop should have been (itemstack, dropper, count_to_drop) -> new_itemstack from the start 21:37 sfan5 then this would have worked 21:37 sfan5 and lua can deal with the problem if it wants to do both 1. drop a single item and 2. change the original stack