mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
Add end crystal beams
This commit is contained in:
parent
ea41c82834
commit
9ba1917209
3 changed files with 64 additions and 0 deletions
|
@ -61,6 +61,22 @@ mobs:register_mob("mobs_mc:enderdragon", {
|
|||
ignores_nametag = true,
|
||||
do_custom = function(self)
|
||||
mcl_bossbars.update_boss(self, "Ender Dragon", "light_purple")
|
||||
for _, obj in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 80)) do
|
||||
local luaentity = obj:get_luaentity()
|
||||
if luaentity and luaentity.name == "mcl_end:crystal" then
|
||||
if luaentity.beam then
|
||||
if luaentity.beam == self.beam then
|
||||
break
|
||||
end
|
||||
else
|
||||
if self.beam then
|
||||
self.beam:remove()
|
||||
end
|
||||
minetest.add_entity(self.object:get_pos(), "mcl_end:crystal_beam"):get_luaentity():init(self.object, obj)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if self._portal_pos then
|
||||
-- migrate old format
|
||||
if type(self._portal_pos) == "string" then
|
||||
|
|
|
@ -79,6 +79,54 @@ minetest.register_entity("mcl_end:crystal", {
|
|||
_hittable_by_projectile = true
|
||||
})
|
||||
|
||||
minetest.register_entity("mcl_end:crystal_beam", {
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
visual = "cube",
|
||||
visual_size = {x = 1, y = 1, z = 1},
|
||||
textures = {
|
||||
"mcl_end_crystal_beam.png^[transformR90",
|
||||
"mcl_end_crystal_beam.png^[transformR90",
|
||||
"mcl_end_crystal_beam.png",
|
||||
"mcl_end_crystal_beam.png",
|
||||
"blank.png",
|
||||
"blank.png",
|
||||
},
|
||||
static_save = false,
|
||||
},
|
||||
spin = 0,
|
||||
init = function(self, dragon, crystal)
|
||||
self.dragon, self.crystal = dragon, crystal
|
||||
crystal:get_luaentity().beam = self.object
|
||||
dragon:get_luaentity().beam = self.object
|
||||
end,
|
||||
on_deactivate = function(self)
|
||||
if self.crystal and self.crystal:get_luaentity() then
|
||||
self.crystal:get_luaentity().beam = nil
|
||||
end
|
||||
if self.dragon and self.dragon:get_luaentity() then
|
||||
self.dragon:get_luaentity().beam = nil
|
||||
end
|
||||
end,
|
||||
on_step = function(self, dtime)
|
||||
if self.dragon and self.dragon:get_luaentity() and self.crystal and self.crystal:get_luaentity() then
|
||||
self.spin = self.spin + dtime * math.pi * 2 / 4
|
||||
local dragon_pos, crystal_pos = self.dragon:get_pos(), self.crystal:get_pos()
|
||||
|
||||
dragon_pos.y = dragon_pos.y + 4
|
||||
crystal_pos.y = crystal_pos.y + 2
|
||||
|
||||
self.object:set_pos(vector.divide(vector.add(dragon_pos, crystal_pos), 2))
|
||||
local rot = vector.dir_to_rotation(vector.direction(dragon_pos, crystal_pos))
|
||||
rot.z = self.spin
|
||||
self.object:set_rotation(rot)
|
||||
self.object:set_properties({visual_size = {x = 0.5, y = 0.5, z = vector.distance(dragon_pos, crystal_pos)}})
|
||||
else
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("mcl_end:crystal", {
|
||||
inventory_image = "mcl_end_crystal_item.png",
|
||||
description = S("End Crystal"),
|
||||
|
|
BIN
mods/ITEMS/mcl_end/textures/mcl_end_crystal_beam.png
Normal file
BIN
mods/ITEMS/mcl_end/textures/mcl_end_crystal_beam.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
Loading…
Reference in a new issue