From 9ba1917209ae5510cd968b8772ce70232077e9fc Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 10 Apr 2021 20:58:34 +0200 Subject: [PATCH] Add end crystal beams --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 16 ++++++ mods/ITEMS/mcl_end/end_crystal.lua | 48 ++++++++++++++++++ .../mcl_end/textures/mcl_end_crystal_beam.png | Bin 0 -> 2065 bytes 3 files changed, 64 insertions(+) create mode 100644 mods/ITEMS/mcl_end/textures/mcl_end_crystal_beam.png diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index 92806d878..db29b63ae 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -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 diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua index 772776a1c..720d8ed8d 100644 --- a/mods/ITEMS/mcl_end/end_crystal.lua +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -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"), diff --git a/mods/ITEMS/mcl_end/textures/mcl_end_crystal_beam.png b/mods/ITEMS/mcl_end/textures/mcl_end_crystal_beam.png new file mode 100644 index 0000000000000000000000000000000000000000..1259a5d0ec80af0c59843b46c21fda8853fa9601 GIT binary patch literal 2065 zcmV+s2=4cZP)EK|00004XF*Lt006O% z3;baP00009a7bBm000id000id0mpBsWB>pMvq?ljRCr#cTL*F+ISkzY|5M2dmX#&T znmfV+7@-lyzN)K|ha?C#8qK(;ZQD-h|M&Oz|3Blhhld9$`}OM=Rqz$lhRC2cFliX- zK=(7(-FGr(4BX$}r(RrLU2&PIgD@~gzrMa;L-qy@p~E70a1@8sK-aSj_wDUX>Ygg# z_Hk0>>+5Tc1^xZ__=uS{4CCqc_SP7f3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