Fix bugs in flint and ssteel and ender eye

This commit is contained in:
Wuzzy 2017-08-17 04:12:34 +02:00
parent 29873b96c1
commit 817c52f92f
5 changed files with 35 additions and 53 deletions

View File

@ -1,8 +1,8 @@
-- Flint and Steel -- Flint and Steel
minetest.register_tool("mcl_fire:flint_and_steel", { minetest.register_tool("mcl_fire:flint_and_steel", {
description = "Flint and Steel", description = "Flint and Steel",
_doc_items_longdesc = "Flint and steel is a tool to start fires and ignite blocks.", _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 and magma blocks it will start an eternal fire. Using it on TNT will ignite it.", _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", inventory_image = "mcl_fire_flint_and_steel.png",
liquids_pointable = false, liquids_pointable = false,
stack_max = 1, stack_max = 1,
@ -25,7 +25,7 @@ minetest.register_tool("mcl_fire:flint_and_steel", {
if pointed_thing.type == "node" then if pointed_thing.type == "node" then
local nodedef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] local nodedef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name]
if nodedef and nodedef._on_ignite then if nodedef and nodedef._on_ignite then
nodedef._on_ignite(pointed_thing.under, user) nodedef._on_ignite(user, pointed_thing)
else else
mcl_fire.set_fire(pointed_thing) mcl_fire.set_fire(pointed_thing)
end end

View File

@ -376,7 +376,8 @@ local eternal_override = {
minetest.remove_node(pos) minetest.remove_node(pos)
end end
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} local flame_pos = {x = pos.x, y = pos.y + 1, z = pos.z}
if minetest.get_node(flame_pos).name == "air" then if minetest.get_node(flame_pos).name == "air" then
minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"}) minetest.set_node(flame_pos, {name = "mcl_fire:eternal_fire"})

View File

@ -71,8 +71,8 @@ minetest.register_node("mcl_tnt:tnt", {
mesecons = {effector = { mesecons = {effector = {
action_on = tnt.ignite action_on = tnt.ignite
}}, }},
_on_ignite = function(pos, player) _on_ignite = function(player, pointed_thing)
tnt.ignite(pos) tnt.ignite(pointed_thing.under)
end, end,
sounds = sounds, sounds = sounds,
}) })

View File

@ -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_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.", _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) on_place = function(itemstack, user, pointed_thing)
local nodedef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] --new -- Use pointed node's on_rightclick function first, if present
local node = minetest.get_node(pointed_thing.under)
-- If used on frame, open portal if user and not user:get_player_control().sneak then
if pointed_thing.under and minetest.get_node(pointed_thing.under).name == portal_frame then if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
make_end_portal(pointed_thing.under) return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
if minetest.get_modpath("doc") then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal_end")
end end
minetest.sound_play( end
"fire_flint_and_steel",
{pos = pointed_thing.above, gain = 0.5, max_hear_distance = 8} -- If used on portal frame, open a portal
) if pointed_thing.under and node.name == portal_frame then
if not minetest.setting_getbool("creative_mode") and used == true then local opened = make_end_portal(pointed_thing.under)
itemstack:take_item() -- 1 use 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
end end

View File

@ -380,43 +380,17 @@ minetest.register_abm({
-- Frame material -- Frame material
minetest.override_item("mcl_core:obsidian", { minetest.override_item("mcl_core:obsidian", {
on_destruct = destroy_portal, on_destruct = destroy_portal,
}) _on_ignite = function(user, pointed_thing)
local pos = pointed_thing.under
-- Portal opener local portal_placed = make_portal(pos)
minetest.override_item("mcl_fire:flint_and_steel", { if portal_placed and minetest.get_modpath("doc") then
_doc_items_longdesc = "Flint and steel is a tool to start fires, ignite blocks and open portals.", doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal")
_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
else else
if pointed_thing.type == "node" then local node = minetest.get_node(pointed_thing.above)
local nodedef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] if node.name ~= "mcl_portals:portal" then
if nodedef._on_ignite then mcl_fire.set_fire(pointed_thing)
nodedef._on_ignite(pointed_thing.under, user)
else
mcl_fire.set_fire(pointed_thing)
end
used = true
end end
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, end,
}) })