From fc17303b1e453ba47fa64461abf3d1c5a9c4a048 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 21 Nov 2017 07:24:56 +0100 Subject: [PATCH] Generate end exit portal near the spawn in the End --- mods/ITEMS/mcl_portals/portal_end.lua | 8 +++--- mods/MAPGEN/mcl_mapgen_core/init.lua | 23 ++++++++++++++++++ mods/MAPGEN/mcl_structures/init.lua | 12 ++++++++- .../mcl_structures_end_exit_portal.mts | Bin 0 -> 222 bytes 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_exit_portal.mts diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index 746cf6f733..834c7e2850 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -336,9 +336,11 @@ minetest.register_abm({ -- Teleport obj:set_pos(target) - -- Look towards the End island - if obj:is_player() and dim ~= "end" then - obj:set_look_horizontal(math.pi/2) + if obj:is_player() then + -- Look towards the End island + if dim ~= "end" then + obj:set_look_horizontal(math.pi/2) + end minetest.sound_play("mcl_portals_teleport", {pos=target, gain=0.5, max_hear_distance = 16}) end end diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 48b53b1c88..3aed74d2f1 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -43,6 +43,13 @@ local mg_name = minetest.get_mapgen_setting("mg_name") local WITCH_HUT_HEIGHT = 3 -- Exact Y level to spawn witch huts at. This height refers to the height of the floor +-- End exit portal position. This is temporary. +-- TODO: Remove the exit portal generation when the ender dragon has been implemented. +local END_EXIT_PORTAL_POS = table.copy(mcl_vars.mg_end_platform_pos) +END_EXIT_PORTAL_POS.x = END_EXIT_PORTAL_POS.x - 30 +END_EXIT_PORTAL_POS.z = END_EXIT_PORTAL_POS.z - 3 +END_EXIT_PORTAL_POS.y = END_EXIT_PORTAL_POS.y - 3 + -- Content IDs local c_bedrock = minetest.get_content_id("mcl_core:bedrock") local c_obsidian = minetest.get_content_id("mcl_core:obsidian") @@ -1333,6 +1340,22 @@ local function generate_structures(minp, maxp, seed, biomemap) end end end + -- End exit portal + elseif minp.y <= END_EXIT_PORTAL_POS.y and maxp.y >= END_EXIT_PORTAL_POS.y and + minp.x <= END_EXIT_PORTAL_POS.x and maxp.x >= END_EXIT_PORTAL_POS.x and + minp.z <= END_EXIT_PORTAL_POS.z and maxp.z >= END_EXIT_PORTAL_POS.z then + local built = false + for y=maxp.y, minp.y, -1 do + local p = {x=END_EXIT_PORTAL_POS.x, y=y, z=END_EXIT_PORTAL_POS.z} + if minetest.get_node(p).name == "mcl_end:end_stone" then + mcl_structures.call_struct(p, "end_exit_portal") + built = true + break + end + end + if not built then + mcl_structures.call_struct(END_EXIT_PORTAL_POS, "end_exit_portal") + end end end diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index 91ecabea5c..e3e6eec67b 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -38,6 +38,8 @@ mcl_structures.call_struct = function(pos, struct_style, rotation) return mcl_structures.generate_boulder(pos, rotation) elseif struct_style == "fossil" then return mcl_structures.generate_fossil(pos, rotation) + elseif struct_style == "end_exit_portal" then + return mcl_structures.generate_end_exit_portal(pos, rotation) end end @@ -116,6 +118,11 @@ mcl_structures.generate_fossil = function(pos) return minetest.place_schematic(newpos, path, "random", nil, true) end +mcl_structures.generate_end_exit_portal = function(pos) + local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts" + return minetest.place_schematic(pos, path, "0", nil, true) +end + mcl_structures.generate_desert_temple = function(pos) -- No Generating for the temple ... Why using it ? No Change local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_temple.mts" @@ -194,7 +201,7 @@ end -- Debug command minetest.register_chatcommand("spawnstruct", { - params = "desert_temple | desert_well | igloo | village | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil", + params = "desert_temple | desert_well | igloo | village | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal", description = "Generate a pre-defined structure near your position.", privs = {debug = true}, func = function(name, param) @@ -230,6 +237,9 @@ minetest.register_chatcommand("spawnstruct", { elseif param == "ice_spike_large" then mcl_structures.generate_ice_spike_large(pos) minetest.chat_send_player(name, "Large ice spike placed.") + elseif param == "end_exit_portal" then + mcl_structures.generate_end_exit_portal(pos) + minetest.chat_send_player(name, "End exit portal placed.") elseif param == "" then minetest.chat_send_player(name, "Error: No structure type given. Please use “/spawnstruct ”.") errord = true diff --git a/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_exit_portal.mts b/mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_exit_portal.mts new file mode 100644 index 0000000000000000000000000000000000000000..bc24f800a6de0e4265fdbe08808c9720061b8490 GIT binary patch literal 222 zcmeYb3HD`RVPI!qWnixd0U(1pF|&w4FgH0TJ~c1J3W(#2OY-wl83aH=$@xX8R!ONT zMfu6u3}PUWg8ZVA#GGO)2o2H$5iiLvO3p|vwgS`f<%u~t6?67Zy32Jyful9}cJci1 z`4Nsmt5cGn$8;pf|C=(Y>x^$sU)L+^RXm2rEqVhjdOw~yd0eDy%Dic&uPyg1I8yyH zO~3W?FE<7=#tl0-et5I*%~5yCuvOaK+coXSeq%5FGkVh6GdgztnH3o08erZh5UT|M Dl|EWe literal 0 HcmV?d00001