From a3c4d915b3a4cc5d0125fcb62444acda9765d04a Mon Sep 17 00:00:00 2001 From: cora Date: Mon, 12 Sep 2022 05:18:04 +0200 Subject: [PATCH] Fix dragon spawning with crystals --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 6 +++--- mods/ITEMS/mcl_end/end_crystal.lua | 9 ++++++--- mods/MAPGEN/mcl_structures/end_spawn.lua | 6 ++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index fa5ab9ebdd..68b4e0b821 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -84,7 +84,7 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", { if type(self._portal_pos) == "string" then self._portal_pos = minetest.string_to_pos(self._portal_pos) end - local portal_center = vector.add(self._portal_pos, vector.new(3, 11, 3)) + local portal_center = vector.add(self._portal_pos, vector.new(0, 11, 0)) local pos = self.object:get_pos() if vector.distance(pos, portal_center) > 50 then self.object:set_pos(self._last_good_pos or portal_center) @@ -93,10 +93,10 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", { end end end, - on_die = function(self, pos) + on_die = function(self, pos, cmi_cause) if self._portal_pos then mcl_portals.spawn_gateway_portal() - mcl_structures.place_structure(self._portal_pos,mcl_structures.registered_structures["end_exit_portal_open"],PseudoRandom(minetest.get_mapgen_setting("seed")),math.random()) + mcl_structures.place_structure(self._portal_pos,mcl_structures.registered_structures["end_exit_portal_open"],PseudoRandom(minetest.get_mapgen_setting("seed")),-1) if self._initial then mcl_experience.throw_xp(pos, 11500) -- 500 + 11500 = 12000 minetest.set_node(vector.add(self._portal_pos, vector.new(0, 5, 0)), {name = "mcl_end:dragon_egg"}) diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua index b7c80c55a2..d6f488b330 100644 --- a/mods/ITEMS/mcl_end/end_crystal.lua +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -65,12 +65,15 @@ local function spawn_crystal(pos) crystals[i] = find_crystal(crystal_pos) if not crystals[i] then return end end + for _,o in pairs(minetest.get_objects_inside_radius(pos,64)) do + local l = o:get_luaentity() + if l and l.name == "mobs_mc:enderdragon" then return end + end for _, crystal in pairs(crystals) do crystal_explode(crystal) end - 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 = portal_pos + local portal_pos = vector.add(portal_center, vector.new(0, -1, 0)) + mcl_structures.place_structure(portal_pos,mcl_structures.registered_structures["end_exit_portal"],PseudoRandom(minetest.get_mapgen_setting("seed")),-1) end minetest.register_entity("mcl_end:crystal", { diff --git a/mods/MAPGEN/mcl_structures/end_spawn.lua b/mods/MAPGEN/mcl_structures/end_spawn.lua index 0d881617ab..b6838ce0f6 100644 --- a/mods/MAPGEN/mcl_structures/end_spawn.lua +++ b/mods/MAPGEN/mcl_structures/end_spawn.lua @@ -17,15 +17,17 @@ mcl_structures.register_structure("end_exit_portal",{ filenames = { modpath.."/schematics/mcl_structures_end_exit_portal.mts" }, - after_place = function(pos,def,pr) + after_place = function(pos,def,pr,blockseed) local p1 = vector.offset(pos,-5,-5,-5) local p2 = vector.offset(pos,5,5,5) minetest.bulk_set_node(minetest.find_nodes_in_area(p1,p2,{"mcl_portals:portal_end"}),{name="air"}) local obj = minetest.add_entity(vector.offset(pos,3, 11, 3), "mobs_mc:enderdragon") if obj then local dragon_entity = obj:get_luaentity() - dragon_entity._initial = true dragon_entity._portal_pos = pos + if blockseed ~= -1 then + dragon_entity._initial = true + end else minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn") end