From 83b9cf3ad258620ff3b89bc9c1ce01b02220b82e Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 6 Apr 2021 15:48:17 +0200 Subject: [PATCH] End exit portal openng / closing on dragon death / spawn --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 8 ++++++-- mods/ITEMS/mcl_end/end_crystal.lua | 4 +++- mods/MAPGEN/mcl_mapgen_core/init.lua | 14 ++++++++++---- mods/MAPGEN/mcl_structures/init.lua | 12 ++++++++++-- .../mcl_structures_end_exit_portal.mts | Bin 222 -> 193 bytes .../mcl_structures_end_exit_portal_open.mts | Bin 0 -> 222 bytes 6 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 mods/MAPGEN/mcl_structures/schematics/mcl_structures_end_exit_portal_open.mts diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index 01c346579..50aaacd4b 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -64,8 +64,12 @@ mobs:register_mob("mobs_mc:enderdragon", { end, on_die = function(self, pos) if self._portal_pos then - mcl_experience.throw_experience(pos, 11500) -- 500 + 11500 = 12000 - minetest.set_node(minetest.string_to_pos(self._portal_pos), {name = mobs_mc.items.dragon_egg}) + local portal_pos = minetest.string_to_pos(self._portal_pos) + mcl_structures.call_struct(portal_pos, "end_exit_portal_open") + if self._initial then + mcl_experience.throw_experience(pos, 11500) -- 500 + 11500 = 12000 + minetest.set_node(vector.add(portal_pos, vector.new(3, 5, 3)), {name = mobs_mc.items.dragon_egg}) + end end end, fire_resistant = true, diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua index 9e4fa13fd..63a37d3c6 100644 --- a/mods/ITEMS/mcl_end/end_crystal.lua +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -58,7 +58,9 @@ local function spawn_crystal(pos) for _, crystal in pairs(crystals) do crystal_explode(crystal) end - minetest.add_entity(vector.add(portal_center, {x = 0, y = 10, z = 0}), "mobs_mc:enderdragon") + local portal_pos = vector.add(portal_center, vector.new(-3, -1, -3)) + mcl_structures.call_struct(portal_pos, "end_exit_portal") + minetest.add_entity(vector.add(portal_pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon"):get_luaentity()._portal_pos = minetest.pos_to_string(portal_pos) end minetest.register_entity("mcl_end:crystal", { diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index e08b55ba3..237579dbe 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -54,8 +54,7 @@ local superflat = mg_name == "flat" and minetest.get_mapgen_setting("mcl_superfl 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. +-- End exit portal position 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 @@ -1251,6 +1250,13 @@ local function generate_clay(minp, maxp, blockseed, voxelmanip_data, voxelmanip_ return lvm_used end +local function generate_end_exit_portal(pos) + local dragon_entity = minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon"):get_luaentity() + dragon_entity._initial = true + dragon_entity._portal_pos = minetest.pos_to_string(pos) + mcl_structures.call_struct(pos, "end_exit_portal") +end + -- TODO: Try to use more efficient structure generating code local function generate_structures(minp, maxp, blockseed, biomemap) local chunk_has_desert_well = false @@ -1490,11 +1496,11 @@ local function generate_structures(minp, maxp, blockseed, biomemap) 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") + generate_end_exit_portal(p) return end end - mcl_structures.call_struct(END_EXIT_PORTAL_POS, "end_exit_portal") + generate_end_exit_portal(END_EXIT_PORTAL_POS) end end diff --git a/mods/MAPGEN/mcl_structures/init.lua b/mods/MAPGEN/mcl_structures/init.lua index 4294215a9..d75854352 100644 --- a/mods/MAPGEN/mcl_structures/init.lua +++ b/mods/MAPGEN/mcl_structures/init.lua @@ -87,6 +87,8 @@ mcl_structures.call_struct = function(pos, struct_style, rotation, pr) return mcl_structures.generate_fossil(pos, rotation, pr) elseif struct_style == "end_exit_portal" then return mcl_structures.generate_end_exit_portal(pos, rotation) + elseif struct_style == "end_exit_portal_open" then + return mcl_structures.generate_end_exit_portal_open(pos, rotation) elseif struct_style == "end_portal_shrine" then return mcl_structures.generate_end_portal_shrine(pos, rotation, pr) end @@ -313,11 +315,15 @@ mcl_structures.generate_fossil = function(pos, rotation, pr) end mcl_structures.generate_end_exit_portal = function(pos, rot) - minetest.add_entity(vector.add(pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon"):get_luaentity()._portal_pos = minetest.pos_to_string(vector.add(pos, vector.new(3, 5, 3))) local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts" return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) end +mcl_structures.generate_end_exit_portal_open = function(pos, rot) + local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal_open.mts" + return mcl_structures.place_schematic(pos, path, rot or "0", nil, true) +end + local function shrine_placement_callback(p1, p2, size, rotation, pr) -- Find and setup spawner with silverfish local spawners = minetest.find_nodes_in_area(p1, p2, "mcl_mobspawners:spawner") @@ -535,7 +541,7 @@ end -- Debug command minetest.register_chatcommand("spawnstruct", { - params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_portal_shrine | nether_portal | dungeon", + params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_exit_portal_opens | end_portal_shrine | nether_portal | dungeon", description = S("Generate a pre-defined structure near your position."), privs = {debug = true}, func = function(name, param) @@ -567,6 +573,8 @@ minetest.register_chatcommand("spawnstruct", { mcl_structures.generate_ice_spike_large(pos, rot, pr) elseif param == "end_exit_portal" then mcl_structures.generate_end_exit_portal(pos, rot, pr) + elseif param == "end_exit_portal_open" then + mcl_structures.generate_end_exit_portal_open(pos, rot, pr) elseif param == "end_portal_shrine" then mcl_structures.generate_end_portal_shrine(pos, rot, pr) elseif param == "dungeon" and mcl_dungeons and mcl_dungeons.spawn_dungeon then 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 index bc24f800a6de0e4265fdbe08808c9720061b8490..30d145bd7fdc822259191c918696b74769628d72 100644 GIT binary patch delta 154 zcmcb|c#u)pHze4XfrWvcft7*19t0RzCJGzWmE;#CXQUQef$8}2#GIUpIa?=n^ED`N zxH`Vx{qw7j;reJ1ys)}uDrD>;&p_i$xl%M#|4o_Hb;dWRuj`fdDjvh*7QKNMy&unx^$sU)L+^RXm2rEqVhjdOw~yd0eDy%Dic&uPyg1I8yyH zO~3W?FE<7=#tl0-et5I*%~5yCuvOaK+coXSeq%5FGkVh6GdgztnH3o08erZh5UT|M Dl|EWe literal 0 HcmV?d00001