From ad5759a5ad552958576d8827a5d37eb0fbeacfd0 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sun, 12 Jul 2020 16:56:41 -0400 Subject: [PATCH] Update method for harming by heal to mob attributes --- mods/ENTITIES/mcl_mobs/api.lua | 4 +++- mods/ENTITIES/mobs_mc/horse.lua | 2 ++ mods/ENTITIES/mobs_mc/skeleton+stray.lua | 1 + mods/ENTITIES/mobs_mc/skeleton_wither.lua | 1 + mods/ENTITIES/mobs_mc/villager_zombie.lua | 1 + mods/ENTITIES/mobs_mc/wither.lua | 2 +- mods/ENTITIES/mobs_mc/zombie.lua | 1 + mods/ENTITIES/mobs_mc/zombiepig.lua | 1 + mods/ITEMS/mcl_potions/functions.lua | 19 +------------------ 9 files changed, 12 insertions(+), 20 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index bdb5dbf125..3ba4d4c93c 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -2042,7 +2042,7 @@ local do_states = function(self, dtime) local is_in_danger = false if lp then - + local is_in_danger = false -- if mob is flying, only check for node it is currently in (no contact with node below) @@ -3438,6 +3438,8 @@ minetest.register_entity(name, { get_staticdata = function(self) return mob_staticdata(self) end, + + harmed_by_heal = def.harmed_by_heal, }) diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index aff938aa48..32ebbc1a92 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -363,6 +363,7 @@ skeleton_horse.sounds = { damage = "mobs_mc_skeleton_hurt", distance = 16, } +skeleton_horse.harmed_by_heal = true mobs:register_mob("mobs_mc:skeleton_horse", skeleton_horse) -- Zombie horse @@ -381,6 +382,7 @@ zombie_horse.sounds = { damage = "mobs_mc_zombie_hurt", distance = 16, } +zombie_horse.harmed_by_heal = true mobs:register_mob("mobs_mc:zombie_horse", zombie_horse) -- Donkey diff --git a/mods/ENTITIES/mobs_mc/skeleton+stray.lua b/mods/ENTITIES/mobs_mc/skeleton+stray.lua index 5d0c8ae858..3192a6c011 100644 --- a/mods/ENTITIES/mobs_mc/skeleton+stray.lua +++ b/mods/ENTITIES/mobs_mc/skeleton+stray.lua @@ -91,6 +91,7 @@ local skeleton = { shoot_offset = 1.5, dogshoot_switch = 1, dogshoot_count_max =1.8, + harmed_by_heal = true, } mobs:register_mob("mobs_mc:skeleton", skeleton) diff --git a/mods/ENTITIES/mobs_mc/skeleton_wither.lua b/mods/ENTITIES/mobs_mc/skeleton_wither.lua index c202228cb4..f2bf2abbc1 100644 --- a/mods/ENTITIES/mobs_mc/skeleton_wither.lua +++ b/mods/ENTITIES/mobs_mc/skeleton_wither.lua @@ -83,6 +83,7 @@ mobs:register_mob("mobs_mc:witherskeleton", { dogshoot_switch = 1, dogshoot_count_max =0.5, fear_height = 4, + harmed_by_heal = true, }) --spawn diff --git a/mods/ENTITIES/mobs_mc/villager_zombie.lua b/mods/ENTITIES/mobs_mc/villager_zombie.lua index 1e87480357..66af8f2277 100644 --- a/mods/ENTITIES/mobs_mc/villager_zombie.lua +++ b/mods/ENTITIES/mobs_mc/villager_zombie.lua @@ -76,6 +76,7 @@ mobs:register_mob("mobs_mc:villager_zombie", { sunlight_damage = 1, view_range = 16, fear_height = 4, + harmed_by_heal = true, }) diff --git a/mods/ENTITIES/mobs_mc/wither.lua b/mods/ENTITIES/mobs_mc/wither.lua index ebbbf92fb1..6af50efff0 100644 --- a/mods/ENTITIES/mobs_mc/wither.lua +++ b/mods/ENTITIES/mobs_mc/wither.lua @@ -61,6 +61,7 @@ mobs:register_mob("mobs_mc:wither", { walk_start = 0, walk_end = 20, run_start = 0, run_end = 20, }, + harmed_by_heal = true, }) local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false @@ -98,4 +99,3 @@ mobs:register_arrow("mobs_mc:wither_skull", { --Spawn egg mobs:register_egg("mobs_mc:wither", S("Wither"), "mobs_mc_spawn_icon_wither.png", 0, true) - diff --git a/mods/ENTITIES/mobs_mc/zombie.lua b/mods/ENTITIES/mobs_mc/zombie.lua index 552369b8c3..416be8a3a0 100644 --- a/mods/ENTITIES/mobs_mc/zombie.lua +++ b/mods/ENTITIES/mobs_mc/zombie.lua @@ -79,6 +79,7 @@ local zombie = { sunlight_damage = 2, view_range = 16, attack_type = "dogfight", + harmed_by_heal = true, } mobs:register_mob("mobs_mc:zombie", zombie) diff --git a/mods/ENTITIES/mobs_mc/zombiepig.lua b/mods/ENTITIES/mobs_mc/zombiepig.lua index bdf97e05d8..577a49afc0 100644 --- a/mods/ENTITIES/mobs_mc/zombiepig.lua +++ b/mods/ENTITIES/mobs_mc/zombiepig.lua @@ -79,6 +79,7 @@ local pigman = { fire_damage = 0, fear_height = 4, view_range = 16, + harmed_by_heal = true, } mobs:register_mob("mobs_mc:pigman", pigman) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 777f090a85..a4f20dd8b6 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -437,29 +437,12 @@ function mcl_potions._add_spawner(obj, color) end -local is_zombie = {} - -for i, zombie in ipairs({"husk","zombie","pigman"}) do - is_zombie["mobs_mc:"..zombie] = true - is_zombie["mobs_mc:baby_"..zombie] = true -end - -is_zombie["mobs_mc:witherskeleton"] = true -is_zombie["mobs_mc:skeleton"] = true -is_zombie["mobs_mc:stray"] = true -is_zombie["mobs_mc:villager_zombie"] = true -is_zombie["mobs_mc:wither"] = true -is_zombie["mobs_mc:skeleton_horse"] = true -is_zombie["mobs_mc:zombie_horse"] = true - - - function mcl_potions.healing_func(player, hp) local obj = player:get_luaentity() - if is_zombie[player:get_entity_name()] then hp = -hp end + if obj and obj.harmed_by_heal then hp = -hp end if hp > 0 then