From 61e148ac2e462c61480ca8f95f0b6d38065a3ccd Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 30 Jan 2020 16:52:07 +0100 Subject: [PATCH] Fix mobs able to swim in plants --- mods/ENTITIES/mcl_mobs/api.lua | 33 +++++++++++--------------- mods/ENTITIES/mcl_mobs/api.txt | 6 +++-- mods/ENTITIES/mobs_mc/bat.lua | 1 - mods/ENTITIES/mobs_mc/ender_dragon.lua | 1 - mods/ENTITIES/mobs_mc/ghast.lua | 1 - mods/ENTITIES/mobs_mc/parrot.lua | 1 - mods/ENTITIES/mobs_mc/vex.lua | 1 - 7 files changed, 18 insertions(+), 26 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index dd1d6e2d..03adf9ad 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -344,27 +344,22 @@ local flight_check = function(self) if not def then return false end -- nil check - if type(self.fly_in) == "string" - and nod == self.fly_in then - - return true - + local fly_in + if type(self.fly_in) == "string" then + fly_in = { self.fly_in } elseif type(self.fly_in) == "table" then - - for _,fly_in in pairs(self.fly_in) do - - if nod == fly_in then - - return true - end - end + fly_in = self.fly_in + else + return false end - -- stops mobs getting stuck inside stairs and plantlike nodes - if def.drawtype ~= "airlike" - and def.drawtype ~= "liquid" - and def.drawtype ~= "flowingliquid" then - return true + for _,checknode in pairs(fly_in) do + if nod == checknode then + return true + elseif checknode == "__airlike" and def.walkable == false and + (def.liquidtype == "none" or minetest.get_item_group(nod, "fake_liquid") == 1) then + return true + end end return false @@ -3173,7 +3168,7 @@ minetest.register_entity(name, { type = def.type, attack_type = def.attack_type, fly = def.fly, - fly_in = def.fly_in or "air", + fly_in = def.fly_in or {"air", "__airlike"}, owner = def.owner or "", order = def.order or "", on_die = def.on_die, diff --git a/mods/ENTITIES/mcl_mobs/api.txt b/mods/ENTITIES/mcl_mobs/api.txt index 6813093a..8a2861e4 100644 --- a/mods/ENTITIES/mcl_mobs/api.txt +++ b/mods/ENTITIES/mcl_mobs/api.txt @@ -52,8 +52,10 @@ functions needed for the mob to work properly which contains the following: 'stepheight' height of a block that your mob can easily walk up onto, defaults to 1.1. 'fly' when true allows your mob to fly around instead of walking. - 'fly_in' holds the node name that the mob flies (or swims) around - in e.g. "air" or "default:water_source". + 'fly_in' holds the node name or a table of node names in which the + mob flies (or swims) around in. The special name + '__airlike' stands for all nodes with 'walkable=false' + that are not liquids 'runaway' if true causes animals to turn and run away when hit. 'view_range' how many nodes in distance the mob can see a player. 'damage' how many health points the mob does to a player or another diff --git a/mods/ENTITIES/mobs_mc/bat.lua b/mods/ENTITIES/mobs_mc/bat.lua index 36415470..a4b54bb9 100644 --- a/mods/ENTITIES/mobs_mc/bat.lua +++ b/mods/ENTITIES/mobs_mc/bat.lua @@ -44,7 +44,6 @@ mobs:register_mob("mobs_mc:bat", { view_range = 16, fly = true, - fly_in = "air", }) diff --git a/mods/ENTITIES/mobs_mc/ender_dragon.lua b/mods/ENTITIES/mobs_mc/ender_dragon.lua index 488c5287..0d324bf6 100644 --- a/mods/ENTITIES/mobs_mc/ender_dragon.lua +++ b/mods/ENTITIES/mobs_mc/ender_dragon.lua @@ -34,7 +34,6 @@ mobs:register_mob("mobs_mc:enderdragon", { jump_height = 14, stepheight = 1.2, fly = true, - fly_in = {"air"}, dogshoot_switch = 1, dogshoot_count_max =5, dogshoot_count2_max = 5, diff --git a/mods/ENTITIES/mobs_mc/ghast.lua b/mods/ENTITIES/mobs_mc/ghast.lua index e783adff..ae480bc7 100644 --- a/mods/ENTITIES/mobs_mc/ghast.lua +++ b/mods/ENTITIES/mobs_mc/ghast.lua @@ -66,7 +66,6 @@ mobs:register_mob("mobs_mc:ghast", { jump_height = 4, floats=1, fly = true, - fly_in = {"air"}, }) diff --git a/mods/ENTITIES/mobs_mc/parrot.lua b/mods/ENTITIES/mobs_mc/parrot.lua index ab798842..42006d8c 100644 --- a/mods/ENTITIES/mobs_mc/parrot.lua +++ b/mods/ENTITIES/mobs_mc/parrot.lua @@ -52,7 +52,6 @@ mobs:register_mob("mobs_mc:parrot", { floats = 1, physical = true, fly = true, - fly_in = {"air"}, fear_height = 4, view_range = 16, follow = mobs_mc.follow.parrot, diff --git a/mods/ENTITIES/mobs_mc/vex.lua b/mods/ENTITIES/mobs_mc/vex.lua index 938e2198..fc8b45dc 100644 --- a/mods/ENTITIES/mobs_mc/vex.lua +++ b/mods/ENTITIES/mobs_mc/vex.lua @@ -85,7 +85,6 @@ mobs:register_mob("mobs_mc:vex", { end end, fly = true, - fly_in = {"air"}, })