Fix dragon spawning with crystals

This commit is contained in:
cora 2022-09-12 05:18:04 +02:00 committed by Gitea
parent e6707d1ef9
commit a3c4d915b3
3 changed files with 13 additions and 8 deletions

@ -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"})

@ -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", {

@ -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