Fix some more issues with vl_pickblock, avoid conflicts with mcl_meshhand

This commit is contained in:
Mikita Wiśniewski 2025-01-04 12:32:45 +07:00
parent 87da975918
commit 90fd8a9f9e
4 changed files with 20 additions and 16 deletions

View file

@ -102,8 +102,15 @@ else
minetest.register_on_joinplayer(mcl_meshhand.update_player)
end
-- This is needed to deal damage when punching mobs
-- with random items in hand in survival mode
minetest.override_item("", {
tool_capabilities = mcl_meshhand.survival_hand_tool_caps
-- This is needed to deal damage when punching mobs
-- with random items in hand in survival mode
tool_capabilities = mcl_meshhand.survival_hand_tool_caps,
-- Creative mode Pickblock mechanics
on_place = function(itemstack, placer, pointed_thing)
if minetest.is_creative_enabled(placer:get_player_name()) then
return vl_pickblock.pickblock(itemstack, placer, pointed_thing)
end
end,
})

View file

@ -1,5 +1,5 @@
name = mcl_meshhand
author = jordan4ibanez
description = Applies the player skin texture to the hand.
depends = mcl_tools, mcl_player, mcl_gamemode
depends = mcl_tools, mcl_player, mcl_gamemode, vl_pickblock
optional_depends = mcl_skins, mcl_custom_skins

View file

@ -1,10 +1,17 @@
local function pickblock(_, placer, pointed_thing)
vl_pickblock = {}
function vl_pickblock.pickblock(itemstack, placer, pointed_thing)
local pos = pointed_thing.under
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
if def.on_rightclick and not placer:get_player_control().sneak then
return def.on_rightclick(pos, node, placer, itemstack, pointed_thing)
end
local illegal = (def.groups.not_in_creative_inventory and def.groups.not_in_creative_inventory ~= 0)
local rnode
@ -30,13 +37,3 @@ local function pickblock(_, placer, pointed_thing)
return rnode
end
local old_on_place = minetest.registered_items[""].on_place
minetest.override_item("", {
on_place = function(itemstack, placer, pointed_thing)
old_on_place(itemstack, placer, pointed_thing)
if minetest.is_creative_enabled(placer:get_player_name()) then
return pickblock(itemstack, placer, pointed_thing)
end
end
})

View file

@ -1,3 +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.
depends = mcl_util, mcl_meshhand
depends = mcl_util