@@ -1612,34 +1612,6 @@ local function get_locked_chest_formspec(pos)
1612
1612
return formspec
1613
1613
end
1614
1614
1615
- local function has_locked_chest_privilege (meta , player )
1616
- if player then
1617
- if minetest .check_player_privs (player , " protection_bypass" ) then
1618
- return true
1619
- end
1620
- else
1621
- return false
1622
- end
1623
-
1624
- -- is player wielding the right key?
1625
- local item = player :get_wielded_item ()
1626
- if item :get_name () == " default:key" then
1627
- local key_meta = minetest .parse_json (item :get_metadata ())
1628
- local secret = meta :get_string (" key_lock_secret" )
1629
- if secret ~= key_meta .secret then
1630
- return false
1631
- end
1632
-
1633
- return true
1634
- end
1635
-
1636
- if player :get_player_name () ~= meta :get_string (" owner" ) then
1637
- return false
1638
- end
1639
-
1640
- return true
1641
- end
1642
-
1643
1615
minetest .register_node (" default:chest" , {
1644
1616
description = " Chest" ,
1645
1617
tiles = {" default_chest_top.png" , " default_chest_top.png" , " default_chest_side.png" ,
@@ -1710,26 +1682,23 @@ minetest.register_node("default:chest_locked", {
1710
1682
can_dig = function (pos ,player )
1711
1683
local meta = minetest .get_meta (pos );
1712
1684
local inv = meta :get_inventory ()
1713
- return inv :is_empty (" main" ) and has_locked_chest_privilege ( meta , player )
1685
+ return inv :is_empty (" main" ) and default . can_interact_with_node ( player , pos )
1714
1686
end ,
1715
1687
allow_metadata_inventory_move = function (pos , from_list , from_index ,
1716
1688
to_list , to_index , count , player )
1717
- local meta = minetest .get_meta (pos )
1718
- if not has_locked_chest_privilege (meta , player ) then
1689
+ if not default .can_interact_with_node (player , pos ) then
1719
1690
return 0
1720
1691
end
1721
1692
return count
1722
1693
end ,
1723
1694
allow_metadata_inventory_put = function (pos , listname , index , stack , player )
1724
- local meta = minetest .get_meta (pos )
1725
- if not has_locked_chest_privilege (meta , player ) then
1695
+ if not default .can_interact_with_node (player , pos ) then
1726
1696
return 0
1727
1697
end
1728
1698
return stack :get_count ()
1729
1699
end ,
1730
1700
allow_metadata_inventory_take = function (pos , listname , index , stack , player )
1731
- local meta = minetest .get_meta (pos )
1732
- if not has_locked_chest_privilege (meta , player ) then
1701
+ if not default .can_interact_with_node (player , pos ) then
1733
1702
return 0
1734
1703
end
1735
1704
return stack :get_count ()
@@ -1745,8 +1714,7 @@ minetest.register_node("default:chest_locked", {
1745
1714
" from locked chest at " .. minetest .pos_to_string (pos ))
1746
1715
end ,
1747
1716
on_rightclick = function (pos , node , clicker , itemstack , pointed_thing )
1748
- local meta = minetest .get_meta (pos )
1749
- if has_locked_chest_privilege (meta , clicker ) then
1717
+ if default .can_interact_with_node (clicker , pos ) then
1750
1718
minetest .show_formspec (
1751
1719
clicker :get_player_name (),
1752
1720
" default:chest_locked" ,
0 commit comments