minetest-mods / anvil

Minetest mod providing an anvil with which to repair worn tools
GNU General Public License v3.0
14 stars 18 forks source link

Duplication of objects #3

Closed ghost closed 7 years ago

ghost commented 7 years ago

This happens when a tool is removed with the right click in a different box

Example: screenshot_20170421_192427 Placed with right-click from the box 1 screenshot_20170421_192429 When you remove the element from the anvil by selecting box 2, it returns two tools screenshot_20170421_192441

FaceDeer commented 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.

FaceDeer commented 7 years ago

Fixed in the latest commit, let me know if that works for you.

ghost commented 7 years ago

No longer replicates, but now the tool disappears if it is removed from the anvil without changing the box

FaceDeer commented 7 years ago

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.

FaceDeer commented 7 years ago

... 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.

FaceDeer commented 7 years ago

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. :)

ghost commented 7 years ago

I tried it and it works very well :)