Closed ghost closed 7 years ago
Ooh, neat bug. I think I've figured out what's happening, the on_rightclick function is adding the item to the player's inventory manually and is setting the player's wielded item. I've got a fix, let me just test that a bit more and I'll send it in.
Fixed in the latest commit, let me know if that works for you.
No longer replicates, but now the tool disappears if it is removed from the anvil without changing the box
Ah, I think I see why. Now on_rightclick is returning "nothing", which is overwriting the tool that was just placed in the player's inventory. Who'd have thought that just giving the player something would be so complicated. I'm on it.
... maybe. Looks like other modders are having trouble with giving players items on right click: https://forum.minetest.net/viewtopic.php?f=47&t=15159
I need to head out for a few hours, will resume debugging this when I get home.
There, back home. I've taken another crack at fixing this, I'm now explicitly reading what inventory index the player is wielding from and setting the contents of that index directly. I've been unable to lose or duplicate a tool despite a huge amount of clicking. I've also tested this fix in both the current 0.4.15 release and dev build cc1ff26 from March 31. Also tested both with and without the unified_inventory mod, to make sure that didn't throw a wrench in the works either. Hopefully this one's the winner. :)
I tried it and it works very well :)
This happens when a tool is removed with the right click in a different box
Example: Placed with right-click from the box 1 When you remove the element from the anvil by selecting box 2, it returns two tools