Merge pull request 'Mob lightning transformation / fix on_lightning_strike api' (#2904) from mob_lighting_transforms_2 into master
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2904 Reviewed-by: MysticTempest <mystictempest@noreply.git.minetest.land>
This commit is contained in:
commit
0d19a66bdd
|
@ -4939,6 +4939,7 @@ minetest.register_entity(name, {
|
|||
|
||||
harmed_by_heal = def.harmed_by_heal,
|
||||
|
||||
on_lightning_strike = def.on_lightning_strike
|
||||
})
|
||||
|
||||
if minetest.get_modpath("doc_identifier") ~= nil then
|
||||
|
|
|
@ -153,6 +153,16 @@ mooshroom_def.on_rightclick = function(self, clicker)
|
|||
end
|
||||
mcl_mobs:capture_mob(self, clicker, 0, 5, 60, false, nil)
|
||||
end
|
||||
|
||||
mooshroom_def.on_lightning_strike = function(self, pos, pos2, objects)
|
||||
if self.base_texture[1] == "mobs_mc_mooshroom_brown.png" then
|
||||
self.base_texture = { "mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png" }
|
||||
else
|
||||
self.base_texture = { "mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" }
|
||||
end
|
||||
self.object:set_properties({ textures = self.base_texture })
|
||||
return true
|
||||
end
|
||||
mcl_mobs:register_mob("mobs_mc:mooshroom", mooshroom_def)
|
||||
|
||||
|
||||
|
|
|
@ -219,6 +219,10 @@ mcl_mobs:register_mob("mobs_mc:creeper_charged", {
|
|||
end
|
||||
end
|
||||
end,
|
||||
on_lightning_strike = function(self, pos, pos2, objects)
|
||||
mcl_util.replace_mob(self.object, "mobs_mc:creeper_charged")
|
||||
return true
|
||||
end,
|
||||
maxdrops = 2,
|
||||
drops = {
|
||||
{name = "mcl_mobitems:gunpowder",
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
name = mobs_mc
|
||||
author = maikerumine
|
||||
description = Adds Minecraft-like monsters and animals.
|
||||
depends = mcl_init, mcl_particles, mcl_mobs, mcl_wip, mcl_core
|
||||
depends = mcl_init, mcl_particles, mcl_mobs, mcl_wip, mcl_core, mcl_util
|
||||
optional_depends = default, mcl_tnt, mcl_bows, mcl_throwing, mcl_fishing, bones, mesecons_materials, mobs_mc_gameconfig, doc_items
|
||||
|
||||
|
|
|
@ -60,6 +60,10 @@ mcl_mobs:register_mob("mobs_mc:pig", {
|
|||
"mcl_mobitems:carrot_on_a_stick"
|
||||
},
|
||||
view_range = 8,
|
||||
on_lightning_strike = function(self, pos, pos2, objects)
|
||||
mcl_util.replace_mob(self.object, "mobs_mc:zombified_piglin")
|
||||
return true
|
||||
end,
|
||||
do_custom = function(self, dtime)
|
||||
|
||||
-- set needed values if not already present
|
||||
|
|
|
@ -1885,6 +1885,10 @@ mcl_mobs:register_mob("mobs_mc:villager", {
|
|||
mcl_log("Died, so bye bye jobsite")
|
||||
end
|
||||
end,
|
||||
on_lightning_strike = function(self, pos, pos2, objects)
|
||||
mcl_util.replace_mob(self.object, "mobs_mc:witch")
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -135,25 +135,11 @@ function lightning.strike_func(pos, pos2, objects)
|
|||
-- damage nearby objects, transform mobs
|
||||
for _, obj in pairs(objects) do
|
||||
local lua = obj:get_luaentity()
|
||||
if lua and lua._on_strike then
|
||||
lua._on_strike(lua, pos, pos2, objects)
|
||||
if lua then
|
||||
if not lua.on_lightning_strike or ( lua.on_lightning_strike and lua.on_lightning_strike(lua, pos, pos2, objects) ~= true ) then
|
||||
mcl_util.deal_damage(obj, 5, { type = "lightning_bolt" })
|
||||
end
|
||||
-- remove this when mob API is done
|
||||
if lua and lua.name == "mobs_mc:pig" then
|
||||
mcl_util.replace_mob(obj, "mobs_mc:pigman")
|
||||
elseif lua and lua.name == "mobs_mc:mooshroom" then
|
||||
if lua.base_texture[1] == "mobs_mc_mooshroom.png" then
|
||||
lua.base_texture = { "mobs_mc_mooshroom_brown.png", "mobs_mc_mushroom_brown.png" }
|
||||
else
|
||||
lua.base_texture = { "mobs_mc_mooshroom.png", "mobs_mc_mushroom_red.png" }
|
||||
end
|
||||
obj:set_properties({ textures = lua.base_texture })
|
||||
elseif lua and lua.name == "mobs_mc:villager" then
|
||||
mcl_util.replace_mob(obj, "mobs_mc:witch")
|
||||
elseif lua and lua.name == "mobs_mc:creeper" then
|
||||
mcl_util.replace_mob(obj, "mobs_mc:creeper_charged")
|
||||
else
|
||||
-- WARNING: unsafe entity handling. object may be removed immediately
|
||||
mcl_util.deal_damage(obj, 5, { type = "lightning_bolt" })
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user