From 817c52f92f053359d8d56ca77d3e9be607558609 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 17 Aug 2017 04:12:34 +0200 Subject: [PATCH] Fix bugs in flint and ssteel and ender eye --- mods/ITEMS/mcl_fire/flint_and_steel.lua | 6 ++-- mods/ITEMS/mcl_fire/init.lua | 3 +- mods/ITEMS/mcl_tnt/init.lua | 4 +-- mods/MAPGEN/mcl_portals/portal_end.lua | 33 +++++++++++------- mods/MAPGEN/mcl_portals/portal_nether.lua | 42 +++++------------------ 5 files changed, 35 insertions(+), 53 deletions(-) diff --git a/mods/ITEMS/mcl_fire/flint_and_steel.lua b/mods/ITEMS/mcl_fire/flint_and_steel.lua index 8902c1604..91e46861b 100644 --- a/mods/ITEMS/mcl_fire/flint_and_steel.lua +++ b/mods/ITEMS/mcl_fire/flint_and_steel.lua @@ -1,8 +1,8 @@ -- Flint and Steel minetest.register_tool("mcl_fire:flint_and_steel", { description = "Flint and Steel", - _doc_items_longdesc = "Flint and steel is a tool to start fires and ignite blocks.", - _doc_items_usagehelp = "Rightclick the surface of a block to attempt to light a fire in front of it. On netherrack and magma blocks it will start an eternal fire. Using it on TNT will ignite it.", + _doc_items_longdesc = "Flint and steel is a tool to start fires, ignite blocks and open portals.", + _doc_items_usagehelp = "Rightclick the surface of a block to attempt to light a fire in front of it. On netherrack it will start an eternal fire. Using it on TNT will ignite it. To open a Nether portal, place an upright frame of obsidian with a length of 4 and a height of 5 blocks, leaving only air in the center. After placing this frame, use the flint and steel on inside of the frame.", inventory_image = "mcl_fire_flint_and_steel.png", liquids_pointable = false, stack_max = 1, @@ -25,7 +25,7 @@ minetest.register_tool("mcl_fire:flint_and_steel", { if pointed_thing.type == "node" then local nodedef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] if nodedef and nodedef._on_ignite then - nodedef._on_ignite(pointed_thing.under, user) + nodedef._on_ignite(user, pointed_thing) else mcl_fire.set_fire(pointed_thing) end diff --git a/mods/ITEMS/mcl_fire/init.lua b/mods/ITEMS/mcl_fire/init.lua index 7c542c73e..0f0313a9d 100644 --- a/mods/ITEMS/mcl_fire/init.lua +++ b/mods/ITEMS/mcl_fire/init.lua @@ -376,7 +376,8 @@ local eternal_override = { minetest.remove_node(pos) end end, - _on_ignite = function(pos, player) + _on_ignite = function(player, pointed_thing) + local pos = pointed_thing.under local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z} if minetest.get_node(flame_pos).name == "air" then minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"}) diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index 4d0f59961..3e9a3c01f 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -71,8 +71,8 @@ minetest.register_node("mcl_tnt:tnt", { mesecons = {effector = { action_on = tnt.ignite }}, - _on_ignite = function(pos, player) - tnt.ignite(pos) + _on_ignite = function(player, pointed_thing) + tnt.ignite(pointed_thing.under) end, sounds = sounds, }) diff --git a/mods/MAPGEN/mcl_portals/portal_end.lua b/mods/MAPGEN/mcl_portals/portal_end.lua index 3fa1de6b3..81c2aad6f 100644 --- a/mods/MAPGEN/mcl_portals/portal_end.lua +++ b/mods/MAPGEN/mcl_portals/portal_end.lua @@ -373,20 +373,27 @@ minetest.override_item("mcl_end:ender_eye", { _doc_items_longdesc = "An eye of ander can be used to open a portal to the End.", _doc_items_usagehelp = "To open an End portal, place an upright frame of quartz blocks with a length of 4 and a height of 5 blocks, leaving only air in the center. After placing this frame, use the eye of ender on the frame.", on_place = function(itemstack, user, pointed_thing) - local nodedef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] --new - - -- If used on frame, open portal - if pointed_thing.under and minetest.get_node(pointed_thing.under).name == portal_frame then - make_end_portal(pointed_thing.under) - if minetest.get_modpath("doc") then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal_end") + -- Use pointed node's on_rightclick function first, if present + local node = minetest.get_node(pointed_thing.under) + if user and not user:get_player_control().sneak then + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack end - minetest.sound_play( - "fire_flint_and_steel", - {pos = pointed_thing.above, gain = 0.5, max_hear_distance = 8} - ) - if not minetest.setting_getbool("creative_mode") and used == true then - itemstack:take_item() -- 1 use + end + + -- If used on portal frame, open a portal + if pointed_thing.under and node.name == portal_frame then + local opened = make_end_portal(pointed_thing.under) + if opened then + if minetest.get_modpath("doc") then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal_end") + end + minetest.sound_play( + "fire_flint_and_steel", + {pos = pointed_thing.above, gain = 0.5, max_hear_distance = 16}) + if not minetest.settings:get_bool("creative_mode") then + itemstack:take_item() -- 1 use + end end end diff --git a/mods/MAPGEN/mcl_portals/portal_nether.lua b/mods/MAPGEN/mcl_portals/portal_nether.lua index 974565398..09ac74c42 100644 --- a/mods/MAPGEN/mcl_portals/portal_nether.lua +++ b/mods/MAPGEN/mcl_portals/portal_nether.lua @@ -380,43 +380,17 @@ minetest.register_abm({ -- Frame material minetest.override_item("mcl_core:obsidian", { on_destruct = destroy_portal, -}) - --- Portal opener -minetest.override_item("mcl_fire:flint_and_steel", { - _doc_items_longdesc = "Flint and steel is a tool to start fires, ignite blocks and open portals.", - _doc_items_usagehelp = "Rightclick the surface of a block to attempt to light a fire in front of it. On netherrack it will start an eternal fire. Using it on TNT will ignite it. To open a Nether portal, place an upright frame of obsidian with a length of 4 and a height of 5 blocks, leaving only air in the center. After placing this frame, use the flint and steel on inside of the frame.", - on_place = function(itemstack, user, pointed_thing) - local idef = itemstack:get_definition() - minetest.sound_play( - "fire_flint_and_steel", - {pos = pointed_thing.above, gain = 0.5, max_hear_distance = 8} - ) - local used = false - - if pointed_thing.under and minetest.get_node(pointed_thing.under).name == "mcl_core:obsidian" then - make_portal(pointed_thing.under) - if minetest.get_modpath("doc") then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal") - end + _on_ignite = function(user, pointed_thing) + local pos = pointed_thing.under + local portal_placed = make_portal(pos) + if portal_placed and minetest.get_modpath("doc") then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal") else - if pointed_thing.type == "node" then - local nodedef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] - if nodedef._on_ignite then - nodedef._on_ignite(pointed_thing.under, user) - else - mcl_fire.set_fire(pointed_thing) - end - used = true + local node = minetest.get_node(pointed_thing.above) + if node.name ~= "mcl_portals:portal" then + mcl_fire.set_fire(pointed_thing) end end - if itemstack:get_count() == 0 and idef.sound and idef.sound.breaks then - minetest.sound_play(idef.sound.breaks, {pos=user:getpos(), gain=0.5}) - end - if not minetest.setting_getbool("creative_mode") and used == true then - itemstack:add_wear(65535/65) -- 65 uses - end - return itemstack end, })