From 077ea1828c36123cb52d80559e9bfb6db6675287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikita=20Wi=C5=9Bniewski?= Date: Wed, 31 Jul 2024 21:20:43 +0700 Subject: [PATCH] Simplify pickblock implementation and call on_rightclick --- mods/PLAYER/vl_pickblock/init.lua | 10 ++++++---- mods/PLAYER/vl_pickblock/mod.conf | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mods/PLAYER/vl_pickblock/init.lua b/mods/PLAYER/vl_pickblock/init.lua index 0e776acbe..7e6257d22 100644 --- a/mods/PLAYER/vl_pickblock/init.lua +++ b/mods/PLAYER/vl_pickblock/init.lua @@ -1,25 +1,27 @@ minetest.override_item("", { on_place = function(itemstack, placer, pointed_thing) 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) if not node then return end local def = minetest.registered_nodes[node.name] 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 the node isn't 'illegal', return it as-is -- (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._vl_pickblock then - rnode = def._vl_pickblock + rnode.name = def._vl_pickblock end else - rnode = node.name + rnode = node end - return {name = rnode} + return rnode end end }) diff --git a/mods/PLAYER/vl_pickblock/mod.conf b/mods/PLAYER/vl_pickblock/mod.conf index 79a8a45e5..cdfdf705e 100644 --- a/mods/PLAYER/vl_pickblock/mod.conf +++ b/mods/PLAYER/vl_pickblock/mod.conf @@ -1,2 +1,3 @@ name = vl_pickblock description = Allows you to put the selected node in an empty slot of your hotbar when you're in creative mode. +depeds = mcl_util