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 zcmdT~ZH!jM6@CD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}Lr3&(5se-&%svs|xD#(ka z3i4v9g1lI&ATO3G$cv>4@?xoiyjZFrFP19Ei=_(kVyS|>SgIf|mMX}Lr3&(5se-&% zsvs|xD#(ka3i4v9g1lI&ATO3G$cv>4@?xoiyjZFrFP1rw7t1`!i)Ak5#WLUWVwsb9 lvCP}NSmt(KEb~7vmN}vq%RJJHWv=PPG9UF~nX`Ja{{^wjZ2|xQ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_end/models/mcl_end_crystal.png b/mods/ITEMS/mcl_end/models/mcl_end_crystal.png new file mode 100644 index 0000000000000000000000000000000000000000..13e12c2ea0038b266a324e4c80996ba9234182c7 GIT binary patch literal 1940 zcmY*Wc{m$*8vaGx8YGSqDGAeJl@eEtD>P`wT`a{q>grUf6qSlbqNULaF*7!lV$5`A zcKfKKzp?tt2Iah<(iTF|&Vs-yh%mz2EV^r6ECnFmpr2fC2!(sVV~ietTY62mnw_^9u9=pshkfmZ$^(P|G@bCK~`v)?Pr)KQC1S02t)> zMCF8COwGwlyp#g662HvMvB^xyK|9#k+Bl{ZV^aW7L7c*Sg%ji6-)_5q)KMG1s#1x@ z;DrcPZS+Y78mA3sAhbo7JSd7H$aO}gHX6=Ah+Q?(mfGKT%-BERyS6XC?+i!2crVU~ zoX%b~BEF@ME{WGBHu_^(7d_?VA(MW2?vQ8U?v>)L5vX9`{Zd7FgXiYjR|_|^`lIk{ zLNe-xpbE<_=6+4ZMlh(@AUPC&sD@x1Gs`zj`VIB0b`cTwbt&s z5kF#}UrjNrNi>|r&HdMyY?&0B+;!P%vAIt#%inOo+j$E1Ya=SynbGz;Cd@BqUnnMb z4U3v7F?-ae7jJxBW*?nH^W9~q+1*p=O~hW=X?82iz$08= zl(c!bERm{aFxB%|t~-kxU%d7X9gqto)hcVQkC=OpU_V3B2+c7lEtY;?*PXqgB$%SR z3gG4dAb4Wn=cbz3xDg{$U1nn0J{6^l5~080z%Q`rv&OV+(w-`hhpT&)-<}B3>i@>> zXcH!;aWj8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