Fix mobs able to swim in plants

This commit is contained in:
Wuzzy 2020-01-30 16:52:07 +01:00
parent 834c8cbc3a
commit 61e148ac2e
7 changed files with 18 additions and 26 deletions

View file

@ -344,28 +344,23 @@ local flight_check = function(self)
if not def then return false end -- nil check if not def then return false end -- nil check
if type(self.fly_in) == "string" local fly_in
and nod == self.fly_in then if type(self.fly_in) == "string" then
fly_in = { self.fly_in }
return true
elseif type(self.fly_in) == "table" then elseif type(self.fly_in) == "table" then
fly_in = self.fly_in
else
return false
end
for _,fly_in in pairs(self.fly_in) do for _,checknode in pairs(fly_in) do
if nod == checknode then
if nod == fly_in 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 return true
end end
end end
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
end
return false return false
end end
@ -3173,7 +3168,7 @@ minetest.register_entity(name, {
type = def.type, type = def.type,
attack_type = def.attack_type, attack_type = def.attack_type,
fly = def.fly, fly = def.fly,
fly_in = def.fly_in or "air", fly_in = def.fly_in or {"air", "__airlike"},
owner = def.owner or "", owner = def.owner or "",
order = def.order or "", order = def.order or "",
on_die = def.on_die, on_die = def.on_die,

View file

@ -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, 'stepheight' height of a block that your mob can easily walk up onto,
defaults to 1.1. defaults to 1.1.
'fly' when true allows your mob to fly around instead of walking. '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 'fly_in' holds the node name or a table of node names in which the
in e.g. "air" or "default:water_source". 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. '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. '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 'damage' how many health points the mob does to a player or another

View file

@ -44,7 +44,6 @@ mobs:register_mob("mobs_mc:bat", {
view_range = 16, view_range = 16,
fly = true, fly = true,
fly_in = "air",
}) })

View file

@ -34,7 +34,6 @@ mobs:register_mob("mobs_mc:enderdragon", {
jump_height = 14, jump_height = 14,
stepheight = 1.2, stepheight = 1.2,
fly = true, fly = true,
fly_in = {"air"},
dogshoot_switch = 1, dogshoot_switch = 1,
dogshoot_count_max =5, dogshoot_count_max =5,
dogshoot_count2_max = 5, dogshoot_count2_max = 5,

View file

@ -66,7 +66,6 @@ mobs:register_mob("mobs_mc:ghast", {
jump_height = 4, jump_height = 4,
floats=1, floats=1,
fly = true, fly = true,
fly_in = {"air"},
}) })

View file

@ -52,7 +52,6 @@ mobs:register_mob("mobs_mc:parrot", {
floats = 1, floats = 1,
physical = true, physical = true,
fly = true, fly = true,
fly_in = {"air"},
fear_height = 4, fear_height = 4,
view_range = 16, view_range = 16,
follow = mobs_mc.follow.parrot, follow = mobs_mc.follow.parrot,

View file

@ -85,7 +85,6 @@ mobs:register_mob("mobs_mc:vex", {
end end
end, end,
fly = true, fly = true,
fly_in = {"air"},
}) })