Fix broken rightclick for tallgrass and cotton_4
This commit is contained in:
parent
06e7c02e54
commit
fa168eb747
@ -1046,28 +1046,19 @@ minetest.register_node(
|
|||||||
floodable = true,
|
floodable = true,
|
||||||
groups = {snappy = 2, dig_immediate = 3, attached_node = 1, grass = 1, normal_grass = 1, green_grass = 1},
|
groups = {snappy = 2, dig_immediate = 3, attached_node = 1, grass = 1, normal_grass = 1, green_grass = 1},
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
on_rightclick = function(pos, node, player, itemstack)
|
-- Trim tall grass with shears
|
||||||
if minetest.is_protected(pos, player:get_player_name()) and
|
_on_trim = function(pos, node, player, itemstack)
|
||||||
not minetest.check_player_privs(player, "protection_bypass") then
|
-- This turns it to a normal grass clump and drops one bonus grass clump
|
||||||
minetest.record_protection_violation(pos, player:get_player_name())
|
minetest.sound_play({name = "default_shears_cut", gain = 0.5}, {pos = player:get_pos(), max_hear_distance = 8})
|
||||||
return itemstack
|
minetest.set_node(pos, {name = "default:grass"})
|
||||||
|
|
||||||
|
item_drop.drop_item(pos, "default:grass")
|
||||||
|
|
||||||
|
-- Add wear
|
||||||
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
|
local def = itemstack:get_definition()
|
||||||
|
itemstack:add_wear(math.ceil(65536 / def.tool_capabilities.groupcaps.snappy.uses))
|
||||||
end
|
end
|
||||||
-- Trim tall grass clump when rightclicked by shears
|
|
||||||
local name = itemstack:get_name()
|
|
||||||
if minetest.get_item_group(name, "shears") == 1 then
|
|
||||||
-- This turns it to a normal grass clump and drops one bonus grass clump
|
|
||||||
minetest.sound_play({name = "default_shears_cut", gain = 0.5}, {pos = player:get_pos(), max_hear_distance = 8})
|
|
||||||
minetest.set_node(pos, {name = "default:grass"})
|
|
||||||
|
|
||||||
item_drop.drop_item(pos, "default:grass")
|
|
||||||
|
|
||||||
-- Add wear
|
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
|
||||||
local def = itemstack:get_definition()
|
|
||||||
itemstack:add_wear(math.ceil(65536 / def.tool_capabilities.groupcaps.snappy.uses))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -672,6 +672,22 @@ minetest.register_tool(
|
|||||||
|
|
||||||
-- Other
|
-- Other
|
||||||
|
|
||||||
|
local trim = function(itemstack, player, pointed_thing)
|
||||||
|
if pointed_thing.type == "node" then
|
||||||
|
local pos = pointed_thing.under
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local def = minetest.registered_nodes[node.name]
|
||||||
|
if def and def._on_trim then
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) and
|
||||||
|
not minetest.check_player_privs(player, "protection_bypass") then
|
||||||
|
minetest.record_protection_violation(pos, player:get_player_name())
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return def._on_trim(pos, node, player, itemstack, pointed_thing)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_tool(
|
minetest.register_tool(
|
||||||
"default:shears",
|
"default:shears",
|
||||||
{
|
{
|
||||||
@ -687,6 +703,7 @@ minetest.register_tool(
|
|||||||
snappy={times=tool_levels.wrought_iron.snappy, uses=15, maxlevel=1},
|
snappy={times=tool_levels.wrought_iron.snappy, uses=15, maxlevel=1},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
on_place = trim,
|
||||||
})
|
})
|
||||||
minetest.register_tool(
|
minetest.register_tool(
|
||||||
"default:shears_steel",
|
"default:shears_steel",
|
||||||
@ -703,6 +720,7 @@ minetest.register_tool(
|
|||||||
snappy={times=tool_levels.steel.snappy, uses=30, maxlevel=1},
|
snappy={times=tool_levels.steel.snappy, uses=30, maxlevel=1},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
on_place = trim,
|
||||||
})
|
})
|
||||||
minetest.register_tool(
|
minetest.register_tool(
|
||||||
"default:shears_carbon_steel",
|
"default:shears_carbon_steel",
|
||||||
@ -719,6 +737,7 @@ minetest.register_tool(
|
|||||||
snappy={times=tool_levels.carbon_steel.snappy, uses=40, maxlevel=1},
|
snappy={times=tool_levels.carbon_steel.snappy, uses=40, maxlevel=1},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
on_place = trim,
|
||||||
})
|
})
|
||||||
minetest.register_tool(
|
minetest.register_tool(
|
||||||
"default:shears_bronze",
|
"default:shears_bronze",
|
||||||
@ -735,6 +754,7 @@ minetest.register_tool(
|
|||||||
snappy={times=tool_levels.bronze.snappy, uses=30, maxlevel=1},
|
snappy={times=tool_levels.bronze.snappy, uses=30, maxlevel=1},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
on_place = trim,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_tool(
|
minetest.register_tool(
|
||||||
|
@ -260,18 +260,9 @@ minetest.register_node(
|
|||||||
},
|
},
|
||||||
groups = {snappy=3, handy=2, attached_node=1, not_in_craft_guide = 1, not_in_creative_inventory = 1},
|
groups = {snappy=3, handy=2, attached_node=1, not_in_craft_guide = 1, not_in_creative_inventory = 1},
|
||||||
sounds = default.node_sound_leaves_defaults(),
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
on_rightclick = function(pos, node, player, itemstack)
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) and
|
-- Trim cotton with shears
|
||||||
not minetest.check_player_privs(player, "protection_bypass") then
|
_on_trim = trim_cotton,
|
||||||
minetest.record_protection_violation(pos, player:get_player_name())
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
-- Trim cotton when rightclicking with shears
|
|
||||||
if minetest.get_item_group(itemstack:get_name(), "shears") == 1 then
|
|
||||||
itemstack = trim_cotton(pos, node, player, itemstack)
|
|
||||||
end
|
|
||||||
return itemstack
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user