forked from MineClone5/MineClone5
Make the dragon stay within a 50 blocks range of the portal
This commit is contained in:
parent
058c6ef9f4
commit
ea08fee9ba
|
@ -61,14 +61,26 @@ mobs:register_mob("mobs_mc:enderdragon", {
|
||||||
ignores_nametag = true,
|
ignores_nametag = true,
|
||||||
do_custom = function(self)
|
do_custom = function(self)
|
||||||
mcl_bossbars.update_boss(self, "Ender Dragon", "light_purple")
|
mcl_bossbars.update_boss(self, "Ender Dragon", "light_purple")
|
||||||
|
if self._portal_pos then
|
||||||
|
-- migrate old format
|
||||||
|
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 pos = self.object:get_pos()
|
||||||
|
if vector.distance(pos, portal_center) > 50 then
|
||||||
|
self.object:set_pos(self._last_good_pos or portal_center)
|
||||||
|
else
|
||||||
|
self._last_good_pos = pos
|
||||||
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
on_die = function(self, pos)
|
on_die = function(self, pos)
|
||||||
if self._portal_pos then
|
if self._portal_pos then
|
||||||
local portal_pos = minetest.string_to_pos(self._portal_pos)
|
mcl_structures.call_struct(self._portal_pos, "end_exit_portal_open")
|
||||||
mcl_structures.call_struct(portal_pos, "end_exit_portal_open")
|
|
||||||
if self._initial then
|
if self._initial then
|
||||||
mcl_experience.throw_experience(pos, 11500) -- 500 + 11500 = 12000
|
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})
|
minetest.set_node(vector.add(self._portal_pos, vector.new(3, 5, 3)), {name = mobs_mc.items.dragon_egg})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -60,7 +60,7 @@ local function spawn_crystal(pos)
|
||||||
end
|
end
|
||||||
local portal_pos = vector.add(portal_center, vector.new(-3, -1, -3))
|
local portal_pos = vector.add(portal_center, vector.new(-3, -1, -3))
|
||||||
mcl_structures.call_struct(portal_pos, "end_exit_portal")
|
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)
|
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", {
|
||||||
|
|
|
@ -1253,7 +1253,7 @@ end
|
||||||
local function generate_end_exit_portal(pos)
|
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()
|
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._initial = true
|
||||||
dragon_entity._portal_pos = minetest.pos_to_string(pos)
|
dragon_entity._portal_pos = pos
|
||||||
mcl_structures.call_struct(pos, "end_exit_portal")
|
mcl_structures.call_struct(pos, "end_exit_portal")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue