Skip to content

Commit

Permalink
Check if player is still holding the same item
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklp09 committed Mar 31, 2024
1 parent 9bf84e7 commit e9508ef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ local function anvil_rotate(pos, node, user, mode, new_param2)
local player_name = user:get_player_name()
local wield_list = user:get_wield_list()
local wield_index = user:get_wield_index()
local wielded_original = user:get_inventory():get_stack(wield_list, wield_index)

minetest.after(0,function()
local player = minetest.get_player_by_name(player_name)
Expand All @@ -263,6 +264,10 @@ local function anvil_rotate(pos, node, user, mode, new_param2)
local inv = player:get_inventory()
local wielded = inv:get_stack(wield_list, wield_index)

if wielded:get_name() ~= wielded_original:get_name() then
return
end

local node_now = minetest.get_node(pos)
if node_now.name ~= "anvil:anvil" then
return
Expand Down

0 comments on commit e9508ef

Please sign in to comment.