From 21c68158394165033aed64d71fc309ed92fbee45 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 25 Jul 2020 13:32:35 +0200 Subject: [PATCH] Added End Crystal --- mods/ENTITIES/mobs_mc/ender_dragon.lua | 17 +-- mods/ITEMS/mcl_bows/arrow.lua | 4 +- mods/ITEMS/mcl_end/end_crystal.lua | 114 ++++++++++++++++++ mods/ITEMS/mcl_end/init.lua | 3 + mods/ITEMS/mcl_end/locale/mcl_end.de.tr | 5 + mods/ITEMS/mcl_end/locale/template.txt | 5 + mods/ITEMS/mcl_end/models/mcl_end_crystal.b3d | Bin 0 -> 12932 bytes mods/ITEMS/mcl_end/models/mcl_end_crystal.png | Bin 0 -> 1940 bytes .../mcl_end/textures/mcl_end_crystal_item.png | Bin 0 -> 356 bytes mods/ITEMS/mcl_throwing/init.lua | 12 +- 10 files changed, 146 insertions(+), 14 deletions(-) create mode 100644 mods/ITEMS/mcl_end/end_crystal.lua create mode 100644 mods/ITEMS/mcl_end/models/mcl_end_crystal.b3d create mode 100644 mods/ITEMS/mcl_end/models/mcl_end_crystal.png create mode 100644 mods/ITEMS/mcl_end/textures/mcl_end_crystal_item.png diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index c9da0c498..71627aada 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -39,12 +39,6 @@ mobs:register_mob("mobs_mc:enderdragon", { dogshoot_count2_max = 5, passive = false, attack_animals = true, - drops = { - {name = mobs_mc.items.dragon_egg, - chance = 1, - min = 1, - max = 1}, - }, lava_damage = 0, fire_damage = 0, on_rightclick = nil, @@ -58,8 +52,17 @@ mobs:register_mob("mobs_mc:enderdragon", { walk_start = 0, walk_end = 20, run_start = 0, run_end = 20, }, - ignores_nametag = true, + on_die = function(self, own_pos) + if self._egg_spawn_pos then + local pos = minetest.string_to_pos(self._egg_spawn_pos) + --if minetest.get_node(pos).buildable_to then + minetest.set_node(pos, {name = mobs_mc.items.dragon_egg}) + return + --end + end + minetest.add_item(own_pos, mobs_mc.items.dragon_egg) + end }) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index ad65eb122..45cc3e621 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -174,7 +174,7 @@ ARROW_ENTITY.on_step = function(self, dtime) if obj ~= self._shooter and obj:is_player() then ok = true elseif obj:get_luaentity() ~= nil then - if obj ~= self._shooter and obj:get_luaentity()._cmi_is_mob then + if obj ~= self._shooter and (obj:get_luaentity()._cmi_is_mob or obj:get_luaentity()._hittable_by_projectile) then ok = true end end @@ -196,7 +196,7 @@ ARROW_ENTITY.on_step = function(self, dtime) local obj = closest_object local is_player = obj:is_player() local lua = obj:get_luaentity() - if obj ~= self._shooter and (is_player or (lua and lua._cmi_is_mob)) then + if obj ~= self._shooter and (is_player or (lua and (lua._cmi_is_mob or lua._hittable_by_projectile))) then if obj:get_hp() > 0 then -- Check if there is no solid node between arrow and object local ray = minetest.raycast(self.object:get_pos(), obj:get_pos(), true) diff --git a/mods/ITEMS/mcl_end/end_crystal.lua b/mods/ITEMS/mcl_end/end_crystal.lua new file mode 100644 index 000000000..50d3312a8 --- /dev/null +++ b/mods/ITEMS/mcl_end/end_crystal.lua @@ -0,0 +1,114 @@ +local S = minetest.get_translator("mcl_end") + +local explosion_strength = 6 + +local directions = { + {x = 1}, {x = -1}, {z = 1}, {z = -1} +} + +local dimensions = {"x", "y", "z"} + +for _, dir in pairs(directions) do + for _, dim in pairs(dimensions) do + dir[dim] = dir[dim] or 0 + end +end + +local function find_crystal(pos) + local objects = minetest.get_objects_inside_radius(pos, 0) + for _, obj in pairs(objects) do + local luaentity = obj:get_luaentity() + if luaentity and luaentity.name == "mcl_end:crystal" then + return luaentity + end + end +end + +local function crystal_explode(self, puncher) + if self._exploded then return end + self._exploded = true + local strength = puncher and explosion_strength or 1 + mcl_explosions.explode(vector.add(self.object:get_pos(), {x = 0, y = 1.5, z = 0}), strength, {drop_chance = 1}, puncher) + minetest.after(0, self.object.remove, self.object) +end + +local function set_crystal_animation(self) + self.object:set_animation({x = 0, y = 60}, 30) +end + +local function spawn_crystal(pos) + local crystal = minetest.add_entity(pos, "mcl_end:crystal") + if not vector.equals(pos, vector.floor(pos)) then return end + if mcl_worlds.pos_to_dimension(pos) ~= "end" then return end + local portal_center + for _, dir in pairs(directions) do + local node = minetest.get_node(vector.add(pos, dir)) + if node.name == "mcl_portals:portal_end" then + portal_center = vector.add(pos, vector.multiply(dir, 3)) + break + end + end + if not portal_center then return end + local crystals = {} + for i, dir in pairs(directions) do + local crystal_pos = vector.add(portal_center, vector.multiply(dir, 3)) + crystals[i] = find_crystal(crystal_pos) + if not crystals[i] then return end + end + for _, crystal in pairs(crystals) do + crystal_explode(crystal) + end + local dragon = minetest.add_entity(vector.add(portal_center, {x = 0, y = 10, z = 0}), "mobs_mc:enderdragon") + dragon:get_luaentity()._egg_spawn_pos = minetest.pos_to_string(vector.add(portal_center, {x = 0, y = 4, z = 0})) +end + +minetest.register_entity("mcl_end:crystal", { + initial_properties = { + physical = true, + visual = "mesh", + visual_size = {x = 7.5, y = 7.5, z = 7.5}, + collisionbox = {-1, 0.5, -1, 1, 2.5, 1}, + mesh = "mcl_end_crystal.b3d", + textures = {"mcl_end_crystal.png"}, + collide_with_objects = true, + }, + on_punch = crystal_explode, + on_activate = set_crystal_animation, + _exploded = false, + _hittable_by_projectile = true +}) + +minetest.register_craftitem("mcl_end:crystal", { + inventory_image = "mcl_end_crystal_item.png", + description = S("End Crystal"), + stack_max = 64, + on_place = function(itemstack, placer, pointed_thing) + if pointed_thing.type == "node" then + local pos = minetest.get_pointed_thing_position(pointed_thing) + local node = minetest.get_node(pos).name + if find_crystal(pos) then return itemstack end + if node == "mcl_core:obsidian" or node == "mcl_core:bedrock" then + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + spawn_crystal(pos) + end + end + return itemstack + end, + _tt_help = S("Ignited by a punch or a hit with an arrow").."\n"..S("Explosion radius: @1", tostring(explosion_strength)), + _doc_items_longdesc = S("End Crystals are explosive devices. They can be placed on Obsidian or Bedrock. Ignite them by a punch or a hit with an arrow. End Crystals can also be used the spawn the Ender Dragon by placing one at each side of the End Exit Portal."), + _doc_items_usagehelp = S("Place the End Crystal on Obsidian or Bedrock, then punch it or hit it with an arrow to cause an huge and probably deadly explosion. To Spawn the Ender Dragon, place one at each side of the End Exit Portal."), + +}) + +minetest.register_craft({ + output = "mcl_end:crystal", + recipe = { + {"mcl_core:glass", "mcl_core:glass", "mcl_core:glass"}, + {"mcl_core:glass", "mcl_end:ender_eye", "mcl_core:glass"}, + {"mcl_core:glass", "mcl_mobitems:ghast_tear", "mcl_core:glass"}, + } +}) + +minetest.register_alias("mcl_end_crystal:end_crystal", "mcl_end:crystal") diff --git a/mods/ITEMS/mcl_end/init.lua b/mods/ITEMS/mcl_end/init.lua index e3ca8a86b..2adcd7cf8 100644 --- a/mods/ITEMS/mcl_end/init.lua +++ b/mods/ITEMS/mcl_end/init.lua @@ -4,3 +4,6 @@ local basepath = minetest.get_modpath(minetest.get_current_modname()) dofile(basepath.."/chorus_plant.lua") dofile(basepath.."/building.lua") dofile(basepath.."/eye_of_ender.lua") +if not minetest.get_modpath("mcl_end_crystal") then + dofile(basepath.."/end_crystal.lua") +end diff --git a/mods/ITEMS/mcl_end/locale/mcl_end.de.tr b/mods/ITEMS/mcl_end/locale/mcl_end.de.tr index df3ad90f2..3914c2a98 100644 --- a/mods/ITEMS/mcl_end/locale/mcl_end.de.tr +++ b/mods/ITEMS/mcl_end/locale/mcl_end.de.tr @@ -26,3 +26,8 @@ The stem attaches itself to end stone and other chorus blocks.=Der Stängel muss Grows on end stone=Wächst auf Endstein Randomly teleports you when eaten=Zufällige Teleportation, wenn gegessen Guides the way to the mysterious End dimension=Weist den Weg zur mysteriösen Endedimension +End Crystal=Enderkristall +End Crystals are explosive devices. They can be placed on Obsidian or Bedrock. Ignite them by a punch or a hit with an arrow. End Crystals can also be used the spawn the Ender Dragon by placing one at each side of the End Exit Portal.=Enderkristalle sind explosiv. Sie können auf Obsidian oder Grundgestein platziert werden. Man kann sie durch einen Schlag oder einen Treffer mit einem Pfeil entzünden. Ausserdem können sie benutzt werden, um den Enderdrachen zu erzeugen, in dem man je einen auf jeder Seite des Endausgangsportals platziert. +Explosion radius: @1=Explosionsradius: @1 +Ignited by a punch or a hit with an arrow=Entzündbar durch einen Schlag oder einen Treffer mit einem Pfeil +Place the End Crystal on Obsidian or Bedrock, then punch it or hit it with an arrow to cause an huge and probably deadly explosion. To Spawn the Ender Dragon, place one at each side of the End Exit Portal.=Platziere den Enderkistall auf Obsidian oder Grundgestein, dann schlage ihn oder triff ihn mit einem Pfeil, um eine riesige und meistens tödliche Explosion zu bewirken. diff --git a/mods/ITEMS/mcl_end/locale/template.txt b/mods/ITEMS/mcl_end/locale/template.txt index 3f024383e..08c7de07b 100644 --- a/mods/ITEMS/mcl_end/locale/template.txt +++ b/mods/ITEMS/mcl_end/locale/template.txt @@ -26,3 +26,8 @@ The stem attaches itself to end stone and other chorus blocks.= Grows on end stone= Randomly teleports you when eaten= Guides the way to the mysterious End dimension= +End Crystal= +End Crystals are explosive devices. They can be placed on Obsidian or Bedrock. Ignite them by a punch or a hit with an arrow. End Crystals can also be used the spawn the Ender Dragon by placing one at each side of the End Exit Portal.= +Explosion radius: @1= +Ignited by a punch or a hit with an arrow= +Place the End Crystal on Obsidian or Bedrock, then punch it or hit it with an arrow to cause an huge and probably deadly explosion. To Spawn the Ender Dragon, place one at each side of the End Exit Portal.= diff --git a/mods/ITEMS/mcl_end/models/mcl_end_crystal.b3d b/mods/ITEMS/mcl_end/models/mcl_end_crystal.b3d new file mode 100644 index 0000000000000000000000000000000000000000..803bf99336149d7be36a2af547ff810a03f10947 GIT binary patch literal 12932 zcmds+eT-Jc6~>1z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$@3$$FEzvA5eyB^2JQc%13V@^p~10Rx;mVR5mizucFqs@k7tZI+$bH5t|)Z1|8tJ+ z(rm@6;AP5j1J?-rjZIA#0zASZ7}ES3Pved=XR zJY2(Her>Qwc%;8Z|ZjR8}eAKwMx$67v7CT%J<#`XfHuS-4{M2Nl(rted4hd?Txepb_c pVYyzqFXTom7_7%B0B@g7U5~}RKh{AO&A>k>aNIwHc-JqX_!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXPVk-lnPYy$kW9! z#KM2=WJ4|{M;_PbAxYUQ6OuJ6xV5)`XE1xjsIztRMgg51-MxNKT2nmJuDS8nlui2c z-`M!gl>IFoQ~o~Fc(7;piLWKopFdufz`KI^`NEfnyQgJ2lnGx8yO#08`H{w|Vx`Qa z%iD7@Ho!y@jllc2PR*TIk-Jd)ilv4DdFiqj$X$5yBa;`ylJjk>#F3pY~n1jQroP${}Vmh xeEt-*AL*2r7j}3M{Y{$v%G}9vm%j&|lCD-xbX2K0wioDI22WQ%mvv4FO#oU3igy42 literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_throwing/init.lua b/mods/ITEMS/mcl_throwing/init.lua index 58399a29d..e46055e8a 100644 --- a/mods/ITEMS/mcl_throwing/init.lua +++ b/mods/ITEMS/mcl_throwing/init.lua @@ -157,7 +157,7 @@ local check_object_hit = function(self, pos, dmg) -- TODO: Deal knockback self.object:remove() return true - elseif entity._cmi_is_mob == true and (self._thrower ~= object) then + elseif (entity._cmi_is_mob == true or entity._hittable_by_projectile) and (self._thrower ~= object) then -- FIXME: Knockback is broken object:punch(self.object, 1.0, { full_punch_interval = 1.0, @@ -196,22 +196,24 @@ end local snowball_on_step = function(self, dtime) self.timer=self.timer+dtime local pos = self.object:get_pos() + local vel = self.object:get_velocity() local node = minetest.get_node(pos) local def = minetest.registered_nodes[node.name] + -- Destroy when hitting a solid node if self._lastpos.x~=nil then if (def and def.walkable) or not def then - minetest.sound_play("mcl_throwing_snowball_impact_hard", { pos = self.object:get_pos(), max_hear_distance=16, gain=0.7 }, true) - snowball_particles(self._lastpos, self.object:get_velocity()) + minetest.sound_play("mcl_throwing_snowball_impact_hard", { pos = pos, max_hear_distance=16, gain=0.7 }, true) + snowball_particles(self._lastpos, vel) self.object:remove() return end end if check_object_hit(self, pos, {snowball_vulnerable = 3}) then - minetest.sound_play("mcl_throwing_snowball_impact_soft", { pos = self.object:get_pos(), max_hear_distance=16, gain=0.7 }, true) - snowball_particles(pos, self.object:get_velocity()) + minetest.sound_play("mcl_throwing_snowball_impact_soft", { pos = pos, max_hear_distance=16, gain=0.7 }, true) + snowball_particles(pos, vel) self.object:remove() return end