Compare commits

..

1 Commits

Author SHA1 Message Date
Mikita Wiśniewski 997fe6ecc4 Add new `supported_node_facedir` group and apply it to item frames
This group acts similarly to `supported_node`: it checks whether the
node behind is airlike (in which case the node is dropped as an item).
This change should fix item frames not placing on chests and similar
blocks, as reported by Bear123 on Discord.
2024-05-14 12:06:27 +07:00
3 changed files with 17 additions and 20 deletions

View File

@ -94,5 +94,16 @@ function minetest.check_single_for_falling(pos)
end
end
if get_item_group(node.name, "supported_node_facedir") ~= 0 then
local dir = facedir_to_dir(node.param2)
if dir then
local def = registered_nodes[get_node(vector.add(pos, dir)).name]
if def and def.drawtype == "airlike" then
drop_attached_node(pos)
return true
end
end
end
return false
end

View File

@ -638,7 +638,7 @@ function mcl_itemframes.create_base_definitions()
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = { dig_immediate = 3, deco_block = 1, dig_by_piston = 1, container = 1, attached_node_facedir = 1 },
groups = { dig_immediate = 3, deco_block = 1, dig_by_piston = 1, container = 1, supported_node_facedir = 1 },
sounds = mcl_sounds.node_sound_defaults(),
node_placement_prediction = "",

View File

@ -251,15 +251,6 @@ local function remove_shield_entity(player, i)
end
end
local function is_node_stack(itemstack)
return itemstack:get_definition().drawtype -- only node's definition table contains element "drawtype"
end
local function is_rmb_conflicting_node(nodename)
local nodedef = minetest.registered_nodes[nodename]
return nodedef.on_rightclick
end
local function handle_blocking(player)
local player_shield = mcl_shields.players[player]
local rmb = player:get_player_control().RMB
@ -275,7 +266,7 @@ local function handle_blocking(player)
local pos = player:get_pos()
if shield_in_hand then
if not_blocking then
minetest.after(0.05, function()
minetest.after(0.25, function()
if (not_blocking or not shield_in_offhand) and shield_in_hand and rmb then
player_shield.blocking = 2
set_shield(player, true, 2)
@ -286,16 +277,11 @@ local function handle_blocking(player)
end
elseif shield_in_offhand then
local pointed_thing = mcl_util.get_pointed_thing(player, true)
local wielded_stack = player:get_wielded_item()
local offhand_can_block = (minetest.get_item_group(wielded_item(player), "bow") ~= 1
and minetest.get_item_group(wielded_item(player), "crossbow") ~= 1)
local offhand_can_block = (wielded_item(player) == "" or not pointed_thing)
and (minetest.get_item_group(wielded_item(player), "bow") ~= 1 and minetest.get_item_group(wielded_item(player), "crossbow") ~= 1)
if pointed_thing and pointed_thing.type == "node" then
local pointed_node = minetest.get_node(pointed_thing.under)
if minetest.get_item_group(pointed_node.name, "container") > 1
or is_rmb_conflicting_node(pointed_node.name)
or is_node_stack(wielded_stack)
then
if minetest.get_item_group(minetest.get_node(pointed_thing.under).name, "container") > 1 then
return
end
end
@ -304,7 +290,7 @@ local function handle_blocking(player)
return
end
if not_blocking then
minetest.after(0.05, function()
minetest.after(0.25, function()
if (not_blocking or not shield_in_hand) and shield_in_offhand and rmb and offhand_can_block then
player_shield.blocking = 1
set_shield(player, true, 1)