1
0
Fork 0

Destroy end portal if end portal frame with eye is removed

This commit is contained in:
Wuzzy 2017-12-09 14:58:06 +01:00
parent 206bd3d29f
commit 5f4d73143e
1 changed files with 32 additions and 6 deletions

View File

@ -170,12 +170,19 @@ local function check_end_portal_frame(pos)
return false return false
end end
-- Generate a 3×3 end portal beginning at pos. To be used to fill an end portal frame -- Generate or destroy a 3×3 end portal beginning at pos. To be used to fill an end portal framea.
local function spawn_end_portal(pos) -- If destroy == true, the 3×3 area is removed instead.
local function end_portal_area(pos, destroy)
local SIZE = 3 local SIZE = 3
local name
if destroy then
name = "air"
else
name = "mcl_portals:portal_end"
end
for x=pos.x, pos.x+SIZE-1 do for x=pos.x, pos.x+SIZE-1 do
for z=pos.z, pos.z+SIZE-1 do for z=pos.z, pos.z+SIZE-1 do
minetest.set_node({x=x,y=pos.y,z=z}, {name="mcl_portals:portal_end"}) minetest.set_node({x=x,y=pos.y,z=z}, {name=name})
end end
end end
end end
@ -265,8 +272,14 @@ minetest.register_abm({
end, end,
}) })
local rotate_frame, rotate_frame_eye
--[[ ITEM OVERRIDES ]] if minetest.get_modpath("screwdriver") then
rotate_frame = screwdriver.rotate_simple
-- TODO: Make the other node rotatable as well.
-- Problem: We need to capture edge cases and update the portal accordingly.
rotate_frame_eye = false
end
minetest.register_node("mcl_portals:end_portal_frame", { minetest.register_node("mcl_portals:end_portal_frame", {
description = "End Portal Frame", description = "End Portal Frame",
@ -285,6 +298,9 @@ minetest.register_node("mcl_portals:end_portal_frame", {
paramtype = "light", paramtype = "light",
sunlight_propagates = false, sunlight_propagates = false,
light_source = 1, light_source = 1,
on_rotate = rotate_frame,
_mcl_blast_resistance = 18000000, _mcl_blast_resistance = 18000000,
_mcl_hardness = -1, _mcl_hardness = -1,
}) })
@ -308,9 +324,17 @@ minetest.register_node("mcl_portals:end_portal_frame_eye", {
paramtype = "light", paramtype = "light",
sunlight_propagates = false, sunlight_propagates = false,
light_source = 1, light_source = 1,
on_destruct = function(pos)
local ok, ppos = check_end_portal_frame(pos)
if ok then
end_portal_area(ppos, true)
end
end,
on_rotate = rotate_frame_eye,
_mcl_blast_resistance = 18000000, _mcl_blast_resistance = 18000000,
_mcl_hardness = -1, _mcl_hardness = -1,
-- TODO: Destroy end portal if this block got destroyed
}) })
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
@ -318,6 +342,8 @@ if minetest.get_modpath("doc") then
end end
--[[ ITEM OVERRIDES ]]
-- Portal opener -- Portal opener
minetest.override_item("mcl_end:ender_eye", { minetest.override_item("mcl_end:ender_eye", {
_doc_items_longdesc = "Eye of ender can be used in the construction of End portal frames.", _doc_items_longdesc = "Eye of ender can be used in the construction of End portal frames.",
@ -347,7 +373,7 @@ minetest.override_item("mcl_end:ender_eye", {
local ok, ppos = check_end_portal_frame(pointed_thing.under) local ok, ppos = check_end_portal_frame(pointed_thing.under)
if ok then if ok then
spawn_end_portal(ppos) end_portal_area(ppos)
if minetest.get_modpath("doc") then if minetest.get_modpath("doc") then
doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal_end") doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal_end")
end end