This commit is contained in:
Wuzzy 2020-10-23 21:53:42 +02:00
commit 4c39224e6f
10 changed files with 146 additions and 14 deletions

View File

@ -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
})

View File

@ -197,7 +197,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
@ -219,7 +219,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)

View File

@ -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 = 120}, 25)
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 = 6, y = 6},
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")

View File

@ -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

View File

@ -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.

View File

@ -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.=

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

View File

@ -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