Call old `on_place` when not clicking on portal material (#74)

This is needed to work with telemosaic since telemosaic depends on `on_rightclick` being called on beacon node when wielding a mese crystal fragment.
This commit is contained in:
Jacob Lifshay 2024-03-09 10:29:03 -08:00 committed by GitHub
parent ea677c5a1b
commit d16b530685
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 10 deletions

View File

@ -2166,22 +2166,20 @@ function nether.unregister_portal(name)
end
function nether.register_portal_ignition_item(item_name, ignition_failure_sound)
local old_on_place = minetest.registered_items[item_name].on_place or minetest.item_place
minetest.override_item(item_name, {
on_place = function(stack, placer, pt)
local done = false
on_place = function(stack, placer, pt, ...)
if pt.under and nether.is_frame_node[minetest.get_node(pt.under).name] then
done = ignite_portal(pt.under, placer:get_player_name())
local done = ignite_portal(pt.under, placer:get_player_name())
if done and not minetest.settings:get_bool("creative_mode") then
stack:take_item()
end
if not done and ignition_failure_sound ~= nil then
minetest.sound_play(ignition_failure_sound, {pos = pt.under, max_hear_distance = 10})
end
return stack
end
if not done and ignition_failure_sound ~= nil then
minetest.sound_play(ignition_failure_sound, {pos = pt.under, max_hear_distance = 10})
end
return stack
return old_on_place(stack, placer, pt, ...)
end,
})