mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-28 05:21:05 +01:00
Simplify pickblock implementation and call on_rightclick
This commit is contained in:
parent
ff590a93ae
commit
077ea1828c
2 changed files with 7 additions and 4 deletions
|
@ -1,25 +1,27 @@
|
||||||
minetest.override_item("", {
|
minetest.override_item("", {
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
if minetest.is_creative_enabled(placer:get_player_name()) then
|
if minetest.is_creative_enabled(placer:get_player_name()) then
|
||||||
|
mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
local node = minetest.get_node_or_nil(pointed_thing.under)
|
local node = minetest.get_node_or_nil(pointed_thing.under)
|
||||||
if not node then return end
|
if not node then return end
|
||||||
|
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
if not def then return end
|
if not def then return end
|
||||||
|
|
||||||
local rnode
|
local rnode = {}
|
||||||
-- if this is an 'illegal' node and there's an explicit `_vl_pickblock` field, then return it
|
-- if this is an 'illegal' node and there's an explicit `_vl_pickblock` field, then return it
|
||||||
-- if the node isn't 'illegal', return it as-is
|
-- if the node isn't 'illegal', return it as-is
|
||||||
-- (and if it's 'illegal' and no `_vl_pickblock` is defined, well, bad luck)
|
-- (and if it's 'illegal' and no `_vl_pickblock` is defined, well, bad luck)
|
||||||
if def.groups.not_in_creative_inventory and def.groups.not_in_creative_inventory ~= 0 then
|
if def.groups.not_in_creative_inventory and def.groups.not_in_creative_inventory ~= 0 then
|
||||||
if def._vl_pickblock then
|
if def._vl_pickblock then
|
||||||
rnode = def._vl_pickblock
|
rnode.name = def._vl_pickblock
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
rnode = node.name
|
rnode = node
|
||||||
end
|
end
|
||||||
|
|
||||||
return {name = rnode}
|
return rnode
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
name = vl_pickblock
|
name = vl_pickblock
|
||||||
description = Allows you to put the selected node in an empty slot of your hotbar when you're in creative mode.
|
description = Allows you to put the selected node in an empty slot of your hotbar when you're in creative mode.
|
||||||
|
depeds = mcl_util
|
||||||
|
|
Loading…
Reference in a new issue