mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
Fix dragon spawning with crystals
This commit is contained in:
parent
e6707d1ef9
commit
a3c4d915b3
@ -84,7 +84,7 @@ mcl_mobs:register_mob("mobs_mc:enderdragon", {
|
|||||||
if type(self._portal_pos) == "string" then
|
if type(self._portal_pos) == "string" then
|
||||||
self._portal_pos = minetest.string_to_pos(self._portal_pos)
|
self._portal_pos = minetest.string_to_pos(self._portal_pos)
|
||||||
end
|
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()
|
local pos = self.object:get_pos()
|
||||||
if vector.distance(pos, portal_center) > 50 then
|
if vector.distance(pos, portal_center) > 50 then
|
||||||
self.object:set_pos(self._last_good_pos or portal_center)
|
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
|
end
|
||||||
end,
|
end,
|
||||||
on_die = function(self, pos)
|
on_die = function(self, pos, cmi_cause)
|
||||||
if self._portal_pos then
|
if self._portal_pos then
|
||||||
mcl_portals.spawn_gateway_portal()
|
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
|
if self._initial then
|
||||||
mcl_experience.throw_xp(pos, 11500) -- 500 + 11500 = 12000
|
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"})
|
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)
|
crystals[i] = find_crystal(crystal_pos)
|
||||||
if not crystals[i] then return end
|
if not crystals[i] then return end
|
||||||
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
|
for _, crystal in pairs(crystals) do
|
||||||
crystal_explode(crystal)
|
crystal_explode(crystal)
|
||||||
end
|
end
|
||||||
local portal_pos = vector.add(portal_center, vector.new(-3, -1, -3))
|
local portal_pos = vector.add(portal_center, vector.new(0, -1, 0))
|
||||||
mcl_structures.call_struct(portal_pos, "end_exit_portal")
|
mcl_structures.place_structure(portal_pos,mcl_structures.registered_structures["end_exit_portal"],PseudoRandom(minetest.get_mapgen_setting("seed")),-1)
|
||||||
minetest.add_entity(vector.add(portal_pos, vector.new(3, 11, 3)), "mobs_mc:enderdragon"):get_luaentity()._portal_pos = portal_pos
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("mcl_end:crystal", {
|
minetest.register_entity("mcl_end:crystal", {
|
||||||
|
@ -17,15 +17,17 @@ mcl_structures.register_structure("end_exit_portal",{
|
|||||||
filenames = {
|
filenames = {
|
||||||
modpath.."/schematics/mcl_structures_end_exit_portal.mts"
|
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 p1 = vector.offset(pos,-5,-5,-5)
|
||||||
local p2 = 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"})
|
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")
|
local obj = minetest.add_entity(vector.offset(pos,3, 11, 3), "mobs_mc:enderdragon")
|
||||||
if obj then
|
if obj then
|
||||||
local dragon_entity = obj:get_luaentity()
|
local dragon_entity = obj:get_luaentity()
|
||||||
dragon_entity._initial = true
|
|
||||||
dragon_entity._portal_pos = pos
|
dragon_entity._portal_pos = pos
|
||||||
|
if blockseed ~= -1 then
|
||||||
|
dragon_entity._initial = true
|
||||||
|
end
|
||||||
else
|
else
|
||||||
minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn")
|
minetest.log("error", "[mcl_mapgen_core] ERROR! Ender dragon doesn't want to spawn")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user